[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 7/9] virtio: handle non-virtio-1-capable backend for
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 7/9] virtio: handle non-virtio-1-capable backend for ccw |
Date: |
Wed, 2 Dec 2015 22:35:42 +0200 |
From: Cornelia Huck <address@hidden>
If you run a qemu advertising VERSION_1 with an old kernel where
vhost did not yet support VERSION_1, you'll end up with a device
that is {modern pci|ccw revision 1} but does not advertise VERSION_1.
This is not a sensible configuration and is rejected by the Linux
guest drivers.
To fix this, add a ->post_plugged() callback invoked after features
have been queried that can handle the VERSION_1 bit being withdrawn
and change ccw to fall back to revision 0 if VERSION_1 is gone.
Note that pci is _not_ fixed; we'll need to rethink the approach
for the next release but at least for pci it's not a regression.
Signed-off-by: Cornelia Huck <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
include/hw/virtio/virtio-bus.h | 5 +++++
hw/s390x/virtio-ccw.c | 12 ++++++++++++
hw/virtio/virtio-bus.c | 3 +++
3 files changed, 20 insertions(+)
diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h
index 6c3d4cb..3f2c136 100644
--- a/include/hw/virtio/virtio-bus.h
+++ b/include/hw/virtio/virtio-bus.h
@@ -60,6 +60,11 @@ typedef struct VirtioBusClass {
*/
void (*device_plugged)(DeviceState *d, Error **errp);
/*
+ * Re-evaluate setup after feature bits have been validated
+ * by the device backend.
+ */
+ void (*post_plugged)(DeviceState *d, Error **errp);
+ /*
* transport independent exit function.
* This is called by virtio-bus just before the device is unplugged.
*/
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index fb103b7..63da303 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1555,6 +1555,17 @@ static void virtio_ccw_device_plugged(DeviceState *d,
Error **errp)
d->hotplugged, 1);
}
+static void virtio_ccw_post_plugged(DeviceState *d, Error **errp)
+{
+ VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
+ VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
+
+ if (!virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1)) {
+ /* A backend didn't support modern virtio. */
+ dev->max_rev = 0;
+ }
+}
+
static void virtio_ccw_device_unplugged(DeviceState *d)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
@@ -1891,6 +1902,7 @@ static void virtio_ccw_bus_class_init(ObjectClass *klass,
void *data)
k->save_config = virtio_ccw_save_config;
k->load_config = virtio_ccw_load_config;
k->device_plugged = virtio_ccw_device_plugged;
+ k->post_plugged = virtio_ccw_post_plugged;
k->device_unplugged = virtio_ccw_device_unplugged;
}
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index febda76..81c7cdd 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -56,6 +56,9 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error
**errp)
assert(vdc->get_features != NULL);
vdev->host_features = vdc->get_features(vdev, vdev->host_features,
errp);
+ if (klass->post_plugged != NULL) {
+ klass->post_plugged(qbus->parent, errp);
+ }
}
/* Reset the virtio_bus */
--
MST
- [Qemu-devel] [PULL 0/9] virtio,vhost,mmap fixes for 2.5, Michael S. Tsirkin, 2015/12/02
- [Qemu-devel] [PULL 1/9] vhost-user-test: fix chardriver race, Michael S. Tsirkin, 2015/12/02
- [Qemu-devel] [PULL 2/9] vhost-user-test: use unix port for migration, Michael S. Tsirkin, 2015/12/02
- [Qemu-devel] [PULL 3/9] vhost-user-test: fix crash with glib < 2.36, Michael S. Tsirkin, 2015/12/02
- [Qemu-devel] [PULL 4/9] vhost-user: verify that number of queues is non-zero, Michael S. Tsirkin, 2015/12/02
- [Qemu-devel] [PULL 6/9] tests/vhost-user-bridge.c: fix fd leakage, Michael S. Tsirkin, 2015/12/02
- [Qemu-devel] [PULL 5/9] vhost: drop dead code, Michael S. Tsirkin, 2015/12/02
- [Qemu-devel] [PULL 7/9] virtio: handle non-virtio-1-capable backend for ccw,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 8/9] virtio-pci: Set the QEMU_PCI_CAP_EXPRESS capability early in its DeviceClass realize method, Michael S. Tsirkin, 2015/12/02
- [Qemu-devel] [PULL 9/9] util/mmap-alloc: fix hugetlb support on ppc64, Michael S. Tsirkin, 2015/12/02
- Re: [Qemu-devel] [PULL 0/9] virtio,vhost,mmap fixes for 2.5, Michael S. Tsirkin, 2015/12/02