From: Greg Kurz <gkurz@linux.vnet.ibm.com>
To: Kevin Wolf <kwolf@redhat.com>,
Anthony Liguori <aliguori@amazon.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Amit Shah <amit.shah@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: "Juan Quintela" <quintela@redhat.com>,
"Fam Zheng" <famz@redhat.com>, "Alexander Graf" <agraf@suse.de>,
"Andreas Färber" <afaerber@suse.de>,
qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH RFC 1/8] virtio: introduce device specific migration calls
Date: Mon, 19 May 2014 10:38:15 +0200 [thread overview]
Message-ID: <20140519083815.22955.63827.stgit@bahia.local> (raw)
In-Reply-To: <20140519063132.22955.63563.stgit@bahia.local>
In order to migrate virtio subsections, we need the device specific
code to be called from the common migration code. This patch introduces
load and save methods for this purpose.
Suggested-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
hw/block/virtio-blk.c | 2 +-
hw/char/virtio-serial-bus.c | 2 +-
hw/net/virtio-net.c | 2 +-
hw/scsi/virtio-scsi.c | 2 +-
hw/virtio/virtio-balloon.c | 2 +-
hw/virtio/virtio-rng.c | 2 +-
hw/virtio/virtio.c | 13 ++++++++++++-
include/hw/virtio/virtio.h | 4 +++-
8 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 8a568e5..63d4ccd 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -611,7 +611,7 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
if (version_id != 2)
return -EINVAL;
- ret = virtio_load(vdev, f);
+ ret = virtio_load(vdev, f, version_id);
if (ret) {
return ret;
}
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 2b647b6..b0f322a 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -676,7 +676,7 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
}
/* The virtio device */
- ret = virtio_load(VIRTIO_DEVICE(s), f);
+ ret = virtio_load(VIRTIO_DEVICE(s), f, version_id);
if (ret) {
return ret;
}
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index fd23c46..e0dc544 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1311,7 +1311,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
return -EINVAL;
- ret = virtio_load(vdev, f);
+ ret = virtio_load(vdev, f, version_id);
if (ret) {
return ret;
}
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index b0d7517..e82e66d 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -478,7 +478,7 @@ static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)
VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
int ret;
- ret = virtio_load(vdev, f);
+ ret = virtio_load(vdev, f, version_id);
if (ret) {
return ret;
}
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index a470a0b..6d8ec72 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -327,7 +327,7 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
if (version_id != 1)
return -EINVAL;
- ret = virtio_load(vdev, f);
+ ret = virtio_load(vdev, f, version_id);
if (ret) {
return ret;
}
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index b6ab361..025de81 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -113,7 +113,7 @@ static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id)
if (version_id != 1) {
return -EINVAL;
}
- virtio_load(vdev, f);
+ virtio_load(vdev, f, version_id);
/* We may have an element ready but couldn't process it due to a quota
* limit. Make sure to try again after live migration when the quota may
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index aeabf3a..cf87b44 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -837,6 +837,7 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
{
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
int i;
if (k->save_config) {
@@ -871,6 +872,10 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
k->save_queue(qbus->parent, i, f);
}
}
+
+ if (vdc->save != NULL) {
+ vdc->save(vdev, f);
+ }
}
int virtio_set_features(VirtIODevice *vdev, uint32_t val)
@@ -889,13 +894,14 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val)
return bad ? -1 : 0;
}
-int virtio_load(VirtIODevice *vdev, QEMUFile *f)
+int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
{
int num, i, ret;
uint32_t features;
uint32_t supported_features;
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
if (k->load_config) {
ret = k->load_config(qbus->parent, f);
@@ -956,6 +962,11 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
}
virtio_notify_vector(vdev, VIRTIO_NO_VECTOR);
+
+ if (vdc->load != NULL) {
+ return vdc->load(vdev, f, version_id);
+ }
+
return 0;
}
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 3e54e90..3505ce5 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -150,6 +150,8 @@ typedef struct VirtioDeviceClass {
* must mask in frontend instead.
*/
void (*guest_notifier_mask)(VirtIODevice *vdev, int n, bool mask);
+ void (*save)(VirtIODevice *vdev, QEMUFile *f);
+ int (*load)(VirtIODevice *vdev, QEMUFile *f, int version_id);
} VirtioDeviceClass;
void virtio_init(VirtIODevice *vdev, const char *name,
@@ -184,7 +186,7 @@ void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
void virtio_save(VirtIODevice *vdev, QEMUFile *f);
-int virtio_load(VirtIODevice *vdev, QEMUFile *f);
+int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id);
void virtio_notify_config(VirtIODevice *vdev);
next prev parent reply other threads:[~2014-05-19 8:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 8:38 [Qemu-devel] [PATCH RFC V2 0/8] virtio: migrate new properties Greg Kurz
2014-05-19 8:38 ` Greg Kurz [this message]
2014-05-19 8:38 ` [Qemu-devel] [PATCH RFC 2/8] virtio-net: implement per-device migration calls Greg Kurz
2014-05-19 8:38 ` [Qemu-devel] [PATCH RFC 3/8] virtio-blk: " Greg Kurz
2014-05-19 8:38 ` [Qemu-devel] [PATCH RFC 4/8] virtio-serial: " Greg Kurz
2014-05-19 8:38 ` [Qemu-devel] [PATCH RFC 5/8] virtio-balloon: " Greg Kurz
2014-05-19 8:38 ` [Qemu-devel] [PATCH RFC 6/8] virtio-rng: " Greg Kurz
2014-05-19 8:39 ` [Qemu-devel] [PATCH RFC 7/8] virtio: add subsections to the migration stream Greg Kurz
2014-05-19 8:39 ` [Qemu-devel] [PATCH RFC 8/8] virtio: add endian-ambivalent support to VirtIODevice Greg Kurz
2014-05-19 13:06 ` Greg Kurz
2014-05-19 17:06 ` Andreas Färber
2014-05-19 17:32 ` Greg Kurz
2014-05-19 18:07 ` Dr. David Alan Gilbert
2014-05-19 12:02 ` [Qemu-devel] [PATCH RFC V2 0/8] virtio: migrate new properties Alexander Graf
2014-05-19 12:45 ` Greg Kurz
2014-05-19 13:07 ` Alexander Graf
2014-05-19 15:10 ` Michael S. Tsirkin
2014-05-19 15:36 ` Alexander Graf
2014-05-19 15:50 ` Michael S. Tsirkin
2014-05-19 15:40 ` Andreas Färber
2014-05-19 15:53 ` Michael S. Tsirkin
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=20140519083815.22955.63827.stgit@bahia.local \
--to=gkurz@linux.vnet.ibm.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aliguori@amazon.com \
--cc=amit.shah@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.