[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 45/67] virtio: allow per-device-class legacy feature
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 45/67] virtio: allow per-device-class legacy features |
Date: |
Wed, 14 Dec 2016 18:44:39 -0600 |
From: "Michael S. Tsirkin" <address@hidden>
Legacy features are those that transitional devices only
expose on the legacy interface.
Allow different ones per device class.
Cc: address@hidden # dependency for the next patch
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Cornelia Huck <address@hidden>
(cherry picked from commit 9b706dbbbb81f5cb7c67e491d38cd6077205e056)
Conflicts:
hw/virtio/virtio.c
* drop context dep on ff4c07df
* resolv func dep on ff4c07df creating vdc variable in
virtio_device_class_init()
Signed-off-by: Michael Roth <address@hidden>
---
hw/s390x/virtio-ccw.c | 4 +++-
hw/virtio/virtio-pci.c | 4 +++-
hw/virtio/virtio.c | 3 +++
include/hw/virtio/virtio.h | 5 +++++
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index a554a24..f6f5e79 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -330,6 +330,8 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
if (!ccw.cda) {
ret = -EFAULT;
} else {
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
+
features.index = address_space_ldub(&address_space_memory,
ccw.cda
+ sizeof(features.features),
@@ -339,7 +341,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
if (dev->revision >= 1) {
/* Don't offer legacy features for modern devices. */
features.features = (uint32_t)
- (vdev->host_features & ~VIRTIO_LEGACY_FEATURES);
+ (vdev->host_features & ~vdc->legacy_features);
} else {
features.features = (uint32_t)vdev->host_features;
}
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 755f921..46711a2 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1192,7 +1192,9 @@ static uint64_t virtio_pci_common_read(void *opaque,
hwaddr addr,
break;
case VIRTIO_PCI_COMMON_DF:
if (proxy->dfselect <= 1) {
- val = (vdev->host_features & ~VIRTIO_LEGACY_FEATURES) >>
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
+
+ val = (vdev->host_features & ~vdc->legacy_features) >>
(32 * proxy->dfselect);
}
break;
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index e8a13a5..f31140a 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1966,12 +1966,15 @@ static Property virtio_properties[] = {
static void virtio_device_class_init(ObjectClass *klass, void *data)
{
/* Set the default value here. */
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = virtio_device_realize;
dc->unrealize = virtio_device_unrealize;
dc->bus_type = TYPE_VIRTIO_BUS;
dc->props = virtio_properties;
+
+ vdc->legacy_features |= VIRTIO_LEGACY_FEATURES;
}
static const TypeInfo virtio_device_info = {
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index d2490c1..d51341d 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -112,6 +112,11 @@ typedef struct VirtioDeviceClass {
void (*set_config)(VirtIODevice *vdev, const uint8_t *config);
void (*reset)(VirtIODevice *vdev);
void (*set_status)(VirtIODevice *vdev, uint8_t val);
+ /* For transitional devices, this is a bitmap of features
+ * that are only exposed on the legacy interface but not
+ * the modern one.
+ */
+ uint64_t legacy_features;
/* Test and clear event pending status.
* Should be called after unmask to avoid losing events.
* If backend does not support masking,
--
1.9.1
- [Qemu-devel] [PATCH 34/67] tests/test-qmp-input-strict: Cover missing struct members, (continued)
- [Qemu-devel] [PATCH 34/67] tests/test-qmp-input-strict: Cover missing struct members, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 37/67] throttle: Correct access to wrong BlockBackendPublic structures, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 44/67] target-ppc: Fix CPU migration from qemu-2.6 <-> later versions, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 38/67] qemu-iotests: Test I/O in a single drive from a throttling group, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 03/67] hw/ppc/spapr: Fix the selection of the processor features, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 46/67] virtio-net: mark VIRTIO_NET_F_GSO as legacy, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 43/67] net: fix sending of data with -net socket, listen backend, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 40/67] memory: Replace skip_dump flag with "ram_device", Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 41/67] memory: Don't use memcpy for ram_device regions, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 42/67] acpi/ipmi: Initialize the fwinfo before fetching it, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 45/67] virtio: allow per-device-class legacy features,
Michael Roth <=
- [Qemu-devel] [PATCH 47/67] block: Don't mark node clean after failed flush, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 50/67] qcow2: Inform block layer about discard boundaries, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 51/67] block: Let write zeroes fallback work even with small max_transfer, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 53/67] block: Pass unaligned discard requests to drivers, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 48/67] vhost: adapt vhost_verify_ring_mappings() to virtio 1 ring layout, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 55/67] block/curl: Fix return value from curl_read_cb, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 56/67] block/curl: Remember all sockets, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 58/67] vhost: drop legacy vring layout bits, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 49/67] slirp: Fix access to freed memory, Michael Roth, 2016/12/14
- [Qemu-devel] [PATCH 04/67] ppc: Check the availability of transactional memory, Michael Roth, 2016/12/14