Skip to contentSkip to conversation

virtio migration: Flip outer layer to vmstate

PATCH Superseded Dr. David Alan Gilbert (git) 6 participants 41 messages Jun 21, 2016 – Jun 30, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover virtio migration: Flip outer layer to vmstate

From: "Dr. David Alan Gilbert" <[email protected]>

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(-)
Signature · 1 line
2.7.4
#5 lore raw

PATCH 3/13 virtio: Migration helper function and macro

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---
 hw/virtio/virtio.c         |  6 ++++++
 include/hw/virtio/virtio.h | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+)
hw/virtio/virtio.c +6 -0
index 7ed06ea..7322018 100644
@@ -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);
include/hw/virtio/virtio.h +20 -0
index 96b581d..b6887e7 100644
@@ -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);
 
Signature · 1 line
2.7.4
#7 lore raw

PATCH 4/13 virtio-scsi: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/scsi/virtio-scsi.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
hw/scsi/virtio-scsi.c +6 -15
index 71d09d3..6e518f4 100644
@@ -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;
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/13 virtio-net: Remove old migration version support

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/net/virtio-net.c | 87 +++++++++++++++++++++--------------------------------
 1 file changed, 34 insertions(+), 53 deletions(-)
hw/net/virtio-net.c +34 -53
index 5798f87..1fae1ee 100644
@@ -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) {
Signature · 1 line
2.7.4
#9 lore raw

PATCH 5/13 virtio-blk: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/block/virtio-blk.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
hw/block/virtio-blk.c +6 -10
index 284e646..8b93f9f 100644
@@ -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;
Signature · 1 line
2.7.4
#15 lore raw

PATCH 8/13 virtio-net: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/net/virtio-net.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
hw/net/virtio-net.c +7 -10
index 1fae1ee..b369fa4 100644
@@ -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;
Signature · 1 line
2.7.4
#3 lore raw

PATCH 2/13 virtio-serial: Remove old migration version support

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/char/virtio-serial-bus.c | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)
hw/char/virtio-serial-bus.c +15 -22
index 6e5de6d..490b5ea 100644
@@ -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;
         }
Signature · 1 line
2.7.4
#11 lore raw

PATCH 6/13 virtio-rng: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/virtio/virtio-rng.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)
hw/virtio/virtio-rng.c +5 -15
index 6b991a7..cd8ca10 100644
@@ -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;
Signature · 1 line
2.7.4
#17 lore raw

PATCH 9/13 virtio-serial: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/char/virtio-serial-bus.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)
hw/char/virtio-serial-bus.c +6 -21
index 490b5ea..db57a38 100644
@@ -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;
Signature · 1 line
2.7.4
#19 lore raw

PATCH 10/13 9pfs: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/9pfs/virtio-9p-device.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
hw/9pfs/virtio-9p-device.c +5 -9
index 494e85e..009b43f 100644
@@ -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;
Signature · 1 line
2.7.4
#13 lore raw

PATCH 7/13 virtio-balloon: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/virtio/virtio-balloon.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
hw/virtio/virtio-balloon.c +5 -14
index 557d3f9..22894f3 100644
@@ -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;
Signature · 1 line
2.7.4
#22 lore raw

PATCH 11/13 virtio-input: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/input/virtio-input.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)
hw/input/virtio-input.c +6 -20
index f59749a..848090f 100644
@@ -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;
Signature · 1 line
2.7.4
#27 lore raw

PATCH 12/13 virtio-gpu: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/display/virtio-gpu.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
hw/display/virtio-gpu.c +7 -10
index 136c095..52f2e7c 100644
@@ -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 = {
Signature · 1 line
2.7.4
#29 lore raw

PATCH 13/13 virtio: Update migration docs

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Remove references to register_savevm.

---
 docs/virtio-migration.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
docs/virtio-migration.txt +4 -2
index cf66458..98a6b0f 100644
@@ -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
Signature · 1 line
2.7.4
#23 lore raw

Re: [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

#31 lore raw
In reply to Dr. David Alan Gilbert (git)

Hi,

Quoted 6 lines

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

#33 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 11 lines · On Tue, 21 Jun 2016 20:13:54 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

Quoted 11 lines

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.

Quoted 2 lines

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!

Quoted 5 lines

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.

#32 lore raw
In reply to Gerd Hoffmann
Quoted 9 lines · * Gerd Hoffmann ([email protected]) wrote:

Hi,

Quoted 6 lines

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.

Quoted 4 lines

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

Quoted 3 lines

cheers,
Gerd

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#24 lore raw

Re: [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate

In reply to Gerd Hoffmann
Quoted 9 lines · * Gerd Hoffmann ([email protected]) wrote:
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

Quoted 4 lines

cheers,
Gerd

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#25 lore raw

Re: [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate

Quoted 7 lines · Dr. David Alan Gilbert
Quoted 6 lines · * Gerd Hoffmann ([email protected]) wrote:
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

Quoted 6 lines
Quoted 3 lines

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

#34 lore raw
In reply to Cornelia Huck
Quoted 29 lines · * Cornelia Huck ([email protected]) wrote:
Quoted 11 lines · On Tue, 21 Jun 2016 20:13:54 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

Quoted 11 lines

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.

Quoted 4 lines
Quoted 2 lines

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.

Quoted 9 lines
Quoted 5 lines

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

Quoted 1 line

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#35 lore raw
Quoted 4 lines · On Wed, 22 Jun 2016 11:54:21 +0100 "Dr. David Alan Gilbert"…

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

Reviewed-by on v1 3/13
#6 lore raw

Re: [Qemu-devel] [PATCH 03/13] virtio: Migration helper function and macro

In reply to Dr. David Alan Gilbert (git)
Quoted 19 lines · On Tue, 21 Jun 2016 20:13:57 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---
 hw/virtio/virtio.c         |  6 ++++++
 include/hw/virtio/virtio.h | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+)
hw/virtio/virtio.c +0 -0
index 7ed06ea..7322018 100644

hw/virtio/virtio.c void virtio_save(VirtIODevice *vdev, QEMUFile *f) · line 1452

Quoted 9 lines
hw/virtio/virtio.c +6 -0
@@ -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.

Quoted 24 lines
hw/virtio/virtio.c +0 -0
 static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val)
 {
     VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
include/hw/virtio/virtio.h +13 -0
index 96b581d..b6887e7 100644
@@ -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,          \

include/hw/virtio/virtio.h bool virtio_should_notify(VirtIODevice *vdev, VirtQueue *vq); · line 192

Quoted 10 lines
include/hw/virtio/virtio.h +7 -0
+                        .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 on v1 4/13
#8 lore raw

Re: [Qemu-devel] [PATCH 04/13] virtio-scsi: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 24 lines · On Tue, 21 Jun 2016 20:13:58 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/scsi/virtio-scsi.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
hw/scsi/virtio-scsi.c +1 -1
index 71d09d3..6e518f4 100644
@@ -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);

hw/scsi/virtio-scsi.c static void virtio_scsi_save(QEMUFile *f, void *opaque) · line 675

Quoted 2 lines
hw/scsi/virtio-scsi.c +0 -0
@@ -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 on v1 5/13
#10 lore raw

Re: [Qemu-devel] [PATCH 05/13] virtio-blk: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 15 lines · On Tue, 21 Jun 2016 20:13:59 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/block/virtio-blk.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
hw/block/virtio-blk.c +0 -0
index 284e646..8b93f9f 100644

hw/block/virtio-blk.c static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) · line 798

Quoted 8 lines
hw/block/virtio-blk.c +1 -1
@@ -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 on v1 6/13
#12 lore raw

Re: [Qemu-devel] [PATCH 06/13] virtio-rng: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 9 lines · On Tue, 21 Jun 2016 20:14:00 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/virtio/virtio-rng.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)
Reviewed-by on v1 7/13
#14 lore raw

Re: [Qemu-devel] [PATCH 07/13] virtio-balloon: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 9 lines · On Tue, 21 Jun 2016 20:14:01 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/virtio/virtio-balloon.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
Reviewed-by on v1 8/13
#16 lore raw

Re: [Qemu-devel] [PATCH 08/13] virtio-net: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 9 lines · On Tue, 21 Jun 2016 20:14:02 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/net/virtio-net.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
Reviewed-by on v1 9/13
#18 lore raw

Re: [Qemu-devel] [PATCH 09/13] virtio-serial: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 9 lines · On Tue, 21 Jun 2016 20:14:03 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/char/virtio-serial-bus.c | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)
Reviewed-by on v1 10/13
#20 lore raw

Re: [Qemu-devel] [PATCH 10/13] 9pfs: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 9 lines · On Tue, 21 Jun 2016 20:14:04 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/9pfs/virtio-9p-device.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
Reviewed-by on v1 11/13
#26 lore raw

Re: [Qemu-devel] [PATCH 11/13] virtio-input: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 9 lines · On Tue, 21 Jun 2016 20:14:05 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/input/virtio-input.c | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)
Reviewed-by on v1 12/13
#28 lore raw

Re: [Qemu-devel] [PATCH 12/13] virtio-gpu: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 9 lines · On Tue, 21 Jun 2016 20:14:06 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hw/display/virtio-gpu.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
Reviewed-by on v1 13/13
#30 lore raw

Re: [Qemu-devel] [PATCH 13/13] virtio: Update migration docs

In reply to Dr. David Alan Gilbert (git)
Quoted 8 lines · On Tue, 21 Jun 2016 20:14:07 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

Remove references to register_savevm.

---
 docs/virtio-migration.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
#36 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 8 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

Quoted 6 lines

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?

Quoted 48 lines

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(-)
Signature · 1 line
2.7.4
#37 lore raw
Quoted 16 lines · * Michael S. Tsirkin ([email protected]) wrote:
Quoted 8 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

Quoted 6 lines

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.

Quoted 2 lines

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

Quoted 47 lines
Quoted 47 lines

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(-)
Quoted 2 lines
Quoted 2 lines
Signature · 1 line
2.7.4

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Reviewed-by on v1 1/13
#2 lore raw

Re: [Qemu-devel] [PATCH 01/13] virtio-net: Remove old migration version support

In reply to Dr. David Alan Gilbert (git)
Quoted 7 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

Amit

#38 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 7 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

Quoted 6 lines

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

#39 lore raw
Quoted 9 lines · * Amit Shah ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

Quoted 4 lines

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.

Quoted 11 lines
Quoted 6 lines

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

Quoted 3 lines

Amit

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#40 lore raw
Quoted 15 lines · Dr. David Alan Gilbert
Quoted 9 lines · * Amit Shah ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

Quoted 4 lines

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.

Quoted 4 lines

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

Reviewed-by on v1 10/13
#21 lore raw

Re: [Qemu-devel] [PATCH 10/13] 9pfs: Wrap in vmstate

In reply to Dr. David Alan Gilbert (git)
Quoted 7 lines · On Tue, 21 Jun 2016 20:14:04 +0100 "Dr. David Alan Gilbert (git)"…

From: "Dr. David Alan Gilbert" <[email protected]>

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

---

Quoted 57 lines
 hw/9pfs/virtio-9p-device.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
hw/9pfs/virtio-9p-device.c +5 -9
index 494e85e..009b43f 100644
@@ -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;