All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
@ 2016-06-21 19:13 Dr. David Alan Gilbert (git)
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
                   ` (16 more replies)
  0 siblings, 17 replies; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:13 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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

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] 41+ messages in thread

* [Qemu-devel] [PATCH 01/13] virtio-net: Remove old migration version support
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
@ 2016-06-21 19:13 ` Dr. David Alan Gilbert (git)
  2016-06-27  6:46   ` Amit Shah
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 02/13] virtio-serial: " Dr. David Alan Gilbert (git)
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:13 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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 5798f87..1fae1ee 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1544,7 +1544,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
     int ret;
 
-    if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
+    if (version_id != VIRTIO_NET_VM_VERSION)
         return -EINVAL;
 
     ret = virtio_load(vdev, f, version_id);
@@ -1584,68 +1584,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] 41+ messages in thread

* [Qemu-devel] [PATCH 02/13] virtio-serial: Remove old migration version support
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
@ 2016-06-21 19:13 ` Dr. David Alan Gilbert (git)
  2016-06-27  6:45   ` Amit Shah
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 03/13] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:13 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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] 41+ messages in thread

* [Qemu-devel] [PATCH 03/13] virtio: Migration helper function and macro
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 02/13] virtio-serial: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:13 ` Dr. David Alan Gilbert (git)
  2016-06-22 17:39   ` Cornelia Huck
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 04/13] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
                   ` (13 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:13 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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 7ed06ea..7322018 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] 41+ messages in thread

* [Qemu-devel] [PATCH 04/13] virtio-scsi: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (2 preceding siblings ...)
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 03/13] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
@ 2016-06-21 19:13 ` Dr. David Alan Gilbert (git)
  2016-06-22 17:40   ` Cornelia Huck
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 05/13] virtio-blk: " Dr. David Alan Gilbert (git)
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:13 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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 71d09d3..6e518f4 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -663,7 +663,7 @@ 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);
     VirtIOSCSI *s = VIRTIO_SCSI(vdev);
@@ -674,16 +674,11 @@ static void virtio_scsi_save(QEMUFile *f, void *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,
@@ -869,7 +864,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,
@@ -892,9 +886,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)
@@ -918,9 +909,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);
 }
 
@@ -937,6 +925,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);
@@ -953,6 +943,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] 41+ messages in thread

* [Qemu-devel] [PATCH 05/13] virtio-blk: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (3 preceding siblings ...)
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 04/13] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
@ 2016-06-21 19:13 ` Dr. David Alan Gilbert (git)
  2016-06-22 17:42   ` Cornelia Huck
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 06/13] virtio-rng: " Dr. David Alan Gilbert (git)
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:13 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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 284e646..8b93f9f 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -792,7 +792,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);
     VirtIOBlock *s = VIRTIO_BLK(vdev);
@@ -817,15 +817,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,
@@ -861,7 +858,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;
 
     if (!conf->conf.blk) {
         error_setg(errp, "drive property not set");
@@ -897,8 +893,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);
 
@@ -913,7 +907,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);
 }
@@ -931,6 +924,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),
@@ -950,6 +945,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] 41+ messages in thread

* [Qemu-devel] [PATCH 06/13] virtio-rng: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (4 preceding siblings ...)
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 05/13] virtio-blk: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:14 ` Dr. David Alan Gilbert (git)
  2016-06-22 17:44   ` Cornelia Huck
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 07/13] virtio-balloon: " Dr. David Alan Gilbert (git)
                   ` (10 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:14 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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] 41+ messages in thread

* [Qemu-devel] [PATCH 07/13] virtio-balloon: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (5 preceding siblings ...)
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 06/13] virtio-rng: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:14 ` Dr. David Alan Gilbert (git)
  2016-06-22 17:46   ` Cornelia Huck
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 08/13] virtio-net: " Dr. David Alan Gilbert (git)
                   ` (9 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:14 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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 557d3f9..22894f3 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] 41+ messages in thread

* [Qemu-devel] [PATCH 08/13] virtio-net: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (6 preceding siblings ...)
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 07/13] virtio-balloon: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:14 ` Dr. David Alan Gilbert (git)
  2016-06-23  7:39   ` Cornelia Huck
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 09/13] virtio-serial: " Dr. David Alan Gilbert (git)
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:14 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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 1fae1ee..b369fa4 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,16 +1538,13 @@ 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);
     int ret;
 
-    if (version_id != VIRTIO_NET_VM_VERSION)
-        return -EINVAL;
-
-    ret = virtio_load(vdev, f, version_id);
+    ret = virtio_load(vdev, f, VIRTIO_NET_VM_VERSION);
     if (ret) {
         return ret;
     }
@@ -1796,8 +1793,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)
@@ -1809,8 +1804,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);
@@ -1845,6 +1838,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,
@@ -1899,6 +1895,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] 41+ messages in thread

* [Qemu-devel] [PATCH 09/13] virtio-serial: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (7 preceding siblings ...)
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 08/13] virtio-net: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:14 ` Dr. David Alan Gilbert (git)
  2016-06-23  7:55   ` Cornelia Huck
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 10/13] 9pfs: " Dr. David Alan Gilbert (git)
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:14 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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] 41+ messages in thread

* [Qemu-devel] [PATCH 10/13] 9pfs: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (8 preceding siblings ...)
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 09/13] virtio-serial: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:14 ` Dr. David Alan Gilbert (git)
  2016-06-23  8:01   ` Cornelia Huck
  2016-06-30  7:02   ` Greg Kurz
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 11/13] virtio-input: " Dr. David Alan Gilbert (git)
                   ` (6 subsequent siblings)
  16 siblings, 2 replies; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:14 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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] 41+ messages in thread

* [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (9 preceding siblings ...)
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 10/13] 9pfs: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:14 ` Dr. David Alan Gilbert (git)
  2016-06-22  6:48   ` Gerd Hoffmann
  2016-06-23  8:07   ` Cornelia Huck
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
                   ` (5 subsequent siblings)
  16 siblings, 2 replies; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:14 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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] 41+ messages in thread

* [Qemu-devel] [PATCH 12/13] virtio-gpu: Wrap in vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (10 preceding siblings ...)
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 11/13] virtio-input: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:14 ` Dr. David Alan Gilbert (git)
  2016-06-23  8:19   ` Cornelia Huck
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 13/13] virtio: Update migration docs Dr. David Alan Gilbert (git)
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:14 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, 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>
---
 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 136c095..52f2e7c 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -985,7 +985,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);
@@ -1015,7 +1015,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);
@@ -1024,11 +1024,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;
     }
@@ -1164,9 +1160,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);
     }
 }
 
@@ -1214,6 +1207,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
@@ -1239,6 +1235,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] 41+ messages in thread

* [Qemu-devel] [PATCH 13/13] virtio: Update migration docs
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (11 preceding siblings ...)
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
@ 2016-06-21 19:14 ` Dr. David Alan Gilbert (git)
  2016-06-23  8:23   ` Cornelia Huck
  2016-06-22  6:53 ` [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Gerd Hoffmann
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-06-21 19:14 UTC (permalink / raw)
  To: qemu-devel, mst, amit.shah, quintela, kraxel

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

Remove references to register_savevm.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.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] 41+ messages in thread

* Re: [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 11/13] virtio-input: " Dr. David Alan Gilbert (git)
@ 2016-06-22  6:48   ` Gerd Hoffmann
  2016-06-22  9:54     ` Dr. David Alan Gilbert
  2016-06-23  8:07   ` Cornelia Huck
  1 sibling, 1 reply; 41+ messages in thread
From: Gerd Hoffmann @ 2016-06-22  6:48 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela

On Di, 2016-06-21 at 20:14 +0100, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Forcibly convert it to a vmstate wrapper;  proper conversion
> comes later.

FYI: Should be an easy target for proper conversion as virtio-input
doesn't need to save any device-specific state beside the usual virtio
and pci bits.

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (12 preceding siblings ...)
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 13/13] virtio: Update migration docs Dr. David Alan Gilbert (git)
@ 2016-06-22  6:53 ` Gerd Hoffmann
  2016-06-22  9:50   ` Dr. David Alan Gilbert
  2016-06-22  8:39 ` Cornelia Huck
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 41+ messages in thread
From: Gerd Hoffmann @ 2016-06-22  6:53 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela

  Hi,

> 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.

We've gone great lengths to avoid new versions by using subsections
instead for *years*.  So if we are going to cut live migration support
from ancient versions now:  Can we possibly remove the versioning
altogether?

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (13 preceding siblings ...)
  2016-06-22  6:53 ` [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Gerd Hoffmann
@ 2016-06-22  8:39 ` Cornelia Huck
  2016-06-22 10:54   ` Dr. David Alan Gilbert
  2016-06-24  5:49 ` Michael S. Tsirkin
  2016-06-27  6:50 ` Amit Shah
  16 siblings, 1 reply; 41+ messages in thread
From: Cornelia Huck @ 2016-06-22  8:39 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:13:54 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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).

These seem rather ancient and we would not care from a s390x
perspective. Others may think differently, though...

> 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)

Real Soon Now :) Thank you for tackling virtio!

> 
> 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?

Do you have a git tree to test somewhere? I'll take a look at the
patches later, but it would be good if we could give it a quick test on
s390x as well.

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-22  6:53 ` [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Gerd Hoffmann
@ 2016-06-22  9:50   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 41+ messages in thread
From: Dr. David Alan Gilbert @ 2016-06-22  9:50 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, mst, amit.shah, quintela

* Gerd Hoffmann (kraxel@redhat.com) wrote:
>   Hi,
> 
> > 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.
> 
> We've gone great lengths to avoid new versions by using subsections
> instead for *years*.  So if we are going to cut live migration support
> from ancient versions now:  Can we possibly remove the versioning
> altogether?

Short answer: no

Longer answer:  I'm saying we can remove some compatibility from very
old versions, especially if we probably lost the compatibility anyway,
but we should stick to trying to maintain compatibility where possible.

I've just tested an upstream 0.12.5 migration and it doesn't work;
/opt/qemu-0.12/bin/qemu-system-x86_64 -cpu core2duo -M pc-0.12 --enable-kvm -m 1G /home/vms/f20-raw.raw -nographic 

migrating to:
1.1.2, 1.2.2, 2.5.1
all fail with:
qemu: warning: error while loading state for instance 0x0 of device 'ram'

and I've not dug into why.
(Migration to 1.0.1 hangs instead).

Given that, there doesn't seem to be any point in trying to maintain
compatibility for loading a stream produced by 0.11 for example.

As you know, we do jump through hoops downstream to have one
very specific 0.12 derivative migrate to our current releases,
and yes this patch set means I'm going to have to do a bit more
work to make that keep happening in one corner of it.
Although if I'm lucky by then if I can get the rest of this
code to be using VMState then it'll be much easier to do
the 0.12 compatibility code.

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

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

* Re: [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate
  2016-06-22  6:48   ` Gerd Hoffmann
@ 2016-06-22  9:54     ` Dr. David Alan Gilbert
  2016-06-22 10:29       ` Gerd Hoffmann
  0 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert @ 2016-06-22  9:54 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, mst, amit.shah, quintela

* Gerd Hoffmann (kraxel@redhat.com) wrote:
> On Di, 2016-06-21 at 20:14 +0100, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > 
> > Forcibly convert it to a vmstate wrapper;  proper conversion
> > comes later.
> 
> FYI: Should be an easy target for proper conversion as virtio-input
> doesn't need to save any device-specific state beside the usual virtio
> and pci bits.

Thanks; what would a good test for virtio-input to be to make sure
migration works; got a recommended command line?

Dave

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

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

* Re: [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate
  2016-06-22  9:54     ` Dr. David Alan Gilbert
@ 2016-06-22 10:29       ` Gerd Hoffmann
  0 siblings, 0 replies; 41+ messages in thread
From: Gerd Hoffmann @ 2016-06-22 10:29 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel, mst, amit.shah, quintela

On Mi, 2016-06-22 at 10:54 +0100, Dr. David Alan Gilbert wrote:
> * Gerd Hoffmann (kraxel@redhat.com) wrote:
> > On Di, 2016-06-21 at 20:14 +0100, Dr. David Alan Gilbert (git) wrote:
> > > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > > 
> > > Forcibly convert it to a vmstate wrapper;  proper conversion
> > > comes later.
> > 
> > FYI: Should be an easy target for proper conversion as virtio-input
> > doesn't need to save any device-specific state beside the usual virtio
> > and pci bits.
> 
> Thanks; what would a good test for virtio-input to be to make sure
> migration works; got a recommended command line?

Drop "-device usb-tablet", add "-device virtio-tablet-pci" instead,
mouse input should continue to work just fine (assuming your guest
kernel is new enough).

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-22  8:39 ` Cornelia Huck
@ 2016-06-22 10:54   ` Dr. David Alan Gilbert
  2016-06-22 17:36     ` Cornelia Huck
  0 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert @ 2016-06-22 10:54 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

* Cornelia Huck (cornelia.huck@de.ibm.com) wrote:
> On Tue, 21 Jun 2016 20:13:54 +0100
> "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:
> 
> > 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).
> 
> These seem rather ancient and we would not care from a s390x
> perspective. Others may think differently, though...
> 
> > 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)
> 
> Real Soon Now :) Thank you for tackling virtio!

More tickling rather than tackling; plenty of scary bits left.

> > 
> > 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?
> 
> Do you have a git tree to test somewhere? I'll take a look at the
> patches later, but it would be good if we could give it a quick test on
> s390x as well.

I've just pushed it to:
  https://github.com/dagrh/qemu.git

  on the virtio-mig branch, tag dag-virtio-mig-20160622

Thanks.

Dave

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

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-22 10:54   ` Dr. David Alan Gilbert
@ 2016-06-22 17:36     ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-22 17:36 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Wed, 22 Jun 2016 11:54:21 +0100
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:

> I've just pushed it to:
>   https://github.com/dagrh/qemu.git
> 
>   on the virtio-mig branch, tag dag-virtio-mig-20160622

I did some managedsave/restore cycles via libvirt for the current 2.7
and the 2.4 (the oldest versioned) ccw machine. Nothing bad happened :)

(I don't have virtio-serial in my default config, though.)

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

* Re: [Qemu-devel] [PATCH 03/13] virtio: Migration helper function and macro
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 03/13] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
@ 2016-06-22 17:39   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-22 17:39 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:13:57 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  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 7ed06ea..7322018 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);
> +}
> +

Providing a macro that generates a .get function for a given version is
probably overkill.

>  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);
> 

Looks reasonable as a first step.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 04/13] virtio-scsi: Wrap in vmstate
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 04/13] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
@ 2016-06-22 17:40   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-22 17:40 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:13:58 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  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 71d09d3..6e518f4 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -663,7 +663,7 @@ 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);
>      VirtIOSCSI *s = VIRTIO_SCSI(vdev);
> @@ -674,16 +674,11 @@ static void virtio_scsi_save(QEMUFile *f, void *opaque)
>      virtio_save(vdev, f);
>  }

You'll be able to switch to the generic function once the patch
removing stopping dataplane has landed.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 05/13] virtio-blk: Wrap in vmstate
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 05/13] virtio-blk: " Dr. David Alan Gilbert (git)
@ 2016-06-22 17:42   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-22 17:42 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:13:59 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  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 284e646..8b93f9f 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -792,7 +792,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);
>      VirtIOBlock *s = VIRTIO_BLK(vdev);

Dito as for scsi, you'll be able to use the generic function as well.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 06/13] virtio-rng: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 06/13] virtio-rng: " Dr. David Alan Gilbert (git)
@ 2016-06-22 17:44   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-22 17:44 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:00 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  hw/virtio/virtio-rng.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 07/13] virtio-balloon: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 07/13] virtio-balloon: " Dr. David Alan Gilbert (git)
@ 2016-06-22 17:46   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-22 17:46 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:01 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  hw/virtio/virtio-balloon.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 08/13] virtio-net: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 08/13] virtio-net: " Dr. David Alan Gilbert (git)
@ 2016-06-23  7:39   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-23  7:39 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:02 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  hw/net/virtio-net.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 09/13] virtio-serial: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 09/13] virtio-serial: " Dr. David Alan Gilbert (git)
@ 2016-06-23  7:55   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-23  7:55 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:03 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  hw/char/virtio-serial-bus.c | 27 ++++++---------------------
>  1 file changed, 6 insertions(+), 21 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 10/13] 9pfs: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 10/13] 9pfs: " Dr. David Alan Gilbert (git)
@ 2016-06-23  8:01   ` Cornelia Huck
  2016-06-30  7:02   ` Greg Kurz
  1 sibling, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-23  8:01 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:04 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  hw/9pfs/virtio-9p-device.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 11/13] virtio-input: " Dr. David Alan Gilbert (git)
  2016-06-22  6:48   ` Gerd Hoffmann
@ 2016-06-23  8:07   ` Cornelia Huck
  1 sibling, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-23  8:07 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:05 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  hw/input/virtio-input.c | 26 ++++++--------------------
>  1 file changed, 6 insertions(+), 20 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 12/13] virtio-gpu: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
@ 2016-06-23  8:19   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-23  8:19 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:06 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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>
> ---
>  hw/display/virtio-gpu.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 13/13] virtio: Update migration docs
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 13/13] virtio: Update migration docs Dr. David Alan Gilbert (git)
@ 2016-06-23  8:23   ` Cornelia Huck
  0 siblings, 0 replies; 41+ messages in thread
From: Cornelia Huck @ 2016-06-23  8:23 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:07 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Remove references to register_savevm.
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  docs/virtio-migration.txt | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (14 preceding siblings ...)
  2016-06-22  8:39 ` Cornelia Huck
@ 2016-06-24  5:49 ` Michael S. Tsirkin
  2016-06-24  8:02   ` Dr. David Alan Gilbert
  2016-06-27  6:50 ` Amit Shah
  16 siblings, 1 reply; 41+ messages in thread
From: Michael S. Tsirkin @ 2016-06-24  5:49 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, amit.shah, quintela, kraxel

On Tue, Jun 21, 2016 at 08:13:54PM +0100, Dr. David Alan Gilbert (git) wrote:
> 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.

I'm ok with removing 0.11 migration compat code.
But doesn't the serial change break 0.12 as well?

> 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
> 
> 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] 41+ messages in thread

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-24  5:49 ` Michael S. Tsirkin
@ 2016-06-24  8:02   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 41+ messages in thread
From: Dr. David Alan Gilbert @ 2016-06-24  8:02 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel, amit.shah, quintela, kraxel

* Michael S. Tsirkin (mst@redhat.com) wrote:
> On Tue, Jun 21, 2016 at 08:13:54PM +0100, Dr. David Alan Gilbert (git) wrote:
> > 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.
> 
> I'm ok with removing 0.11 migration compat code.
> But doesn't the serial change break 0.12 as well?

Yes it does; but see my reply to Gerd; 0.12 migration seems to be broken
to modern versions anyway.

Dave

> 
> > 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
> > 
> > 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
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

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

* Re: [Qemu-devel] [PATCH 02/13] virtio-serial: Remove old migration version support
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 02/13] virtio-serial: " Dr. David Alan Gilbert (git)
@ 2016-06-27  6:45   ` Amit Shah
  0 siblings, 0 replies; 41+ messages in thread
From: Amit Shah @ 2016-06-27  6:45 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, quintela, kraxel

On (Tue) 21 Jun 2016 [20:13:56], Dr. David Alan Gilbert (git) wrote:
> 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>

		Amit

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

* Re: [Qemu-devel] [PATCH 01/13] virtio-net: Remove old migration version support
  2016-06-21 19:13 ` [Qemu-devel] [PATCH 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
@ 2016-06-27  6:46   ` Amit Shah
  0 siblings, 0 replies; 41+ messages in thread
From: Amit Shah @ 2016-06-27  6:46 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, quintela, kraxel

On (Tue) 21 Jun 2016 [20:13:55], Dr. David Alan Gilbert (git) wrote:
> 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>

		Amit

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
                   ` (15 preceding siblings ...)
  2016-06-24  5:49 ` Michael S. Tsirkin
@ 2016-06-27  6:50 ` Amit Shah
  2016-06-27  7:53   ` Dr. David Alan Gilbert
  16 siblings, 1 reply; 41+ messages in thread
From: Amit Shah @ 2016-06-27  6:50 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git)
  Cc: qemu-devel, mst, quintela, kraxel, Paolo Bonzini

On (Tue) 21 Jun 2016 [20:13:54], Dr. David Alan Gilbert (git) wrote:
> 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'm not sure how to go about this though - should we pick these
patches now, and keep taking smaller stabs at the problem; vs
maintaining a separate tree and see how the series grows and what
directions it takes.

> 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.

I think it's fine to remove these.  Distributions that depend on older
releases should take the burden of maintaining the older state.
However, as you say, it could be controversial, so let's wait for more
input from others.


		Amit

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-27  6:50 ` Amit Shah
@ 2016-06-27  7:53   ` Dr. David Alan Gilbert
  2016-06-28  9:04     ` Amit Shah
  0 siblings, 1 reply; 41+ messages in thread
From: Dr. David Alan Gilbert @ 2016-06-27  7:53 UTC (permalink / raw)
  To: Amit Shah; +Cc: qemu-devel, mst, quintela, kraxel, Paolo Bonzini

* Amit Shah (amit.shah@redhat.com) wrote:
> On (Tue) 21 Jun 2016 [20:13:54], Dr. David Alan Gilbert (git) wrote:
> > 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'm not sure how to go about this though - should we pick these
> patches now, and keep taking smaller stabs at the problem; vs
> maintaining a separate tree and see how the series grows and what
> directions it takes.

My intention was that this set would be taken as is and then we'd do some
more later.  Killing off register_savevm will probably take another
couple of dozen patches all over the place.  Turning all of virtio
into VMState will probably take a lot more.

> > 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.
> 
> I think it's fine to remove these.  Distributions that depend on older
> releases should take the burden of maintaining the older state.
> However, as you say, it could be controversial, so let's wait for more
> input from others.

Dave

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

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

* Re: [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate
  2016-06-27  7:53   ` Dr. David Alan Gilbert
@ 2016-06-28  9:04     ` Amit Shah
  0 siblings, 0 replies; 41+ messages in thread
From: Amit Shah @ 2016-06-28  9:04 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel, mst, quintela, kraxel, Paolo Bonzini

On (Mon) 27 Jun 2016 [08:53:47], Dr. David Alan Gilbert wrote:
> * Amit Shah (amit.shah@redhat.com) wrote:
> > On (Tue) 21 Jun 2016 [20:13:54], Dr. David Alan Gilbert (git) wrote:
> > > 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'm not sure how to go about this though - should we pick these
> > patches now, and keep taking smaller stabs at the problem; vs
> > maintaining a separate tree and see how the series grows and what
> > directions it takes.
> 
> My intention was that this set would be taken as is and then we'd do some
> more later.  Killing off register_savevm will probably take another
> couple of dozen patches all over the place.  Turning all of virtio
> into VMState will probably take a lot more.

OK - I don't think this set should be controversial, but I'll wait
this week to see if there are any comments; will send a pull req next
week if nothing pops up.

Thanks,

		Amit

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

* Re: [Qemu-devel] [PATCH 10/13] 9pfs: Wrap in vmstate
  2016-06-21 19:14 ` [Qemu-devel] [PATCH 10/13] 9pfs: " Dr. David Alan Gilbert (git)
  2016-06-23  8:01   ` Cornelia Huck
@ 2016-06-30  7:02   ` Greg Kurz
  1 sibling, 0 replies; 41+ messages in thread
From: Greg Kurz @ 2016-06-30  7:02 UTC (permalink / raw)
  To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel

On Tue, 21 Jun 2016 20:14:04 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:

> 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: 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;

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

end of thread, other threads:[~2016-06-30  7:02 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-21 19:13 [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
2016-06-21 19:13 ` [Qemu-devel] [PATCH 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
2016-06-27  6:46   ` Amit Shah
2016-06-21 19:13 ` [Qemu-devel] [PATCH 02/13] virtio-serial: " Dr. David Alan Gilbert (git)
2016-06-27  6:45   ` Amit Shah
2016-06-21 19:13 ` [Qemu-devel] [PATCH 03/13] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
2016-06-22 17:39   ` Cornelia Huck
2016-06-21 19:13 ` [Qemu-devel] [PATCH 04/13] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
2016-06-22 17:40   ` Cornelia Huck
2016-06-21 19:13 ` [Qemu-devel] [PATCH 05/13] virtio-blk: " Dr. David Alan Gilbert (git)
2016-06-22 17:42   ` Cornelia Huck
2016-06-21 19:14 ` [Qemu-devel] [PATCH 06/13] virtio-rng: " Dr. David Alan Gilbert (git)
2016-06-22 17:44   ` Cornelia Huck
2016-06-21 19:14 ` [Qemu-devel] [PATCH 07/13] virtio-balloon: " Dr. David Alan Gilbert (git)
2016-06-22 17:46   ` Cornelia Huck
2016-06-21 19:14 ` [Qemu-devel] [PATCH 08/13] virtio-net: " Dr. David Alan Gilbert (git)
2016-06-23  7:39   ` Cornelia Huck
2016-06-21 19:14 ` [Qemu-devel] [PATCH 09/13] virtio-serial: " Dr. David Alan Gilbert (git)
2016-06-23  7:55   ` Cornelia Huck
2016-06-21 19:14 ` [Qemu-devel] [PATCH 10/13] 9pfs: " Dr. David Alan Gilbert (git)
2016-06-23  8:01   ` Cornelia Huck
2016-06-30  7:02   ` Greg Kurz
2016-06-21 19:14 ` [Qemu-devel] [PATCH 11/13] virtio-input: " Dr. David Alan Gilbert (git)
2016-06-22  6:48   ` Gerd Hoffmann
2016-06-22  9:54     ` Dr. David Alan Gilbert
2016-06-22 10:29       ` Gerd Hoffmann
2016-06-23  8:07   ` Cornelia Huck
2016-06-21 19:14 ` [Qemu-devel] [PATCH 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
2016-06-23  8:19   ` Cornelia Huck
2016-06-21 19:14 ` [Qemu-devel] [PATCH 13/13] virtio: Update migration docs Dr. David Alan Gilbert (git)
2016-06-23  8:23   ` Cornelia Huck
2016-06-22  6:53 ` [Qemu-devel] [PATCH 00/13] virtio migration: Flip outer layer to vmstate Gerd Hoffmann
2016-06-22  9:50   ` Dr. David Alan Gilbert
2016-06-22  8:39 ` Cornelia Huck
2016-06-22 10:54   ` Dr. David Alan Gilbert
2016-06-22 17:36     ` Cornelia Huck
2016-06-24  5:49 ` Michael S. Tsirkin
2016-06-24  8:02   ` Dr. David Alan Gilbert
2016-06-27  6:50 ` Amit Shah
2016-06-27  7:53   ` Dr. David Alan Gilbert
2016-06-28  9:04     ` Amit Shah

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.