All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate
@ 2016-07-12 12:19 Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
                   ` (12 more replies)
  0 siblings, 13 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Hi,
  This series converts the outer most layer of virtio to
use VMState macros;  this is the easy bit, but I'm hoping that
having done that, the next trick is to nibble away at the virtio_save/load
functions and all of the zillions of device/bus helpers.

I think the first two patches are the most controversial;
they remove migration support for old version of virtio-net and virtio-serial;
(for virtio-net versions prior to 0.11 and for virtio-serial prior to 0.13).
I'm working on the basis that migration has bit rotted enough so
that the streams aren't migration compatible for that long back
on upstream - but if anyone knows otherwise please shout.

The reason for doing those is that the virtio structure makes
it a bit tricky to pass the outer device version number down
through VMState to the device specific code (I can do it
as a hack if necessary using a dummy is_needed function);
and with -net and -serial compatibility sorted I think
every other device just supports a single version.

My main reason for doing this is to get rid of the
calls to register_savevm ('going to disappear as soon..' since 2010)

It's lightly tested using the magic line:
./x86_64-softmmu/qemu-system-x86_64 -nographic -machine pc-i440fx-2.6,accel=kvm -cpu qemu64 -m 2048M -drive file=/home/vmimages/f20.img,if=none,id=drivea -device virtio-scsi,id=scsi -device scsi-hd,drive=drivea -device virtio-rng -device virtio-serial -chardev file,id=test,path=/tmp/testfile -device virtconsole,chardev=test,name=foo -virtfs local,path=/home,security_model=passthrough,mount_tag=host_share  -device virtio-gpu  -drive file=/home/vmimages/jeos-19-64.qcow2,id=jeos,if=none -device virtio-blk,drive=jeos  -device virtio-balloon

Thoughts?

Dave

v2
  Just remerged to current head; only changes are in 0001/0008 for virtio-net
  to merge around the changes in the same function.
  Added R-b's

Dr. David Alan Gilbert (13):
  virtio-net: Remove old migration version support
  virtio-serial: Remove old migration version support
  virtio: Migration helper function and macro
  virtio-scsi: Wrap in vmstate
  virtio-blk: Wrap in vmstate
  virtio-rng: Wrap in vmstate
  virtio-balloon: Wrap in vmstate
  virtio-net: Wrap in vmstate
  virtio-serial: Wrap in vmstate
  9pfs: Wrap in vmstate
  virtio-input: Wrap in vmstate
  virtio-gpu: Wrap in vmstate
  virtio: Update migration docs

 docs/virtio-migration.txt   |   6 ++-
 hw/9pfs/virtio-9p-device.c  |  14 +++---
 hw/block/virtio-blk.c       |  16 +++----
 hw/char/virtio-serial-bus.c |  62 +++++++++------------------
 hw/display/virtio-gpu.c     |  17 +++-----
 hw/input/virtio-input.c     |  26 +++--------
 hw/net/virtio-net.c         | 102 +++++++++++++++++---------------------------
 hw/scsi/virtio-scsi.c       |  21 +++------
 hw/virtio/virtio-balloon.c  |  19 +++------
 hw/virtio/virtio-rng.c      |  20 +++------
 hw/virtio/virtio.c          |   6 +++
 include/hw/virtio/virtio.h  |  20 +++++++++
 12 files changed, 130 insertions(+), 199 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 01/13] virtio-net: Remove old migration version support
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 02/13] virtio-serial: " Dr. David Alan Gilbert (git)
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

virtio-net has had version 11 since 0ce0e8f4 in 2009
(v0.11.0-rc0-1480-g0ce0e8f) - remove the code to support loading
anything earlier.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
---
 hw/net/virtio-net.c | 87 +++++++++++++++++++++--------------------------------
 1 file changed, 34 insertions(+), 53 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9999899..550db30 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1543,7 +1543,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
     VirtIONet *n = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
 
-    if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
+    if (version_id != VIRTIO_NET_VM_VERSION)
         return -EINVAL;
 
     return virtio_load(vdev, f, version_id);
@@ -1562,68 +1562,49 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
                                virtio_vdev_has_feature(vdev,
                                                        VIRTIO_F_VERSION_1));
 
-    if (version_id >= 3)
-        n->status = qemu_get_be16(f);
+    n->status = qemu_get_be16(f);
 
-    if (version_id >= 4) {
-        if (version_id < 8) {
-            n->promisc = qemu_get_be32(f);
-            n->allmulti = qemu_get_be32(f);
-        } else {
-            n->promisc = qemu_get_byte(f);
-            n->allmulti = qemu_get_byte(f);
-        }
-    }
+    n->promisc = qemu_get_byte(f);
+    n->allmulti = qemu_get_byte(f);
 
-    if (version_id >= 5) {
-        n->mac_table.in_use = qemu_get_be32(f);
-        /* MAC_TABLE_ENTRIES may be different from the saved image */
-        if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {
-            qemu_get_buffer(f, n->mac_table.macs,
-                            n->mac_table.in_use * ETH_ALEN);
-        } else {
-            int64_t i;
-
-            /* Overflow detected - can happen if source has a larger MAC table.
-             * We simply set overflow flag so there's no need to maintain the
-             * table of addresses, discard them all.
-             * Note: 64 bit math to avoid integer overflow.
-             */
-            for (i = 0; i < (int64_t)n->mac_table.in_use * ETH_ALEN; ++i) {
-                qemu_get_byte(f);
-            }
-            n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1;
-            n->mac_table.in_use = 0;
+    n->mac_table.in_use = qemu_get_be32(f);
+    /* MAC_TABLE_ENTRIES may be different from the saved image */
+    if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {
+        qemu_get_buffer(f, n->mac_table.macs,
+                        n->mac_table.in_use * ETH_ALEN);
+    } else {
+        int64_t i;
+
+        /* Overflow detected - can happen if source has a larger MAC table.
+         * We simply set overflow flag so there's no need to maintain the
+         * table of addresses, discard them all.
+         * Note: 64 bit math to avoid integer overflow.
+         */
+        for (i = 0; i < (int64_t)n->mac_table.in_use * ETH_ALEN; ++i) {
+            qemu_get_byte(f);
         }
+        n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1;
+        n->mac_table.in_use = 0;
     }
  
-    if (version_id >= 6)
-        qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);
+    qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);
 
-    if (version_id >= 7) {
-        if (qemu_get_be32(f) && !peer_has_vnet_hdr(n)) {
-            error_report("virtio-net: saved image requires vnet_hdr=on");
-            return -1;
-        }
+    if (qemu_get_be32(f) && !peer_has_vnet_hdr(n)) {
+        error_report("virtio-net: saved image requires vnet_hdr=on");
+        return -1;
     }
 
-    if (version_id >= 9) {
-        n->mac_table.multi_overflow = qemu_get_byte(f);
-        n->mac_table.uni_overflow = qemu_get_byte(f);
-    }
+    n->mac_table.multi_overflow = qemu_get_byte(f);
+    n->mac_table.uni_overflow = qemu_get_byte(f);
 
-    if (version_id >= 10) {
-        n->alluni = qemu_get_byte(f);
-        n->nomulti = qemu_get_byte(f);
-        n->nouni = qemu_get_byte(f);
-        n->nobcast = qemu_get_byte(f);
-    }
+    n->alluni = qemu_get_byte(f);
+    n->nomulti = qemu_get_byte(f);
+    n->nouni = qemu_get_byte(f);
+    n->nobcast = qemu_get_byte(f);
 
-    if (version_id >= 11) {
-        if (qemu_get_byte(f) && !peer_has_ufo(n)) {
-            error_report("virtio-net: saved image requires TUN_F_UFO support");
-            return -1;
-        }
+    if (qemu_get_byte(f) && !peer_has_ufo(n)) {
+        error_report("virtio-net: saved image requires TUN_F_UFO support");
+        return -1;
     }
 
     if (n->max_queues > 1) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 02/13] virtio-serial: Remove old migration version support
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 03/13] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

virtio-serial-bus has had version 3 since 37f95bf3d0 in 0.13-rc0;
it's time to clean it up a bit.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
---
 hw/char/virtio-serial-bus.c | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 6e5de6d..490b5ea 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -685,7 +685,7 @@ static void virtio_serial_post_load_timer_cb(void *opaque)
     s->post_load = NULL;
 }
 
-static int fetch_active_ports_list(QEMUFile *f, int version_id,
+static int fetch_active_ports_list(QEMUFile *f,
                                    VirtIOSerial *s, uint32_t nr_active_ports)
 {
     uint32_t i;
@@ -702,6 +702,7 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
     /* Items in struct VirtIOSerialPort */
     for (i = 0; i < nr_active_ports; i++) {
         VirtIOSerialPort *port;
+        uint32_t elem_popped;
         uint32_t id;
 
         id = qemu_get_be32(f);
@@ -714,23 +715,19 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
         s->post_load->connected[i].port = port;
         s->post_load->connected[i].host_connected = qemu_get_byte(f);
 
-        if (version_id > 2) {
-            uint32_t elem_popped;
-
-            qemu_get_be32s(f, &elem_popped);
-            if (elem_popped) {
-                qemu_get_be32s(f, &port->iov_idx);
-                qemu_get_be64s(f, &port->iov_offset);
+        qemu_get_be32s(f, &elem_popped);
+        if (elem_popped) {
+            qemu_get_be32s(f, &port->iov_idx);
+            qemu_get_be64s(f, &port->iov_offset);
 
-                port->elem =
-                    qemu_get_virtqueue_element(f, sizeof(VirtQueueElement));
+            port->elem =
+                qemu_get_virtqueue_element(f, sizeof(VirtQueueElement));
 
-                /*
-                 *  Port was throttled on source machine.  Let's
-                 *  unthrottle it here so data starts flowing again.
-                 */
-                virtio_serial_throttle_port(port, false);
-            }
+            /*
+             *  Port was throttled on source machine.  Let's
+             *  unthrottle it here so data starts flowing again.
+             */
+            virtio_serial_throttle_port(port, false);
         }
     }
     timer_mod(s->post_load->timer, 1);
@@ -739,7 +736,7 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
 
 static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
 {
-    if (version_id > 3) {
+    if (version_id != 3) {
         return -EINVAL;
     }
 
@@ -756,10 +753,6 @@ static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f,
     int ret;
     uint32_t tmp;
 
-    if (version_id < 2) {
-        return 0;
-    }
-
     /* Unused */
     qemu_get_be16s(f, (uint16_t *) &tmp);
     qemu_get_be16s(f, (uint16_t *) &tmp);
@@ -781,7 +774,7 @@ static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f,
     qemu_get_be32s(f, &nr_active_ports);
 
     if (nr_active_ports) {
-        ret = fetch_active_ports_list(f, version_id, s, nr_active_ports);
+        ret = fetch_active_ports_list(f, s, nr_active_ports);
         if (ret) {
             return ret;
         }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 03/13] virtio: Migration helper function and macro
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 02/13] virtio-serial: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 04/13] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

To make conversion of virtio devices to VMState simple
at first add a helper function for the simple virtio_save
case and a helper macro that defines the VMState structure.
These will probably go away or change as more of the virtio
code gets converted.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/virtio/virtio.c         |  6 ++++++
 include/hw/virtio/virtio.h | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 18153d5..3e441a6 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1444,6 +1444,12 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
     vmstate_save_state(f, &vmstate_virtio, vdev, NULL);
 }
 
+/* A wrapper for use as a VMState .put function */
+void virtio_vmstate_save(QEMUFile *f, void *opaque, size_t size)
+{
+    virtio_save(VIRTIO_DEVICE(opaque), f);
+}
+
 static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val)
 {
     VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 96b581d..b6887e7 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -167,6 +167,26 @@ bool virtio_should_notify(VirtIODevice *vdev, VirtQueue *vq);
 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
 
 void virtio_save(VirtIODevice *vdev, QEMUFile *f);
+void virtio_vmstate_save(QEMUFile *f, void *opaque, size_t size);
+
+#define VMSTATE_VIRTIO_DEVICE(devname, v, getf, putf) \
+    static const VMStateDescription vmstate_virtio_ ## devname = { \
+        .name = "virtio-" #devname ,          \
+        .minimum_version_id = v,              \
+        .version_id = v,                      \
+        .fields = (VMStateField[]) {          \
+            {                                 \
+                .name = "virtio",             \
+                .info = &(const VMStateInfo) {\
+                        .name = "virtio",     \
+                        .get = getf,          \
+                        .put = putf,          \
+                    },                        \
+                .flags = VMS_SINGLE,          \
+            },                                \
+            VMSTATE_END_OF_LIST()             \
+        }                                     \
+    }
 
 int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 04/13] virtio-scsi: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (2 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 03/13] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 05/13] virtio-blk: " Dr. David Alan Gilbert (git)
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/scsi/virtio-scsi.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index e8179d6..7c6adc9 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -663,22 +663,17 @@ static void virtio_scsi_reset(VirtIODevice *vdev)
 /* The device does not have anything to save beyond the virtio data.
  * Request data is saved with callbacks from SCSI devices.
  */
-static void virtio_scsi_save(QEMUFile *f, void *opaque)
+static void virtio_scsi_save(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
     virtio_save(vdev, f);
 }
 
-static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_scsi_load(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
-    int ret;
 
-    ret = virtio_load(vdev, f, version_id);
-    if (ret) {
-        return ret;
-    }
-    return 0;
+    return virtio_load(vdev, f, 1);
 }
 
 void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
@@ -864,7 +859,6 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOSCSI *s = VIRTIO_SCSI(dev);
-    static int virtio_scsi_id;
     Error *err = NULL;
 
     virtio_scsi_common_realize(dev, &err, virtio_scsi_handle_ctrl,
@@ -887,9 +881,6 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
             return;
         }
     }
-
-    register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1,
-                    virtio_scsi_save, virtio_scsi_load, s);
 }
 
 static void virtio_scsi_instance_init(Object *obj)
@@ -913,9 +904,6 @@ void virtio_scsi_common_unrealize(DeviceState *dev, Error **errp)
 
 static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp)
 {
-    VirtIOSCSI *s = VIRTIO_SCSI(dev);
-
-    unregister_savevm(dev, "virtio-scsi", s);
     virtio_scsi_common_unrealize(dev, errp);
 }
 
@@ -932,6 +920,8 @@ static Property virtio_scsi_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+VMSTATE_VIRTIO_DEVICE(scsi, 1, virtio_scsi_load, virtio_scsi_save);
+
 static void virtio_scsi_common_class_init(ObjectClass *klass, void *data)
 {
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
@@ -948,6 +938,7 @@ static void virtio_scsi_class_init(ObjectClass *klass, void *data)
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
     dc->props = virtio_scsi_properties;
+    dc->vmsd = &vmstate_virtio_scsi;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
     vdc->realize = virtio_scsi_device_realize;
     vdc->unrealize = virtio_scsi_device_unrealize;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 05/13] virtio-blk: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (3 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 04/13] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 06/13] virtio-rng: " Dr. David Alan Gilbert (git)
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/block/virtio-blk.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index ae86e94..a616b43 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -798,7 +798,7 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
     }
 }
 
-static void virtio_blk_save(QEMUFile *f, void *opaque)
+static void virtio_blk_save(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
 
@@ -823,15 +823,12 @@ static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)
     qemu_put_sbyte(f, 0);
 }
 
-static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_blk_load(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIOBlock *s = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(s);
 
-    if (version_id != 2)
-        return -EINVAL;
-
-    return virtio_load(vdev, f, version_id);
+    return virtio_load(vdev, f, 2);
 }
 
 static int virtio_blk_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -880,7 +877,6 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
     VirtIOBlock *s = VIRTIO_BLK(dev);
     VirtIOBlkConf *conf = &s->conf;
     Error *err = NULL;
-    static int virtio_blk_id;
     unsigned i;
 
     if (!conf->conf.blk) {
@@ -923,8 +919,6 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
     }
 
     s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s);
-    register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
-                    virtio_blk_save, virtio_blk_load, s);
     blk_set_dev_ops(s->blk, &virtio_block_ops, s);
     blk_set_guest_block_size(s->blk, s->conf.conf.logical_block_size);
 
@@ -939,7 +933,6 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
     virtio_blk_data_plane_destroy(s->dataplane);
     s->dataplane = NULL;
     qemu_del_vm_change_state_handler(s->change);
-    unregister_savevm(dev, "virtio-blk", s);
     blockdev_mark_auto_del(s->blk);
     virtio_cleanup(vdev);
 }
@@ -957,6 +950,8 @@ static void virtio_blk_instance_init(Object *obj)
                                   DEVICE(obj), NULL);
 }
 
+VMSTATE_VIRTIO_DEVICE(blk, 2, virtio_blk_load, virtio_blk_save);
+
 static Property virtio_blk_properties[] = {
     DEFINE_BLOCK_PROPERTIES(VirtIOBlock, conf.conf),
     DEFINE_BLOCK_CHS_PROPERTIES(VirtIOBlock, conf.conf),
@@ -977,6 +972,7 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 
     dc->props = virtio_blk_properties;
+    dc->vmsd = &vmstate_virtio_blk;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
     vdc->realize = virtio_blk_device_realize;
     vdc->unrealize = virtio_blk_device_unrealize;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 06/13] virtio-rng: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (4 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 05/13] virtio-blk: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 07/13] virtio-balloon: " Dr. David Alan Gilbert (git)
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/virtio/virtio-rng.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 6b991a7..cd8ca10 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -120,22 +120,12 @@ static uint64_t get_features(VirtIODevice *vdev, uint64_t f, Error **errp)
     return f;
 }
 
-static void virtio_rng_save(QEMUFile *f, void *opaque)
-{
-    VirtIODevice *vdev = opaque;
-
-    virtio_save(vdev, f);
-}
-
-static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_rng_load(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIORNG *vrng = opaque;
     int ret;
 
-    if (version_id != 1) {
-        return -EINVAL;
-    }
-    ret = virtio_load(VIRTIO_DEVICE(vrng), f, version_id);
+    ret = virtio_load(VIRTIO_DEVICE(vrng), f, 1);
     if (ret != 0) {
         return ret;
     }
@@ -214,8 +204,6 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
     vrng->rate_limit_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL,
                                                check_rate_limit, vrng);
     vrng->activate_timer = true;
-    register_savevm(dev, "virtio-rng", -1, 1, virtio_rng_save,
-                    virtio_rng_load, vrng);
 }
 
 static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp)
@@ -225,10 +213,11 @@ static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp)
 
     timer_del(vrng->rate_limit_timer);
     timer_free(vrng->rate_limit_timer);
-    unregister_savevm(dev, "virtio-rng", vrng);
     virtio_cleanup(vdev);
 }
 
+VMSTATE_VIRTIO_DEVICE(rng, 1, virtio_rng_load, virtio_vmstate_save);
+
 static Property virtio_rng_properties[] = {
     /* Set a default rate limit of 2^47 bytes per minute or roughly 2TB/s.  If
      * you have an entropy source capable of generating more entropy than this
@@ -246,6 +235,7 @@ static void virtio_rng_class_init(ObjectClass *klass, void *data)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 
     dc->props = virtio_rng_properties;
+    dc->vmsd = &vmstate_virtio_rng;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
     vdc->realize = virtio_rng_device_realize;
     vdc->unrealize = virtio_rng_device_unrealize;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 07/13] virtio-balloon: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (5 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 06/13] virtio-rng: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 08/13] virtio-net: " Dr. David Alan Gilbert (git)
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/virtio/virtio-balloon.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 1a22e6d..5af429a 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -396,11 +396,6 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
     trace_virtio_balloon_to_target(target, dev->num_pages);
 }
 
-static void virtio_balloon_save(QEMUFile *f, void *opaque)
-{
-    virtio_save(VIRTIO_DEVICE(opaque), f);
-}
-
 static void virtio_balloon_save_device(VirtIODevice *vdev, QEMUFile *f)
 {
     VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
@@ -409,12 +404,9 @@ static void virtio_balloon_save_device(VirtIODevice *vdev, QEMUFile *f)
     qemu_put_be32(f, s->actual);
 }
 
-static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_balloon_load(QEMUFile *f, void *opaque, size_t size)
 {
-    if (version_id != 1)
-        return -EINVAL;
-
-    return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);
+    return virtio_load(VIRTIO_DEVICE(opaque), f, 1);
 }
 
 static int virtio_balloon_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -454,9 +446,6 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
     s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
 
     reset_stats(s);
-
-    register_savevm(dev, "virtio-balloon", -1, 1,
-                    virtio_balloon_save, virtio_balloon_load, s);
 }
 
 static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp)
@@ -466,7 +455,6 @@ static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp)
 
     balloon_stats_destroy_timer(s);
     qemu_remove_balloon_handler(s);
-    unregister_savevm(dev, "virtio-balloon", s);
     virtio_cleanup(vdev);
 }
 
@@ -493,6 +481,8 @@ static void virtio_balloon_instance_init(Object *obj)
                         NULL, s, NULL);
 }
 
+VMSTATE_VIRTIO_DEVICE(balloon, 1, virtio_balloon_load, virtio_vmstate_save);
+
 static Property virtio_balloon_properties[] = {
     DEFINE_PROP_BIT("deflate-on-oom", VirtIOBalloon, host_features,
                     VIRTIO_BALLOON_F_DEFLATE_ON_OOM, false),
@@ -505,6 +495,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 
     dc->props = virtio_balloon_properties;
+    dc->vmsd = &vmstate_virtio_balloon;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
     vdc->realize = virtio_balloon_device_realize;
     vdc->unrealize = virtio_balloon_device_unrealize;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 08/13] virtio-net: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (6 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 07/13] virtio-balloon: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 09/13] virtio-serial: " Dr. David Alan Gilbert (git)
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/net/virtio-net.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 550db30..bb311c4 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1492,7 +1492,7 @@ static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
     virtio_net_set_queues(n);
 }
 
-static void virtio_net_save(QEMUFile *f, void *opaque)
+static void virtio_net_save(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIONet *n = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
@@ -1538,15 +1538,12 @@ static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f)
     }
 }
 
-static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_net_load(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIONet *n = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
 
-    if (version_id != VIRTIO_NET_VM_VERSION)
-        return -EINVAL;
-
-    return virtio_load(vdev, f, version_id);
+    return virtio_load(vdev, f, VIRTIO_NET_VM_VERSION);
 }
 
 static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -1790,8 +1787,6 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
     nc->rxfilter_notify_enabled = 1;
 
     n->qdev = dev;
-    register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
-                    virtio_net_save, virtio_net_load, n);
 }
 
 static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
@@ -1803,8 +1798,6 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
     /* This will stop vhost backend if appropriate. */
     virtio_net_set_status(vdev, 0);
 
-    unregister_savevm(dev, "virtio-net", n);
-
     g_free(n->netclient_name);
     n->netclient_name = NULL;
     g_free(n->netclient_type);
@@ -1839,6 +1832,9 @@ static void virtio_net_instance_init(Object *obj)
                                   DEVICE(n), NULL);
 }
 
+VMSTATE_VIRTIO_DEVICE(net, VIRTIO_NET_VM_VERSION, virtio_net_load,
+                      virtio_net_save);
+
 static Property virtio_net_properties[] = {
     DEFINE_PROP_BIT("csum", VirtIONet, host_features, VIRTIO_NET_F_CSUM, true),
     DEFINE_PROP_BIT("guest_csum", VirtIONet, host_features,
@@ -1893,6 +1889,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 
     dc->props = virtio_net_properties;
+    dc->vmsd = &vmstate_virtio_net;
     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
     vdc->realize = virtio_net_device_realize;
     vdc->unrealize = virtio_net_device_unrealize;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 09/13] virtio-serial: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (7 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 08/13] virtio-net: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 10/13] 9pfs: " Dr. David Alan Gilbert (git)
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/char/virtio-serial-bus.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 490b5ea..db57a38 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -594,12 +594,6 @@ static void vser_reset(VirtIODevice *vdev)
     guest_reset(vser);
 }
 
-static void virtio_serial_save(QEMUFile *f, void *opaque)
-{
-    /* The virtio device */
-    virtio_save(VIRTIO_DEVICE(opaque), f);
-}
-
 static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f)
 {
     VirtIOSerial *s = VIRTIO_SERIAL(vdev);
@@ -734,14 +728,10 @@ static int fetch_active_ports_list(QEMUFile *f,
     return 0;
 }
 
-static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_serial_load(QEMUFile *f, void *opaque, size_t size)
 {
-    if (version_id != 3) {
-        return -EINVAL;
-    }
-
     /* The virtio device */
-    return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);
+    return virtio_load(VIRTIO_DEVICE(opaque), f, 3);
 }
 
 static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -1042,13 +1032,6 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp)
 
     vser->post_load = NULL;
 
-    /*
-     * Register for the savevm section with the virtio-console name
-     * to preserve backward compat
-     */
-    register_savevm(dev, "virtio-console", -1, 3, virtio_serial_save,
-                    virtio_serial_load, vser);
-
     QLIST_INSERT_HEAD(&vserdevices.devices, vser, next);
 }
 
@@ -1079,8 +1062,6 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
 
     QLIST_REMOVE(vser, next);
 
-    unregister_savevm(dev, "virtio-console", vser);
-
     g_free(vser->ivqs);
     g_free(vser->ovqs);
     g_free(vser->ports_map);
@@ -1093,6 +1074,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
     virtio_cleanup(vdev);
 }
 
+/* Note: 'console' is used for backwards compatibility */
+VMSTATE_VIRTIO_DEVICE(console, 3, virtio_serial_load, virtio_vmstate_save);
+
 static Property virtio_serial_properties[] = {
     DEFINE_PROP_UINT32("max_ports", VirtIOSerial, serial.max_virtserial_ports,
                                                   31),
@@ -1108,6 +1092,7 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data)
     QLIST_INIT(&vserdevices.devices);
 
     dc->props = virtio_serial_properties;
+    dc->vmsd = &vmstate_virtio_console;
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
     vdc->realize = virtio_serial_device_realize;
     vdc->unrealize = virtio_serial_device_unrealize;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 10/13] 9pfs: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (8 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 09/13] virtio-serial: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 11/13] virtio-input: " Dr. David Alan Gilbert (git)
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/virtio-9p-device.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 494e85e..009b43f 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -97,14 +97,9 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
     g_free(cfg);
 }
 
-static void virtio_9p_save(QEMUFile *f, void *opaque)
+static int virtio_9p_load(QEMUFile *f, void *opaque, size_t size)
 {
-    virtio_save(VIRTIO_DEVICE(opaque), f);
-}
-
-static int virtio_9p_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);
+    return virtio_load(VIRTIO_DEVICE(opaque), f, 1);
 }
 
 static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
@@ -120,7 +115,6 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
     v->config_size = sizeof(struct virtio_9p_config) + strlen(s->fsconf.tag);
     virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size);
     v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
-    register_savevm(dev, "virtio-9p", -1, 1, virtio_9p_save, virtio_9p_load, v);
 
 out:
     return;
@@ -133,7 +127,6 @@ static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp)
     V9fsState *s = &v->state;
 
     virtio_cleanup(vdev);
-    unregister_savevm(dev, "virtio-9p", v);
     v9fs_device_unrealize_common(s, errp);
 }
 
@@ -175,6 +168,8 @@ void virtio_init_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
 
 /* virtio-9p device */
 
+VMSTATE_VIRTIO_DEVICE(9p, 1, virtio_9p_load, virtio_vmstate_save);
+
 static Property virtio_9p_properties[] = {
     DEFINE_PROP_STRING("mount_tag", V9fsVirtioState, state.fsconf.tag),
     DEFINE_PROP_STRING("fsdev", V9fsVirtioState, state.fsconf.fsdev_id),
@@ -187,6 +182,7 @@ static void virtio_9p_class_init(ObjectClass *klass, void *data)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 
     dc->props = virtio_9p_properties;
+    dc->vmsd = &vmstate_virtio_9p;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
     vdc->realize = virtio_9p_device_realize;
     vdc->unrealize = virtio_9p_device_unrealize;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 11/13] virtio-input: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (9 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 10/13] 9pfs: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 13/13] virtio: Update migration docs Dr. David Alan Gilbert (git)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/input/virtio-input.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index f59749a..848090f 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -216,26 +216,14 @@ static void virtio_input_reset(VirtIODevice *vdev)
     }
 }
 
-static void virtio_input_save(QEMUFile *f, void *opaque)
-{
-    VirtIOInput *vinput = opaque;
-    VirtIODevice *vdev = VIRTIO_DEVICE(vinput);
-
-    virtio_save(vdev, f);
-}
-
-static int virtio_input_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_input_load(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIOInput *vinput = opaque;
     VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(vinput);
     VirtIODevice *vdev = VIRTIO_DEVICE(vinput);
     int ret;
 
-    if (version_id != VIRTIO_INPUT_VM_VERSION) {
-        return -EINVAL;
-    }
-
-    ret = virtio_load(vdev, f, version_id);
+    ret = virtio_load(vdev, f, VIRTIO_INPUT_VM_VERSION);
     if (ret) {
         return ret;
     }
@@ -279,20 +267,14 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp)
                 vinput->cfg_size);
     vinput->evt = virtio_add_queue(vdev, 64, virtio_input_handle_evt);
     vinput->sts = virtio_add_queue(vdev, 64, virtio_input_handle_sts);
-
-    register_savevm(dev, "virtio-input", -1, VIRTIO_INPUT_VM_VERSION,
-                    virtio_input_save, virtio_input_load, vinput);
 }
 
 static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
 {
     VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev);
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
-    VirtIOInput *vinput = VIRTIO_INPUT(dev);
     Error *local_err = NULL;
 
-    unregister_savevm(dev, "virtio-input", vinput);
-
     if (vic->unrealize) {
         vic->unrealize(dev, &local_err);
         if (local_err) {
@@ -303,6 +285,9 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)
     virtio_cleanup(vdev);
 }
 
+VMSTATE_VIRTIO_DEVICE(input, VIRTIO_INPUT_VM_VERSION, virtio_input_load,
+                      virtio_vmstate_save);
+
 static Property virtio_input_properties[] = {
     DEFINE_PROP_STRING("serial", VirtIOInput, serial),
     DEFINE_PROP_END_OF_LIST(),
@@ -314,6 +299,7 @@ static void virtio_input_class_init(ObjectClass *klass, void *data)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 
     dc->props          = virtio_input_properties;
+    dc->vmsd           = &vmstate_virtio_input;
     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
     vdc->realize      = virtio_input_device_realize;
     vdc->unrealize    = virtio_input_device_unrealize;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 12/13] virtio-gpu: Wrap in vmstate
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (10 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 11/13] virtio-input: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  2016-07-12 13:54   ` Gerd Hoffmann
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 13/13] virtio: Update migration docs Dr. David Alan Gilbert (git)
  12 siblings, 1 reply; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/display/virtio-gpu.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index f8b0274..24149f7 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -991,7 +991,7 @@ static const VMStateDescription vmstate_virtio_gpu_unmigratable = {
     .unmigratable = 1,
 };
 
-static void virtio_gpu_save(QEMUFile *f, void *opaque)
+static void virtio_gpu_save(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIOGPU *g = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(g);
@@ -1021,7 +1021,7 @@ static void virtio_gpu_save(QEMUFile *f, void *opaque)
     vmstate_save_state(f, &vmstate_virtio_gpu_scanouts, g, NULL);
 }
 
-static int virtio_gpu_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIOGPU *g = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(g);
@@ -1030,11 +1030,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, int version_id)
     uint32_t resource_id, pformat;
     int i, ret;
 
-    if (version_id != VIRTIO_GPU_VM_VERSION) {
-        return -EINVAL;
-    }
-
-    ret = virtio_load(vdev, f, version_id);
+    ret = virtio_load(vdev, f, VIRTIO_GPU_VM_VERSION);
     if (ret) {
         return ret;
     }
@@ -1170,9 +1166,6 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
 
     if (virtio_gpu_virgl_enabled(g->conf)) {
         vmstate_register(qdev, -1, &vmstate_virtio_gpu_unmigratable, g);
-    } else {
-        register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
-                        virtio_gpu_save, virtio_gpu_load, g);
     }
 }
 
@@ -1220,6 +1213,9 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
 #endif
 }
 
+VMSTATE_VIRTIO_DEVICE(gpu, VIRTIO_GPU_VM_VERSION, virtio_gpu_load,
+                      virtio_gpu_save);
+
 static Property virtio_gpu_properties[] = {
     DEFINE_PROP_UINT32("max_outputs", VirtIOGPU, conf.max_outputs, 1),
 #ifdef CONFIG_VIRGL
@@ -1245,6 +1241,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
     vdc->reset = virtio_gpu_reset;
 
     dc->props = virtio_gpu_properties;
+    dc->vmsd = &vmstate_virtio_gpu;
 }
 
 static const TypeInfo virtio_gpu_info = {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [Qemu-devel] [PATCH v2 13/13] virtio: Update migration docs
  2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (11 preceding siblings ...)
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
@ 2016-07-12 12:19 ` Dr. David Alan Gilbert (git)
  12 siblings, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-12 12:19 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Remove references to register_savevm.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 docs/virtio-migration.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/docs/virtio-migration.txt b/docs/virtio-migration.txt
index cf66458..98a6b0f 100644
--- a/docs/virtio-migration.txt
+++ b/docs/virtio-migration.txt
@@ -28,7 +28,8 @@ virtio core               virtio transport          virtio device
 -----------               ----------------          -------------
 
                                                     save() function registered
-                                                    via register_savevm()
+                                                    via VMState wrapper on
+                                                    device class
 virtio_save()                                       <----------
              ------>      save_config()
                           - save proxy device
@@ -63,7 +64,8 @@ virtio core               virtio transport          virtio device
 -----------               ----------------          -------------
 
                                                     load() function registered
-                                                    via register_savevm()
+                                                    via VMState wrapper on
+                                                    device class
 virtio_load()                                       <----------
              ------>      load_config()
                           - load proxy device
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH v2 12/13] virtio-gpu: Wrap in vmstate
  2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
@ 2016-07-12 13:54   ` Gerd Hoffmann
  2016-07-12 14:02     ` Cornelia Huck
  0 siblings, 1 reply; 20+ messages in thread
From: Gerd Hoffmann @ 2016-07-12 13:54 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git)
  Cc: qemu-devel, mst, amit.shah, quintela, cornelia.huck

> @@ -1170,9 +1166,6 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
>  
>      if (virtio_gpu_virgl_enabled(g->conf)) {
>          vmstate_register(qdev, -1, &vmstate_virtio_gpu_unmigratable, g);
> -    } else {
> -        register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
> -                        virtio_gpu_save, virtio_gpu_load, g);
>      }
>  }
>  
> @@ -1220,6 +1213,9 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
>  #endif
>  }
>  
> +VMSTATE_VIRTIO_DEVICE(gpu, VIRTIO_GPU_VM_VERSION, virtio_gpu_load,
> +                      virtio_gpu_save);
> +
>  static Property virtio_gpu_properties[] = {
>      DEFINE_PROP_UINT32("max_outputs", VirtIOGPU, conf.max_outputs, 1),
>  #ifdef CONFIG_VIRGL
> @@ -1245,6 +1241,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
>      vdc->reset = virtio_gpu_reset;
>  
>      dc->props = virtio_gpu_properties;
> +    dc->vmsd = &vmstate_virtio_gpu;
>  }
>  
>  static const TypeInfo virtio_gpu_info = {

This is confusing.  I think for the virtio_gpu_virgl_enabled() case we
install *two* vmstates now ...

I think you should move up VMSTATE_VIRTIO_DEVICE, then simply replace
the register_savevm() call with a vmstate_register() call.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH v2 12/13] virtio-gpu: Wrap in vmstate
  2016-07-12 13:54   ` Gerd Hoffmann
@ 2016-07-12 14:02     ` Cornelia Huck
  2016-07-12 15:09       ` Gerd Hoffmann
  0 siblings, 1 reply; 20+ messages in thread
From: Cornelia Huck @ 2016-07-12 14:02 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Dr. David Alan Gilbert (git),
	amit.shah, cornelia.huck, quintela, qemu-devel, mst

On Tue, 12 Jul 2016 15:54:57 +0200
Gerd Hoffmann <kraxel@redhat.com> wrote:

> > @@ -1170,9 +1166,6 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
> >  
> >      if (virtio_gpu_virgl_enabled(g->conf)) {
> >          vmstate_register(qdev, -1, &vmstate_virtio_gpu_unmigratable, g);
> > -    } else {
> > -        register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
> > -                        virtio_gpu_save, virtio_gpu_load, g);
> >      }
> >  }
> >  
> > @@ -1220,6 +1213,9 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
> >  #endif
> >  }
> >  
> > +VMSTATE_VIRTIO_DEVICE(gpu, VIRTIO_GPU_VM_VERSION, virtio_gpu_load,
> > +                      virtio_gpu_save);
> > +
> >  static Property virtio_gpu_properties[] = {
> >      DEFINE_PROP_UINT32("max_outputs", VirtIOGPU, conf.max_outputs, 1),
> >  #ifdef CONFIG_VIRGL
> > @@ -1245,6 +1241,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
> >      vdc->reset = virtio_gpu_reset;
> >  
> >      dc->props = virtio_gpu_properties;
> > +    dc->vmsd = &vmstate_virtio_gpu;
> >  }
> >  
> >  static const TypeInfo virtio_gpu_info = {
> 
> This is confusing.  I think for the virtio_gpu_virgl_enabled() case we
> install *two* vmstates now ...

I don't think that matters, as the unmigratable state already blocks,
no?

> 
> I think you should move up VMSTATE_VIRTIO_DEVICE, then simply replace
> the register_savevm() call with a vmstate_register() call.

It would make virtio-gpu look different from all other devices, though.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH v2 12/13] virtio-gpu: Wrap in vmstate
  2016-07-12 14:02     ` Cornelia Huck
@ 2016-07-12 15:09       ` Gerd Hoffmann
  2016-07-12 15:12         ` Dr. David Alan Gilbert
  2016-07-14 16:04         ` Dr. David Alan Gilbert
  0 siblings, 2 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2016-07-12 15:09 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Dr. David Alan Gilbert (git),
	amit.shah, cornelia.huck, quintela, qemu-devel, mst

On Di, 2016-07-12 at 16:02 +0200, Cornelia Huck wrote:
> On Tue, 12 Jul 2016 15:54:57 +0200
> Gerd Hoffmann <kraxel@redhat.com> wrote:
> 
> > > @@ -1170,9 +1166,6 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
> > >  
> > >      if (virtio_gpu_virgl_enabled(g->conf)) {
> > >          vmstate_register(qdev, -1, &vmstate_virtio_gpu_unmigratable, g);
> > > -    } else {
> > > -        register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
> > > -                        virtio_gpu_save, virtio_gpu_load, g);
> > >      }
> > >  }
> > >  
> > > @@ -1220,6 +1213,9 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
> > >  #endif
> > >  }
> > >  
> > > +VMSTATE_VIRTIO_DEVICE(gpu, VIRTIO_GPU_VM_VERSION, virtio_gpu_load,
> > > +                      virtio_gpu_save);
> > > +
> > >  static Property virtio_gpu_properties[] = {
> > >      DEFINE_PROP_UINT32("max_outputs", VirtIOGPU, conf.max_outputs, 1),
> > >  #ifdef CONFIG_VIRGL
> > > @@ -1245,6 +1241,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
> > >      vdc->reset = virtio_gpu_reset;
> > >  
> > >      dc->props = virtio_gpu_properties;
> > > +    dc->vmsd = &vmstate_virtio_gpu;
> > >  }
> > >  
> > >  static const TypeInfo virtio_gpu_info = {
> > 
> > This is confusing.  I think for the virtio_gpu_virgl_enabled() case we
> > install *two* vmstates now ...
> 
> I don't think that matters, as the unmigratable state already blocks,
> no?

As long the core isn't confused if we register twice for the same device
it should work, yes ...

> > I think you should move up VMSTATE_VIRTIO_DEVICE, then simply replace
> > the register_savevm() call with a vmstate_register() call.
> 
> It would make virtio-gpu look different from all other devices, though.

Sure, because depending on device configuration you can migrate it or
not, which isn't the case for all other devices.

I'd prefer to have the logic for that in one place as it makes more
clear how things are working:  "if (!migrateable) register(block) else
register(normal);"

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH v2 12/13] virtio-gpu: Wrap in vmstate
  2016-07-12 15:09       ` Gerd Hoffmann
@ 2016-07-12 15:12         ` Dr. David Alan Gilbert
  2016-07-14 16:04         ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 20+ messages in thread
From: Dr. David Alan Gilbert @ 2016-07-12 15:12 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Cornelia Huck, amit.shah, cornelia.huck, quintela, qemu-devel, mst

* Gerd Hoffmann (kraxel@redhat.com) wrote:
> On Di, 2016-07-12 at 16:02 +0200, Cornelia Huck wrote:
> > On Tue, 12 Jul 2016 15:54:57 +0200
> > Gerd Hoffmann <kraxel@redhat.com> wrote:
> > 
> > > > @@ -1170,9 +1166,6 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
> > > >  
> > > >      if (virtio_gpu_virgl_enabled(g->conf)) {
> > > >          vmstate_register(qdev, -1, &vmstate_virtio_gpu_unmigratable, g);
> > > > -    } else {
> > > > -        register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
> > > > -                        virtio_gpu_save, virtio_gpu_load, g);
> > > >      }
> > > >  }
> > > >  
> > > > @@ -1220,6 +1213,9 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
> > > >  #endif
> > > >  }
> > > >  
> > > > +VMSTATE_VIRTIO_DEVICE(gpu, VIRTIO_GPU_VM_VERSION, virtio_gpu_load,
> > > > +                      virtio_gpu_save);
> > > > +
> > > >  static Property virtio_gpu_properties[] = {
> > > >      DEFINE_PROP_UINT32("max_outputs", VirtIOGPU, conf.max_outputs, 1),
> > > >  #ifdef CONFIG_VIRGL
> > > > @@ -1245,6 +1241,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
> > > >      vdc->reset = virtio_gpu_reset;
> > > >  
> > > >      dc->props = virtio_gpu_properties;
> > > > +    dc->vmsd = &vmstate_virtio_gpu;
> > > >  }
> > > >  
> > > >  static const TypeInfo virtio_gpu_info = {
> > > 
> > > This is confusing.  I think for the virtio_gpu_virgl_enabled() case we
> > > install *two* vmstates now ...
> > 
> > I don't think that matters, as the unmigratable state already blocks,
> > no?
> 
> As long the core isn't confused if we register twice for the same device
> it should work, yes ...
> 
> > > I think you should move up VMSTATE_VIRTIO_DEVICE, then simply replace
> > > the register_savevm() call with a vmstate_register() call.
> > 
> > It would make virtio-gpu look different from all other devices, though.
> 
> Sure, because depending on device configuration you can migrate it or
> not, which isn't the case for all other devices.
> 
> I'd prefer to have the logic for that in one place as it makes more
> clear how things are working:  "if (!migrateable) register(block) else
> register(normal);"

Hmm yes I'll look at this again; I agree registering it twice is probably
a bad idea (whether it happens to work or not, it still seems a bad idea).
virtio-gpu is just a bit special in this case and I'll dig further.

Dave

> cheers,
>   Gerd
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH v2 12/13] virtio-gpu: Wrap in vmstate
  2016-07-12 15:09       ` Gerd Hoffmann
  2016-07-12 15:12         ` Dr. David Alan Gilbert
@ 2016-07-14 16:04         ` Dr. David Alan Gilbert
  2016-07-15  9:53           ` Gerd Hoffmann
  1 sibling, 1 reply; 20+ messages in thread
From: Dr. David Alan Gilbert @ 2016-07-14 16:04 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Cornelia Huck, amit.shah, cornelia.huck, quintela, qemu-devel, mst

* Gerd Hoffmann (kraxel@redhat.com) wrote:
> On Di, 2016-07-12 at 16:02 +0200, Cornelia Huck wrote:
> > On Tue, 12 Jul 2016 15:54:57 +0200
> > Gerd Hoffmann <kraxel@redhat.com> wrote:
> > 
> > > > @@ -1170,9 +1166,6 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
> > > >  
> > > >      if (virtio_gpu_virgl_enabled(g->conf)) {
> > > >          vmstate_register(qdev, -1, &vmstate_virtio_gpu_unmigratable, g);
> > > > -    } else {
> > > > -        register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
> > > > -                        virtio_gpu_save, virtio_gpu_load, g);
> > > >      }
> > > >  }
> > > >  
> > > > @@ -1220,6 +1213,9 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
> > > >  #endif
> > > >  }
> > > >  
> > > > +VMSTATE_VIRTIO_DEVICE(gpu, VIRTIO_GPU_VM_VERSION, virtio_gpu_load,
> > > > +                      virtio_gpu_save);
> > > > +
> > > >  static Property virtio_gpu_properties[] = {
> > > >      DEFINE_PROP_UINT32("max_outputs", VirtIOGPU, conf.max_outputs, 1),
> > > >  #ifdef CONFIG_VIRGL
> > > > @@ -1245,6 +1241,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
> > > >      vdc->reset = virtio_gpu_reset;
> > > >  
> > > >      dc->props = virtio_gpu_properties;
> > > > +    dc->vmsd = &vmstate_virtio_gpu;
> > > >  }
> > > >  
> > > >  static const TypeInfo virtio_gpu_info = {
> > > 
> > > This is confusing.  I think for the virtio_gpu_virgl_enabled() case we
> > > install *two* vmstates now ...
> > 
> > I don't think that matters, as the unmigratable state already blocks,
> > no?
> 
> As long the core isn't confused if we register twice for the same device
> it should work, yes ...
> > > I think you should move up VMSTATE_VIRTIO_DEVICE, then simply replace
> > > the register_savevm() call with a vmstate_register() call.
> > 
> > It would make virtio-gpu look different from all other devices, though.
> 
> Sure, because depending on device configuration you can migrate it or
> not, which isn't the case for all other devices.
> 
> I'd prefer to have the logic for that in one place as it makes more
> clear how things are working:  "if (!migrateable) register(block) else
> register(normal);"

Hmm yes; I think the right fix here is to convert that into
  migrate_add_blocker / migrate_del_blocker

since that's all you're currently doing.
When you actually want to make it migratable add it to virtio_gpu_load/store
(until they get borged into vmstate)

I'll rework with migrate_add/del_blocker calls.

Dave

> 
> cheers,
>   Gerd
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Qemu-devel] [PATCH v2 12/13] virtio-gpu: Wrap in vmstate
  2016-07-14 16:04         ` Dr. David Alan Gilbert
@ 2016-07-15  9:53           ` Gerd Hoffmann
  0 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2016-07-15  9:53 UTC (permalink / raw)
  To: Dr. David Alan Gilbert
  Cc: Cornelia Huck, amit.shah, cornelia.huck, quintela, qemu-devel, mst

  Hi,

> Hmm yes; I think the right fix here is to convert that into
>   migrate_add_blocker / migrate_del_blocker

Oh, didn't notice we have that, yes that sounds good.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-07-15  9:53 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 02/13] virtio-serial: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 03/13] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 04/13] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 05/13] virtio-blk: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 06/13] virtio-rng: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 07/13] virtio-balloon: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 08/13] virtio-net: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 09/13] virtio-serial: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 10/13] 9pfs: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 11/13] virtio-input: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
2016-07-12 13:54   ` Gerd Hoffmann
2016-07-12 14:02     ` Cornelia Huck
2016-07-12 15:09       ` Gerd Hoffmann
2016-07-12 15:12         ` Dr. David Alan Gilbert
2016-07-14 16:04         ` Dr. David Alan Gilbert
2016-07-15  9:53           ` Gerd Hoffmann
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 13/13] virtio: Update migration docs Dr. David Alan Gilbert (git)

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.