[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 65/77] virtio: list legacy-capable devices
From: |
Michael Roth |
Subject: |
[PATCH 65/77] virtio: list legacy-capable devices |
Date: |
Thu, 3 Sep 2020 15:59:23 -0500 |
From: Cornelia Huck <cohuck@redhat.com>
Several types of virtio devices had already been around before the
virtio standard was specified. These devices support virtio in legacy
(and transitional) mode.
Devices that have been added in the virtio standard are considered
non-transitional (i.e. with no support for legacy virtio).
Provide a helper function so virtio transports can figure that out
easily.
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20200707105446.677966-2-cohuck@redhat.com>
Cc: qemu-stable@nongnu.org
Acked-by: Halil Pasic <pasic@linux.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 7c78bdd7a3d0086179331f10d1f6f8cdac34731a)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
hw/virtio/virtio.c | 25 +++++++++++++++++++++++++
include/hw/virtio/virtio.h | 2 ++
2 files changed, 27 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index b6c8ef5bc0..398fd4a305 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -27,6 +27,7 @@
#include "hw/virtio/virtio-access.h"
#include "sysemu/dma.h"
#include "sysemu/runstate.h"
+#include "standard-headers/linux/virtio_ids.h"
/*
* The alignment to use between consumer and producer parts of vring.
@@ -3278,6 +3279,30 @@ void virtio_init(VirtIODevice *vdev, const char *name,
vdev->use_guest_notifier_mask = true;
}
+/*
+ * Only devices that have already been around prior to defining the virtio
+ * standard support legacy mode; this includes devices not specified in the
+ * standard. All newer devices conform to the virtio standard only.
+ */
+bool virtio_legacy_allowed(VirtIODevice *vdev)
+{
+ switch (vdev->device_id) {
+ case VIRTIO_ID_NET:
+ case VIRTIO_ID_BLOCK:
+ case VIRTIO_ID_CONSOLE:
+ case VIRTIO_ID_RNG:
+ case VIRTIO_ID_BALLOON:
+ case VIRTIO_ID_RPMSG:
+ case VIRTIO_ID_SCSI:
+ case VIRTIO_ID_9P:
+ case VIRTIO_ID_RPROC_SERIAL:
+ case VIRTIO_ID_CAIF:
+ return true;
+ default:
+ return false;
+ }
+}
+
hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
{
return vdev->vq[n].vring.desc;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index b69d517496..198ffc7626 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -396,4 +396,6 @@ static inline bool virtio_device_disabled(VirtIODevice
*vdev)
return unlikely(vdev->disabled || vdev->broken);
}
+bool virtio_legacy_allowed(VirtIODevice *vdev);
+
#endif
--
2.17.1
- [PATCH 56/77] target/hppa: Free some temps in do_sub, (continued)
- [PATCH 56/77] target/hppa: Free some temps in do_sub, Michael Roth, 2020/09/03
- [PATCH 55/77] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid, Michael Roth, 2020/09/03
- [PATCH 57/77] tpm: tpm_spapr: Exit on TPM backend failures, Michael Roth, 2020/09/03
- [PATCH 59/77] qdev: Fix device_add DRIVER,help to print to monitor, Michael Roth, 2020/09/03
- [PATCH 62/77] virtio-balloon: always indicate S_DONE when migration fails, Michael Roth, 2020/09/03
- [PATCH 58/77] tests: tpm: Skip over pcrUpdateCounter byte in result comparison, Michael Roth, 2020/09/03
- [PATCH 60/77] virtio-balloon: Prevent guest from starting a report when we didn't request one, Michael Roth, 2020/09/03
- [PATCH 63/77] linux-headers: update against Linux 5.7-rc3, Michael Roth, 2020/09/03
- [PATCH 61/77] virtio-balloon: Add locking to prevent possible race when starting hinting, Michael Roth, 2020/09/03
- [PATCH 71/77] migration/block-dirty-bitmap: fix dirty_bitmap_mig_before_vm_start, Michael Roth, 2020/09/03
- [PATCH 65/77] virtio: list legacy-capable devices,
Michael Roth <=
- [PATCH 66/77] virtio: verify that legacy support is not accidentally on, Michael Roth, 2020/09/03
- [PATCH 05/77] net: Do not include a newline in the id of -nic devices, Michael Roth, 2020/09/03
- [PATCH 67/77] intel_iommu: Use correct shift for 256 bits qi descriptor, Michael Roth, 2020/09/03
- [PATCH 69/77] libvhost-user: Report descriptor index on panic, Michael Roth, 2020/09/03
- [PATCH 68/77] virtio-pci: Changed vdev to proxy for VirtIO PCI BAR callbacks., Michael Roth, 2020/09/03
- [PATCH 06/77] nbd/server: Avoid long error message assertions CVE-2020-10761, Michael Roth, 2020/09/03
- [PATCH 72/77] block: Fix bdrv_aligned_p*v() for qiov_offset != 0, Michael Roth, 2020/09/03
- [PATCH 73/77] iotests/028: Add test for cross-base-EOF reads, Michael Roth, 2020/09/03
- [PATCH 74/77] nbd: Fix large trim/zero requests, Michael Roth, 2020/09/03