[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC 1/2] virtio: new post_load hook
From: |
Alex Bennée |
Subject: |
Re: [RFC 1/2] virtio: new post_load hook |
Date: |
Fri, 11 Oct 2019 14:15:47 +0100 |
User-agent: |
mu4e 1.3.5; emacs 27.0.50 |
Michael S. Tsirkin <address@hidden> writes:
> Post load hook in virtio vmsd is called early while device is processed,
> and when VirtIODevice core isn't fully initialized. Most device
> specific code isn't ready to deal with a device in such state, and
> behaves weirdly.
>
> Add a new post_load hook in a device class instead. Devices should use
> this unless they specifically want to verify the migration stream as
> it's processed, e.g. for bounds checking.
>
> Suggested-by: "Dr. David Alan Gilbert" <address@hidden>
> Cc: Mikhail Sennikovsky <address@hidden>
> Signed-off-by: Michael S. Tsirkin <address@hidden>
> ---
> hw/virtio/virtio.c | 7 +++++++
> include/hw/virtio/virtio.h | 6 ++++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 527df03bfd..54a46e204c 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -2291,6 +2291,13 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int
> version_id)
> }
> rcu_read_unlock();
>
> + if (vdc->post_load) {
> + ret = vdc->post_load(vdev);
> + if (ret) {
> + return ret;
> + }
I see this pattern repeated above because we get early exits on error
but here it seems superfluous. Why not:
return vdc->_post_load(vdev)
?
> + }
> +
> return 0;
> }
>
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index 48e8d04ff6..ca4f9c0bcc 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -158,6 +158,12 @@ typedef struct VirtioDeviceClass {
> */
> void (*save)(VirtIODevice *vdev, QEMUFile *f);
> int (*load)(VirtIODevice *vdev, QEMUFile *f, int version_id);
> + /* Post load hook in vmsd is called early while device is processed, and
> + * when VirtIODevice isn't fully initialized. Devices should use this
> instead,
> + * unless they specifically want to verify the migration stream as it's
> + * processed, e.g. for bounds checking.
> + */
> + int (*post_load)(VirtIODevice *vdev);
> const VMStateDescription *vmsd;
> } VirtioDeviceClass;
--
Alex Bennée
- [RFC 2/2] virtio-net: use post load hook, (continued)
- [RFC 2/2] virtio-net: use post load hook, Michael S. Tsirkin, 2019/10/10
- Re: [RFC 2/2] virtio-net: use post load hook, Jason Wang, 2019/10/10
- Re: [RFC 2/2] virtio-net: use post load hook, Mikhail Sennikovsky, 2019/10/11
- Re: [RFC 2/2] virtio-net: use post load hook, Michael S. Tsirkin, 2019/10/11
- Re: [RFC 2/2] virtio-net: use post load hook, Mikhail Sennikovsky, 2019/10/11
- Re: [RFC 2/2] virtio-net: use post load hook, Michael S. Tsirkin, 2019/10/11
- Re: [RFC 2/2] virtio-net: use post load hook, Mikhail Sennikovsky, 2019/10/11
- Re: [RFC 2/2] virtio-net: use post load hook, Mikhail Sennikovsky, 2019/10/11
- Re: [RFC 2/2] virtio-net: use post load hook, Michael S. Tsirkin, 2019/10/11
- Re: [RFC 2/2] virtio-net: use post load hook, Michael S. Tsirkin, 2019/10/11
Re: [RFC 1/2] virtio: new post_load hook,
Alex Bennée <=