qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC 1/1] virtio: migrate config_vector


From: Cornelia Huck
Subject: Re: [Qemu-devel] [PATCH RFC 1/1] virtio: migrate config_vector
Date: Mon, 18 May 2015 17:29:28 +0200

On Mon, 18 May 2015 13:26:35 +0200
Cornelia Huck <address@hidden> wrote:

> Would the subsection approach be more acceptable if I default needed to
> false and have only virtio-ccw override it in a callback?

Smth like the following:

From 773a753475d9c89fb8dc789005a694d07b0cfac2 Mon Sep 17 00:00:00 2001
From: Cornelia Huck <address@hidden>
Date: Tue, 12 May 2015 09:14:45 +0200
Subject: [PATCH] virtio: migrate config_vector

Currently, config_vector is managed in VirtIODevice, but migration is
handled by the transport; this led to one transport using config_vector
migrating correctly (pci), while the other forgot it (ccw).

We don't want to simply add a value to the virtio-ccw save data (it
may make migration failures hard to debug), and unfortunately we can't
add optional vmstate subsections to a transport only. So let's add
a new subsection for config_vector to the core and only let virtio-ccw
signal via an optional callback that it wants the config_vector to be
saved.

Reported-by: "Jason J. Herne" <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
 hw/s390x/virtio-ccw.c          | 10 ++++++++++
 hw/virtio/virtio.c             | 24 ++++++++++++++++++++++++
 include/hw/virtio/virtio-bus.h |  5 +++++
 3 files changed, 39 insertions(+)

diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index c96101a..dfb4514 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1436,6 +1436,15 @@ static void virtio_ccw_device_unplugged(DeviceState *d)
 
     virtio_ccw_stop_ioeventfd(dev);
 }
+
+static bool virtio_ccw_needs_confvec(DeviceState *d)
+{
+    VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
+    VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
+
+    return vdev && (vdev->config_vector != VIRTIO_NO_VECTOR);
+}
+
 /**************** Virtio-ccw Bus Device Descriptions *******************/
 
 static Property virtio_ccw_net_properties[] = {
@@ -1760,6 +1769,7 @@ static void virtio_ccw_bus_class_init(ObjectClass *klass, 
void *data)
     k->load_config = virtio_ccw_load_config;
     k->device_plugged = virtio_ccw_device_plugged;
     k->device_unplugged = virtio_ccw_device_unplugged;
+    k->needs_confvec = virtio_ccw_needs_confvec;
 }
 
 static const TypeInfo virtio_ccw_bus_info = {
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 6985e76..627be0d 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -903,6 +903,26 @@ static const VMStateDescription 
vmstate_virtio_device_endian = {
     }
 };
 
+static bool virtio_device_confvec_needed(void *opaque)
+{
+    VirtIODevice *vdev = opaque;
+    BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
+    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+
+    return k && k->needs_confvec ?
+        k->needs_confvec(qbus->parent) : false;
+}
+
+static const VMStateDescription vmstate_virtio_device_confvec = {
+    .name = "virtio/config_vector",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT16(config_vector, VirtIODevice),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static const VMStateDescription vmstate_virtio = {
     .name = "virtio",
     .version_id = 1,
@@ -916,6 +936,10 @@ static const VMStateDescription vmstate_virtio = {
             .vmsd = &vmstate_virtio_device_endian,
             .needed = &virtio_device_endian_needed
         },
+        {
+            .vmsd = &vmstate_virtio_device_confvec,
+            .needed = &virtio_device_confvec_needed,
+        },
         { 0 }
     }
 };
diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h
index a4588ca..79e6e8b 100644
--- a/include/hw/virtio/virtio-bus.h
+++ b/include/hw/virtio/virtio-bus.h
@@ -69,6 +69,11 @@ typedef struct VirtioBusClass {
      * Note that changing this will break migration for this transport.
      */
     bool has_variable_vring_alignment;
+    /*
+     * (optional) Does the bus want the core to handle config_vector
+     * migration? This is for backwards compatibility only.
+     */
+    bool (*needs_confvec)(DeviceState *d);
 } VirtioBusClass;
 
 struct VirtioBusState {
-- 
2.3.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]