From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuMz5-0005lK-QC for qemu-devel@nongnu.org; Mon, 18 May 2015 11:29:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuMz0-0006xq-PY for qemu-devel@nongnu.org; Mon, 18 May 2015 11:29:39 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:42339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuMz0-0006xc-H9 for qemu-devel@nongnu.org; Mon, 18 May 2015 11:29:34 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 May 2015 16:29:32 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 78F5117D805F for ; Mon, 18 May 2015 16:30:21 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4IFTUam10092852 for ; Mon, 18 May 2015 15:29:30 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t4IFTTNB009374 for ; Mon, 18 May 2015 09:29:30 -0600 Date: Mon, 18 May 2015 17:29:28 +0200 From: Cornelia Huck Message-ID: <20150518172928.43300b77.cornelia.huck@de.ibm.com> In-Reply-To: <20150518132635.57971731.cornelia.huck@de.ibm.com> References: <20150513165438-mutt-send-email-mst@redhat.com> <20150513170335.2d662124.cornelia.huck@de.ibm.com> <20150513180005-mutt-send-email-mst@redhat.com> <55539E7C.90004@de.ibm.com> <20150513234516-mutt-send-email-mst@redhat.com> <55546945.4050400@de.ibm.com> <20150514112845-mutt-send-email-mst@redhat.com> <55547938.4020201@de.ibm.com> <20150514170035.GJ2576@work-vm> <55559B57.5020704@de.ibm.com> <20150515091307-mutt-send-email-mst@redhat.com> <20150518132635.57971731.cornelia.huck@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC 1/1] virtio: migrate config_vector List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Christian Borntraeger , "Dr. David Alan Gilbert" , jjherne@linux.vnet.ibm.com, "Michael S. Tsirkin" On Mon, 18 May 2015 13:26:35 +0200 Cornelia Huck 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: =46rom 773a753475d9c89fb8dc789005a694d07b0cfac2 Mon Sep 17 00:00:00 2001 From: Cornelia Huck 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" Signed-off-by: Cornelia Huck --- 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) =20 virtio_ccw_stop_ioeventfd(dev); } + +static bool virtio_ccw_needs_confvec(DeviceState *d) +{ + VirtioCcwDevice *dev =3D VIRTIO_CCW_DEVICE(d); + VirtIODevice *vdev =3D virtio_bus_get_device(&dev->bus); + + return vdev && (vdev->config_vector !=3D VIRTIO_NO_VECTOR); +} + /**************** Virtio-ccw Bus Device Descriptions *******************/ =20 static Property virtio_ccw_net_properties[] =3D { @@ -1760,6 +1769,7 @@ static void virtio_ccw_bus_class_init(ObjectClass *kl= ass, void *data) k->load_config =3D virtio_ccw_load_config; k->device_plugged =3D virtio_ccw_device_plugged; k->device_unplugged =3D virtio_ccw_device_unplugged; + k->needs_confvec =3D virtio_ccw_needs_confvec; } =20 static const TypeInfo virtio_ccw_bus_info =3D { 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 =3D { } }; =20 +static bool virtio_device_confvec_needed(void *opaque) +{ + VirtIODevice *vdev =3D opaque; + BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); + VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); + + return k && k->needs_confvec ? + k->needs_confvec(qbus->parent) : false; +} + +static const VMStateDescription vmstate_virtio_device_confvec =3D { + .name =3D "virtio/config_vector", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT16(config_vector, VirtIODevice), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_virtio =3D { .name =3D "virtio", .version_id =3D 1, @@ -916,6 +936,10 @@ static const VMStateDescription vmstate_virtio =3D { .vmsd =3D &vmstate_virtio_device_endian, .needed =3D &virtio_device_endian_needed }, + { + .vmsd =3D &vmstate_virtio_device_confvec, + .needed =3D &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; =20 struct VirtioBusState { --=20 2.3.7