* [Qemu-devel] [PATCH v3 01/14] virtio-net: Remove old migration version support
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 02/14] virtio-serial: " Dr. David Alan Gilbert (git)
` (13 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
virtio-net has had version 11 since 0ce0e8f4 in 2009
(v0.11.0-rc0-1480-g0ce0e8f) - remove the code to support loading
anything earlier.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
---
hw/net/virtio-net.c | 87 +++++++++++++++++++++--------------------------------
1 file changed, 34 insertions(+), 53 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9999899..550db30 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1543,7 +1543,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
VirtIONet *n = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(n);
- if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
+ if (version_id != VIRTIO_NET_VM_VERSION)
return -EINVAL;
return virtio_load(vdev, f, version_id);
@@ -1562,68 +1562,49 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
virtio_vdev_has_feature(vdev,
VIRTIO_F_VERSION_1));
- if (version_id >= 3)
- n->status = qemu_get_be16(f);
+ n->status = qemu_get_be16(f);
- if (version_id >= 4) {
- if (version_id < 8) {
- n->promisc = qemu_get_be32(f);
- n->allmulti = qemu_get_be32(f);
- } else {
- n->promisc = qemu_get_byte(f);
- n->allmulti = qemu_get_byte(f);
- }
- }
+ n->promisc = qemu_get_byte(f);
+ n->allmulti = qemu_get_byte(f);
- if (version_id >= 5) {
- n->mac_table.in_use = qemu_get_be32(f);
- /* MAC_TABLE_ENTRIES may be different from the saved image */
- if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {
- qemu_get_buffer(f, n->mac_table.macs,
- n->mac_table.in_use * ETH_ALEN);
- } else {
- int64_t i;
-
- /* Overflow detected - can happen if source has a larger MAC table.
- * We simply set overflow flag so there's no need to maintain the
- * table of addresses, discard them all.
- * Note: 64 bit math to avoid integer overflow.
- */
- for (i = 0; i < (int64_t)n->mac_table.in_use * ETH_ALEN; ++i) {
- qemu_get_byte(f);
- }
- n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1;
- n->mac_table.in_use = 0;
+ n->mac_table.in_use = qemu_get_be32(f);
+ /* MAC_TABLE_ENTRIES may be different from the saved image */
+ if (n->mac_table.in_use <= MAC_TABLE_ENTRIES) {
+ qemu_get_buffer(f, n->mac_table.macs,
+ n->mac_table.in_use * ETH_ALEN);
+ } else {
+ int64_t i;
+
+ /* Overflow detected - can happen if source has a larger MAC table.
+ * We simply set overflow flag so there's no need to maintain the
+ * table of addresses, discard them all.
+ * Note: 64 bit math to avoid integer overflow.
+ */
+ for (i = 0; i < (int64_t)n->mac_table.in_use * ETH_ALEN; ++i) {
+ qemu_get_byte(f);
}
+ n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1;
+ n->mac_table.in_use = 0;
}
- if (version_id >= 6)
- qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);
+ qemu_get_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);
- if (version_id >= 7) {
- if (qemu_get_be32(f) && !peer_has_vnet_hdr(n)) {
- error_report("virtio-net: saved image requires vnet_hdr=on");
- return -1;
- }
+ if (qemu_get_be32(f) && !peer_has_vnet_hdr(n)) {
+ error_report("virtio-net: saved image requires vnet_hdr=on");
+ return -1;
}
- if (version_id >= 9) {
- n->mac_table.multi_overflow = qemu_get_byte(f);
- n->mac_table.uni_overflow = qemu_get_byte(f);
- }
+ n->mac_table.multi_overflow = qemu_get_byte(f);
+ n->mac_table.uni_overflow = qemu_get_byte(f);
- if (version_id >= 10) {
- n->alluni = qemu_get_byte(f);
- n->nomulti = qemu_get_byte(f);
- n->nouni = qemu_get_byte(f);
- n->nobcast = qemu_get_byte(f);
- }
+ n->alluni = qemu_get_byte(f);
+ n->nomulti = qemu_get_byte(f);
+ n->nouni = qemu_get_byte(f);
+ n->nobcast = qemu_get_byte(f);
- if (version_id >= 11) {
- if (qemu_get_byte(f) && !peer_has_ufo(n)) {
- error_report("virtio-net: saved image requires TUN_F_UFO support");
- return -1;
- }
+ if (qemu_get_byte(f) && !peer_has_ufo(n)) {
+ error_report("virtio-net: saved image requires TUN_F_UFO support");
+ return -1;
}
if (n->max_queues > 1) {
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 02/14] virtio-serial: Remove old migration version support
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 01/14] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 03/14] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
` (12 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
virtio-serial-bus has had version 3 since 37f95bf3d0 in 0.13-rc0;
it's time to clean it up a bit.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
---
hw/char/virtio-serial-bus.c | 37 +++++++++++++++----------------------
1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 6e5de6d..490b5ea 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -685,7 +685,7 @@ static void virtio_serial_post_load_timer_cb(void *opaque)
s->post_load = NULL;
}
-static int fetch_active_ports_list(QEMUFile *f, int version_id,
+static int fetch_active_ports_list(QEMUFile *f,
VirtIOSerial *s, uint32_t nr_active_ports)
{
uint32_t i;
@@ -702,6 +702,7 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
/* Items in struct VirtIOSerialPort */
for (i = 0; i < nr_active_ports; i++) {
VirtIOSerialPort *port;
+ uint32_t elem_popped;
uint32_t id;
id = qemu_get_be32(f);
@@ -714,23 +715,19 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
s->post_load->connected[i].port = port;
s->post_load->connected[i].host_connected = qemu_get_byte(f);
- if (version_id > 2) {
- uint32_t elem_popped;
-
- qemu_get_be32s(f, &elem_popped);
- if (elem_popped) {
- qemu_get_be32s(f, &port->iov_idx);
- qemu_get_be64s(f, &port->iov_offset);
+ qemu_get_be32s(f, &elem_popped);
+ if (elem_popped) {
+ qemu_get_be32s(f, &port->iov_idx);
+ qemu_get_be64s(f, &port->iov_offset);
- port->elem =
- qemu_get_virtqueue_element(f, sizeof(VirtQueueElement));
+ port->elem =
+ qemu_get_virtqueue_element(f, sizeof(VirtQueueElement));
- /*
- * Port was throttled on source machine. Let's
- * unthrottle it here so data starts flowing again.
- */
- virtio_serial_throttle_port(port, false);
- }
+ /*
+ * Port was throttled on source machine. Let's
+ * unthrottle it here so data starts flowing again.
+ */
+ virtio_serial_throttle_port(port, false);
}
}
timer_mod(s->post_load->timer, 1);
@@ -739,7 +736,7 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id,
static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
{
- if (version_id > 3) {
+ if (version_id != 3) {
return -EINVAL;
}
@@ -756,10 +753,6 @@ static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f,
int ret;
uint32_t tmp;
- if (version_id < 2) {
- return 0;
- }
-
/* Unused */
qemu_get_be16s(f, (uint16_t *) &tmp);
qemu_get_be16s(f, (uint16_t *) &tmp);
@@ -781,7 +774,7 @@ static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f,
qemu_get_be32s(f, &nr_active_ports);
if (nr_active_ports) {
- ret = fetch_active_ports_list(f, version_id, s, nr_active_ports);
+ ret = fetch_active_ports_list(f, s, nr_active_ports);
if (ret) {
return ret;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 03/14] virtio: Migration helper function and macro
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 01/14] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 02/14] virtio-serial: " Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 04/14] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
` (11 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To make conversion of virtio devices to VMState simple
at first add a helper function for the simple virtio_save
case and a helper macro that defines the VMState structure.
These will probably go away or change as more of the virtio
code gets converted.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/virtio/virtio.c | 6 ++++++
include/hw/virtio/virtio.h | 20 ++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 18153d5..3e441a6 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1444,6 +1444,12 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
vmstate_save_state(f, &vmstate_virtio, vdev, NULL);
}
+/* A wrapper for use as a VMState .put function */
+void virtio_vmstate_save(QEMUFile *f, void *opaque, size_t size)
+{
+ virtio_save(VIRTIO_DEVICE(opaque), f);
+}
+
static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 8a681f5..5ad4cc1 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] 21+ messages in thread
* [Qemu-devel] [PATCH v3 04/14] virtio-scsi: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (2 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 03/14] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 05/14] virtio-blk: " Dr. David Alan Gilbert (git)
` (10 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/scsi/virtio-scsi.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 722c93e..ebbd0ae 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -663,22 +663,17 @@ static void virtio_scsi_reset(VirtIODevice *vdev)
/* The device does not have anything to save beyond the virtio data.
* Request data is saved with callbacks from SCSI devices.
*/
-static void virtio_scsi_save(QEMUFile *f, void *opaque)
+static void virtio_scsi_save(QEMUFile *f, void *opaque, size_t size)
{
VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
virtio_save(vdev, f);
}
-static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_scsi_load(QEMUFile *f, void *opaque, size_t size)
{
VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
- int ret;
- ret = virtio_load(vdev, f, version_id);
- if (ret) {
- return ret;
- }
- return 0;
+ return virtio_load(vdev, f, 1);
}
void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
@@ -864,7 +859,6 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSCSI *s = VIRTIO_SCSI(dev);
- static int virtio_scsi_id;
Error *err = NULL;
virtio_scsi_common_realize(dev, &err, virtio_scsi_handle_ctrl,
@@ -887,9 +881,6 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
return;
}
}
-
- register_savevm(dev, "virtio-scsi", virtio_scsi_id++, 1,
- virtio_scsi_save, virtio_scsi_load, s);
}
static void virtio_scsi_instance_init(Object *obj)
@@ -913,9 +904,6 @@ void virtio_scsi_common_unrealize(DeviceState *dev, Error **errp)
static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp)
{
- VirtIOSCSI *s = VIRTIO_SCSI(dev);
-
- unregister_savevm(dev, "virtio-scsi", s);
virtio_scsi_common_unrealize(dev, errp);
}
@@ -932,6 +920,8 @@ static Property virtio_scsi_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
+VMSTATE_VIRTIO_DEVICE(scsi, 1, virtio_scsi_load, virtio_scsi_save);
+
static void virtio_scsi_common_class_init(ObjectClass *klass, void *data)
{
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
@@ -948,6 +938,7 @@ static void virtio_scsi_class_init(ObjectClass *klass, void *data)
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
dc->props = virtio_scsi_properties;
+ dc->vmsd = &vmstate_virtio_scsi;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->realize = virtio_scsi_device_realize;
vdc->unrealize = virtio_scsi_device_unrealize;
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 05/14] virtio-blk: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (3 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 04/14] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 06/14] virtio-rng: " Dr. David Alan Gilbert (git)
` (9 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/block/virtio-blk.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 357ff90..5916594 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -798,7 +798,7 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
}
}
-static void virtio_blk_save(QEMUFile *f, void *opaque)
+static void virtio_blk_save(QEMUFile *f, void *opaque, size_t size)
{
VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
@@ -823,15 +823,12 @@ static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)
qemu_put_sbyte(f, 0);
}
-static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_blk_load(QEMUFile *f, void *opaque, size_t size)
{
VirtIOBlock *s = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(s);
- if (version_id != 2)
- return -EINVAL;
-
- return virtio_load(vdev, f, version_id);
+ return virtio_load(vdev, f, 2);
}
static int virtio_blk_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -880,7 +877,6 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
VirtIOBlock *s = VIRTIO_BLK(dev);
VirtIOBlkConf *conf = &s->conf;
Error *err = NULL;
- static int virtio_blk_id;
unsigned i;
if (!conf->conf.blk) {
@@ -924,8 +920,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);
@@ -940,7 +934,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);
}
@@ -958,6 +951,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_ERROR_PROPERTIES(VirtIOBlock, conf.conf),
@@ -979,6 +974,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] 21+ messages in thread
* [Qemu-devel] [PATCH v3 06/14] virtio-rng: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (4 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 05/14] virtio-blk: " Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 07/14] virtio-balloon: " Dr. David Alan Gilbert (git)
` (8 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/virtio/virtio-rng.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 6b991a7..cd8ca10 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -120,22 +120,12 @@ static uint64_t get_features(VirtIODevice *vdev, uint64_t f, Error **errp)
return f;
}
-static void virtio_rng_save(QEMUFile *f, void *opaque)
-{
- VirtIODevice *vdev = opaque;
-
- virtio_save(vdev, f);
-}
-
-static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_rng_load(QEMUFile *f, void *opaque, size_t size)
{
VirtIORNG *vrng = opaque;
int ret;
- if (version_id != 1) {
- return -EINVAL;
- }
- ret = virtio_load(VIRTIO_DEVICE(vrng), f, version_id);
+ ret = virtio_load(VIRTIO_DEVICE(vrng), f, 1);
if (ret != 0) {
return ret;
}
@@ -214,8 +204,6 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
vrng->rate_limit_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL,
check_rate_limit, vrng);
vrng->activate_timer = true;
- register_savevm(dev, "virtio-rng", -1, 1, virtio_rng_save,
- virtio_rng_load, vrng);
}
static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp)
@@ -225,10 +213,11 @@ static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp)
timer_del(vrng->rate_limit_timer);
timer_free(vrng->rate_limit_timer);
- unregister_savevm(dev, "virtio-rng", vrng);
virtio_cleanup(vdev);
}
+VMSTATE_VIRTIO_DEVICE(rng, 1, virtio_rng_load, virtio_vmstate_save);
+
static Property virtio_rng_properties[] = {
/* Set a default rate limit of 2^47 bytes per minute or roughly 2TB/s. If
* you have an entropy source capable of generating more entropy than this
@@ -246,6 +235,7 @@ static void virtio_rng_class_init(ObjectClass *klass, void *data)
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->props = virtio_rng_properties;
+ dc->vmsd = &vmstate_virtio_rng;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
vdc->realize = virtio_rng_device_realize;
vdc->unrealize = virtio_rng_device_unrealize;
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 07/14] virtio-balloon: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (5 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 06/14] virtio-rng: " Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 08/14] virtio-net: " Dr. David Alan Gilbert (git)
` (7 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/virtio/virtio-balloon.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 1a22e6d..5af429a 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -396,11 +396,6 @@ static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
trace_virtio_balloon_to_target(target, dev->num_pages);
}
-static void virtio_balloon_save(QEMUFile *f, void *opaque)
-{
- virtio_save(VIRTIO_DEVICE(opaque), f);
-}
-
static void virtio_balloon_save_device(VirtIODevice *vdev, QEMUFile *f)
{
VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
@@ -409,12 +404,9 @@ static void virtio_balloon_save_device(VirtIODevice *vdev, QEMUFile *f)
qemu_put_be32(f, s->actual);
}
-static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_balloon_load(QEMUFile *f, void *opaque, size_t size)
{
- if (version_id != 1)
- return -EINVAL;
-
- return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);
+ return virtio_load(VIRTIO_DEVICE(opaque), f, 1);
}
static int virtio_balloon_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -454,9 +446,6 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
reset_stats(s);
-
- register_savevm(dev, "virtio-balloon", -1, 1,
- virtio_balloon_save, virtio_balloon_load, s);
}
static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp)
@@ -466,7 +455,6 @@ static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp)
balloon_stats_destroy_timer(s);
qemu_remove_balloon_handler(s);
- unregister_savevm(dev, "virtio-balloon", s);
virtio_cleanup(vdev);
}
@@ -493,6 +481,8 @@ static void virtio_balloon_instance_init(Object *obj)
NULL, s, NULL);
}
+VMSTATE_VIRTIO_DEVICE(balloon, 1, virtio_balloon_load, virtio_vmstate_save);
+
static Property virtio_balloon_properties[] = {
DEFINE_PROP_BIT("deflate-on-oom", VirtIOBalloon, host_features,
VIRTIO_BALLOON_F_DEFLATE_ON_OOM, false),
@@ -505,6 +495,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->props = virtio_balloon_properties;
+ dc->vmsd = &vmstate_virtio_balloon;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
vdc->realize = virtio_balloon_device_realize;
vdc->unrealize = virtio_balloon_device_unrealize;
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 08/14] virtio-net: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (6 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 07/14] virtio-balloon: " Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 09/14] virtio-serial: " Dr. David Alan Gilbert (git)
` (6 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/net/virtio-net.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 550db30..bb311c4 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1492,7 +1492,7 @@ static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)
virtio_net_set_queues(n);
}
-static void virtio_net_save(QEMUFile *f, void *opaque)
+static void virtio_net_save(QEMUFile *f, void *opaque, size_t size)
{
VirtIONet *n = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(n);
@@ -1538,15 +1538,12 @@ static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f)
}
}
-static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_net_load(QEMUFile *f, void *opaque, size_t size)
{
VirtIONet *n = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(n);
- if (version_id != VIRTIO_NET_VM_VERSION)
- return -EINVAL;
-
- return virtio_load(vdev, f, version_id);
+ return virtio_load(vdev, f, VIRTIO_NET_VM_VERSION);
}
static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -1790,8 +1787,6 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
nc->rxfilter_notify_enabled = 1;
n->qdev = dev;
- register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
- virtio_net_save, virtio_net_load, n);
}
static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
@@ -1803,8 +1798,6 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
/* This will stop vhost backend if appropriate. */
virtio_net_set_status(vdev, 0);
- unregister_savevm(dev, "virtio-net", n);
-
g_free(n->netclient_name);
n->netclient_name = NULL;
g_free(n->netclient_type);
@@ -1839,6 +1832,9 @@ static void virtio_net_instance_init(Object *obj)
DEVICE(n), NULL);
}
+VMSTATE_VIRTIO_DEVICE(net, VIRTIO_NET_VM_VERSION, virtio_net_load,
+ virtio_net_save);
+
static Property virtio_net_properties[] = {
DEFINE_PROP_BIT("csum", VirtIONet, host_features, VIRTIO_NET_F_CSUM, true),
DEFINE_PROP_BIT("guest_csum", VirtIONet, host_features,
@@ -1893,6 +1889,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data)
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->props = virtio_net_properties;
+ dc->vmsd = &vmstate_virtio_net;
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
vdc->realize = virtio_net_device_realize;
vdc->unrealize = virtio_net_device_unrealize;
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 09/14] virtio-serial: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (7 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 08/14] virtio-net: " Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 10/14] 9pfs: " Dr. David Alan Gilbert (git)
` (5 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/char/virtio-serial-bus.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 490b5ea..db57a38 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -594,12 +594,6 @@ static void vser_reset(VirtIODevice *vdev)
guest_reset(vser);
}
-static void virtio_serial_save(QEMUFile *f, void *opaque)
-{
- /* The virtio device */
- virtio_save(VIRTIO_DEVICE(opaque), f);
-}
-
static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f)
{
VirtIOSerial *s = VIRTIO_SERIAL(vdev);
@@ -734,14 +728,10 @@ static int fetch_active_ports_list(QEMUFile *f,
return 0;
}
-static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_serial_load(QEMUFile *f, void *opaque, size_t size)
{
- if (version_id != 3) {
- return -EINVAL;
- }
-
/* The virtio device */
- return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);
+ return virtio_load(VIRTIO_DEVICE(opaque), f, 3);
}
static int virtio_serial_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -1042,13 +1032,6 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp)
vser->post_load = NULL;
- /*
- * Register for the savevm section with the virtio-console name
- * to preserve backward compat
- */
- register_savevm(dev, "virtio-console", -1, 3, virtio_serial_save,
- virtio_serial_load, vser);
-
QLIST_INSERT_HEAD(&vserdevices.devices, vser, next);
}
@@ -1079,8 +1062,6 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
QLIST_REMOVE(vser, next);
- unregister_savevm(dev, "virtio-console", vser);
-
g_free(vser->ivqs);
g_free(vser->ovqs);
g_free(vser->ports_map);
@@ -1093,6 +1074,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
virtio_cleanup(vdev);
}
+/* Note: 'console' is used for backwards compatibility */
+VMSTATE_VIRTIO_DEVICE(console, 3, virtio_serial_load, virtio_vmstate_save);
+
static Property virtio_serial_properties[] = {
DEFINE_PROP_UINT32("max_ports", VirtIOSerial, serial.max_virtserial_ports,
31),
@@ -1108,6 +1092,7 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data)
QLIST_INIT(&vserdevices.devices);
dc->props = virtio_serial_properties;
+ dc->vmsd = &vmstate_virtio_console;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
vdc->realize = virtio_serial_device_realize;
vdc->unrealize = virtio_serial_device_unrealize;
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 10/14] 9pfs: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (8 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 09/14] virtio-serial: " Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 11/14] virtio-input: " Dr. David Alan Gilbert (git)
` (4 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
---
hw/9pfs/virtio-9p-device.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 494e85e..009b43f 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -97,14 +97,9 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
g_free(cfg);
}
-static void virtio_9p_save(QEMUFile *f, void *opaque)
+static int virtio_9p_load(QEMUFile *f, void *opaque, size_t size)
{
- virtio_save(VIRTIO_DEVICE(opaque), f);
-}
-
-static int virtio_9p_load(QEMUFile *f, void *opaque, int version_id)
-{
- return virtio_load(VIRTIO_DEVICE(opaque), f, version_id);
+ return virtio_load(VIRTIO_DEVICE(opaque), f, 1);
}
static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
@@ -120,7 +115,6 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
v->config_size = sizeof(struct virtio_9p_config) + strlen(s->fsconf.tag);
virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size);
v->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output);
- register_savevm(dev, "virtio-9p", -1, 1, virtio_9p_save, virtio_9p_load, v);
out:
return;
@@ -133,7 +127,6 @@ static void virtio_9p_device_unrealize(DeviceState *dev, Error **errp)
V9fsState *s = &v->state;
virtio_cleanup(vdev);
- unregister_savevm(dev, "virtio-9p", v);
v9fs_device_unrealize_common(s, errp);
}
@@ -175,6 +168,8 @@ void virtio_init_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
/* virtio-9p device */
+VMSTATE_VIRTIO_DEVICE(9p, 1, virtio_9p_load, virtio_vmstate_save);
+
static Property virtio_9p_properties[] = {
DEFINE_PROP_STRING("mount_tag", V9fsVirtioState, state.fsconf.tag),
DEFINE_PROP_STRING("fsdev", V9fsVirtioState, state.fsconf.fsdev_id),
@@ -187,6 +182,7 @@ static void virtio_9p_class_init(ObjectClass *klass, void *data)
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->props = virtio_9p_properties;
+ dc->vmsd = &vmstate_virtio_9p;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->realize = virtio_9p_device_realize;
vdc->unrealize = virtio_9p_device_unrealize;
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 11/14] virtio-input: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (9 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 10/14] 9pfs: " Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-15 9:56 ` Gerd Hoffmann
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 12/14] virtio-gpu: Use migrate_add_blocker for virgl migration blocking Dr. David Alan Gilbert (git)
` (3 subsequent siblings)
14 siblings, 1 reply; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/input/virtio-input.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index edf6990..a87fd68 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -217,26 +217,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;
}
@@ -280,20 +268,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) {
@@ -304,6 +286,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(),
@@ -315,6 +300,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] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v3 11/14] virtio-input: Wrap in vmstate
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 11/14] virtio-input: " Dr. David Alan Gilbert (git)
@ 2016-07-15 9:56 ` Gerd Hoffmann
0 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2016-07-15 9:56 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git)
Cc: qemu-devel, mst, amit.shah, quintela, cornelia.huck
On Do, 2016-07-14 at 18:22 +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.
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 12/14] virtio-gpu: Use migrate_add_blocker for virgl migration blocking
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (10 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 11/14] virtio-input: " Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-15 8:21 ` Cornelia Huck
2016-07-15 9:57 ` Gerd Hoffmann
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 13/14] virtio-gpu: Wrap in vmstate Dr. David Alan Gilbert (git)
` (2 subsequent siblings)
14 siblings, 2 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
virgl conditionally registers a vmstate as unmigratable when virgl
is enabled; instead use the migrate_add_blocker mechanism.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
hw/display/virtio-gpu.c | 19 +++++++++++++------
include/hw/virtio/virtio-gpu.h | 2 ++
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 929c3c8..cc87eb7 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -19,6 +19,7 @@
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-gpu.h"
#include "hw/virtio/virtio-bus.h"
+#include "migration/migration.h"
#include "qemu/log.h"
#include "qapi/error.h"
@@ -986,11 +987,6 @@ static const VMStateDescription vmstate_virtio_gpu_scanouts = {
},
};
-static const VMStateDescription vmstate_virtio_gpu_unmigratable = {
- .name = "virtio-gpu-with-virgl",
- .unmigratable = 1,
-};
-
static void virtio_gpu_save(QEMUFile *f, void *opaque)
{
VirtIOGPU *g = opaque;
@@ -1169,13 +1165,23 @@ 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);
+ error_setg(&g->migration_blocker, "virgl is not yet migratable");
+ migrate_add_blocker(g->migration_blocker);
} else {
register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
virtio_gpu_save, virtio_gpu_load, g);
}
}
+static void virtio_gpu_device_unrealize(DeviceState *qdev, Error **errp)
+{
+ VirtIOGPU *g = VIRTIO_GPU(qdev);
+ if (g->migration_blocker) {
+ migrate_del_blocker(g->migration_blocker);
+ error_free(g->migration_blocker);
+ }
+}
+
static void virtio_gpu_instance_init(Object *obj)
{
}
@@ -1237,6 +1243,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
vdc->realize = virtio_gpu_device_realize;
+ vdc->unrealize = virtio_gpu_device_unrealize;
vdc->get_config = virtio_gpu_get_config;
vdc->set_config = virtio_gpu_set_config;
vdc->get_features = virtio_gpu_get_features;
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 325354f..e4f424a 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -118,6 +118,8 @@ typedef struct VirtIOGPU {
uint32_t req_3d;
uint32_t bytes_3d;
} stats;
+
+ Error *migration_blocker;
} VirtIOGPU;
extern const GraphicHwOps virtio_gpu_ops;
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v3 12/14] virtio-gpu: Use migrate_add_blocker for virgl migration blocking
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 12/14] virtio-gpu: Use migrate_add_blocker for virgl migration blocking Dr. David Alan Gilbert (git)
@ 2016-07-15 8:21 ` Cornelia Huck
2016-07-15 9:57 ` Gerd Hoffmann
1 sibling, 0 replies; 21+ messages in thread
From: Cornelia Huck @ 2016-07-15 8:21 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel
On Thu, 14 Jul 2016 18:22:54 +0100
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> virgl conditionally registers a vmstate as unmigratable when virgl
> is enabled; instead use the migrate_add_blocker mechanism.
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> hw/display/virtio-gpu.c | 19 +++++++++++++------
> include/hw/virtio/virtio-gpu.h | 2 ++
> 2 files changed, 15 insertions(+), 6 deletions(-)
>
> @@ -1169,13 +1165,23 @@ 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);
> + error_setg(&g->migration_blocker, "virgl is not yet migratable");
Suggest prepending with "virtio-gpu:".
> + migrate_add_blocker(g->migration_blocker);
> } else {
> register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
> virtio_gpu_save, virtio_gpu_load, g);
> }
> }
In any case,
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v3 12/14] virtio-gpu: Use migrate_add_blocker for virgl migration blocking
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 12/14] virtio-gpu: Use migrate_add_blocker for virgl migration blocking Dr. David Alan Gilbert (git)
2016-07-15 8:21 ` Cornelia Huck
@ 2016-07-15 9:57 ` Gerd Hoffmann
1 sibling, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2016-07-15 9:57 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git)
Cc: qemu-devel, mst, amit.shah, quintela, cornelia.huck
On Do, 2016-07-14 at 18:22 +0100, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> virgl conditionally registers a vmstate as unmigratable when virgl
> is enabled; instead use the migrate_add_blocker mechanism.
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 13/14] virtio-gpu: Wrap in vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (11 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 12/14] virtio-gpu: Use migrate_add_blocker for virgl migration blocking Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-15 9:56 ` Gerd Hoffmann
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 14/14] virtio: Update migration docs Dr. David Alan Gilbert (git)
2016-07-15 8:23 ` [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Cornelia Huck
14 siblings, 1 reply; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Forcibly convert it to a vmstate wrapper; proper conversion
comes later.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/display/virtio-gpu.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index cc87eb7..7fe6ed8 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -987,7 +987,7 @@ static const VMStateDescription vmstate_virtio_gpu_scanouts = {
},
};
-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);
@@ -1017,7 +1017,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);
@@ -1026,11 +1026,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;
}
@@ -1167,9 +1163,6 @@ static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
if (virtio_gpu_virgl_enabled(g->conf)) {
error_setg(&g->migration_blocker, "virgl is not yet migratable");
migrate_add_blocker(g->migration_blocker);
- } else {
- register_savevm(qdev, "virtio-gpu", -1, VIRTIO_GPU_VM_VERSION,
- virtio_gpu_save, virtio_gpu_load, g);
}
}
@@ -1226,6 +1219,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
@@ -1252,6 +1248,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] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v3 13/14] virtio-gpu: Wrap in vmstate
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 13/14] virtio-gpu: Wrap in vmstate Dr. David Alan Gilbert (git)
@ 2016-07-15 9:56 ` Gerd Hoffmann
0 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2016-07-15 9:56 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git)
Cc: qemu-devel, mst, amit.shah, quintela, cornelia.huck
On Do, 2016-07-14 at 18:22 +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.
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
> hw/display/virtio-gpu.c | 17 +++++++----------
> 1 file changed, 7 insertions(+), 10 deletions(-)
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v3 14/14] virtio: Update migration docs
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (12 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 13/14] virtio-gpu: Wrap in vmstate Dr. David Alan Gilbert (git)
@ 2016-07-14 17:22 ` Dr. David Alan Gilbert (git)
2016-07-15 8:23 ` [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Cornelia Huck
14 siblings, 0 replies; 21+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2016-07-14 17:22 UTC (permalink / raw)
To: qemu-devel, mst, amit.shah, quintela; +Cc: cornelia.huck, kraxel
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Remove references to register_savevm.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
docs/virtio-migration.txt | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/virtio-migration.txt b/docs/virtio-migration.txt
index cf66458..98a6b0f 100644
--- a/docs/virtio-migration.txt
+++ b/docs/virtio-migration.txt
@@ -28,7 +28,8 @@ virtio core virtio transport virtio device
----------- ---------------- -------------
save() function registered
- via register_savevm()
+ via VMState wrapper on
+ device class
virtio_save() <----------
------> save_config()
- save proxy device
@@ -63,7 +64,8 @@ virtio core virtio transport virtio device
----------- ---------------- -------------
load() function registered
- via register_savevm()
+ via VMState wrapper on
+ device class
virtio_load() <----------
------> load_config()
- load proxy device
--
2.7.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate
2016-07-14 17:22 [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
` (13 preceding siblings ...)
2016-07-14 17:22 ` [Qemu-devel] [PATCH v3 14/14] virtio: Update migration docs Dr. David Alan Gilbert (git)
@ 2016-07-15 8:23 ` Cornelia Huck
2016-07-15 12:43 ` Amit Shah
14 siblings, 1 reply; 21+ messages in thread
From: Cornelia Huck @ 2016-07-15 8:23 UTC (permalink / raw)
To: Dr. David Alan Gilbert (git); +Cc: qemu-devel, mst, amit.shah, quintela, kraxel
On Thu, 14 Jul 2016 18:22:42 +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.
Looks good, and I'd like to see this in 2.7.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate
2016-07-15 8:23 ` [Qemu-devel] [PATCH v3 00/14] virtio migration: Flip outer layer to vmstate Cornelia Huck
@ 2016-07-15 12:43 ` Amit Shah
0 siblings, 0 replies; 21+ messages in thread
From: Amit Shah @ 2016-07-15 12:43 UTC (permalink / raw)
To: Cornelia Huck
Cc: Dr. David Alan Gilbert (git), qemu-devel, mst, quintela, kraxel
On (Fri) 15 Jul 2016 [10:23:10], Cornelia Huck wrote:
> On Thu, 14 Jul 2016 18:22:42 +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.
>
> Looks good, and I'd like to see this in 2.7.
Michael mentioned he's interested in reviewing, so we'll wait a few
days for him to go through this.
Amit
^ permalink raw reply [flat|nested] 21+ messages in thread