From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: Jason Wang <jasowang@redhat.com>,
Mikhail Sennikovsky <mikhail.sennikovskii@cloud.ionos.com>,
qemu-stable@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [PULL 2/4] virtio: new post_load hook
Date: Mon, 28 Oct 2019 14:35:18 +0800 [thread overview]
Message-ID: <1572244520-14737-3-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1572244520-14737-1-git-send-email-jasowang@redhat.com>
From: "Michael S. Tsirkin" <mst@redhat.com>
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.
Cc: qemu-stable@nongnu.org
Suggested-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Mikhail Sennikovsky <mikhail.sennikovskii@cloud.ionos.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
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 527df03..54a46e2 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;
+ }
+ }
+
return 0;
}
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 48e8d04..ca4f9c0 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;
--
2.5.0
next prev parent reply other threads:[~2019-10-28 6:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-28 6:35 [PULL 0/4] Net patches Jason Wang
2019-10-28 6:35 ` [PULL 1/4] net: add tulip (dec21143) driver Jason Wang
2019-10-28 6:35 ` Jason Wang [this message]
2019-10-28 6:35 ` [PULL 3/4] virtio-net: prevent offloads reset on migration Jason Wang
2019-10-28 6:35 ` [PULL 4/4] COLO-compare: Fix incorrect `if` logic Jason Wang
2019-10-28 21:42 ` [PULL 0/4] Net patches Peter Maydell
2019-10-29 2:33 ` Jason Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1572244520-14737-3-git-send-email-jasowang@redhat.com \
--to=jasowang@redhat.com \
--cc=mikhail.sennikovskii@cloud.ionos.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).