Check whether the disable-legacy property is present on the following
devices:
virtio-balloon-pci
virtio-blk-pci
virtio-scsi-pci
virtio-serial-pci
virtio-9p-pci
virtio-net-pci
virtio-rng-pci
virtio-gpu-pci
virtio-input-host-pci
virtio-keyboard-pci
virtio-mouse-pci
virtio-tablet-pci
Assuming that if QEMU knows other virtio devices where this property
is applicable, it will have at least one of these devices.
Added in QEMU by:
commit e266d421490e0ae83044bbebb209b2d3650c0ba6
virtio-pci: add flags to enable/disable legacy/modern
---
v4: only check -pci devices
rename the capability to virtio-pci-disable-legacy
src/qemu/qemu_capabilities.c | 58 ++++++++++++++++++++++
src/qemu/qemu_capabilities.h | 1 +
tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 +
.../caps_2.6.0-gicv2.aarch64.xml | 1 +
.../caps_2.6.0-gicv3.aarch64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 1 +
tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 +
tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 +
9 files changed, 66 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 43e3ea7..46c6529 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -340,6 +340,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"display", /* 230 */
"intel-iommu",
"smm",
+ "virtio-pci-disable-legacy",
);
@@ -1741,6 +1742,34 @@ static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] =
{
ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI) },
};
+struct virQEMUCapsPropObjects {
+ const char *prop;
+ int flag;
+ const char **objects;
+};
+
+static const char *virQEMUCapsVirtioPCIDisableLegacyObjects[] = {
+ "virtio-balloon-pci",
+ "virtio-blk-pci",
+ "virtio-scsi-pci",
+ "virtio-serial-pci",
+ "virtio-9p-pci",
+ "virtio-net-pci",
+ "virtio-rng-pci",
+ "virtio-gpu-pci",
+ "virtio-input-host-pci",
+ "virtio-keyboard-pci",
+ "virtio-mouse-pci",
+ "virtio-tablet-pci",
+ NULL
+};
+
+static struct virQEMUCapsPropObjects virQEMUCapsPropObjects[] = {
+ { "disable-legacy",
+ QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY,
+ virQEMUCapsVirtioPCIDisableLegacyObjects }
+};
+
static void
virQEMUCapsProcessStringFlags(virQEMUCapsPtr qemuCaps,
@@ -1762,6 +1791,31 @@ virQEMUCapsProcessStringFlags(virQEMUCapsPtr qemuCaps,
static void
+virQEMUCapsProcessProps(virQEMUCapsPtr qemuCaps,
+ size_t nprops,
+ struct virQEMUCapsPropObjects *props,
+ const char *object,
+ size_t nvalues,
+ char *const*values)
+{
+ size_t i, j;
+
+ for (i = 0; i < nprops; i++) {
+ if (virQEMUCapsGet(qemuCaps, props[i].flag))
+ continue;
+
+ for (j = 0; j < nvalues; j++) {
+ if (STREQ(values[j], props[i].prop)) {
+ if (virStringArrayHasString((char **)props[i].objects, object))
+ virQEMUCapsSet(qemuCaps, props[i].flag);
+ break;
+ }
+ }
+ }
+}
+
+
+static void
virQEMUCapsFreeStringList(size_t len,
char **values)
{
@@ -2470,6 +2524,10 @@ virQEMUCapsProbeQMPObjects(virQEMUCapsPtr qemuCaps,
virQEMUCapsObjectProps[i].nprops,
virQEMUCapsObjectProps[i].props,
nvalues, values);
+ virQEMUCapsProcessProps(qemuCaps,
+ ARRAY_CARDINALITY(virQEMUCapsPropObjects),
+ virQEMUCapsPropObjects, type,
+ nvalues, values);
virQEMUCapsFreeStringList(nvalues, values);
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index d249e2e..776a0f3 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -373,6 +373,7 @@ typedef enum {
QEMU_CAPS_DISPLAY, /* -display */
QEMU_CAPS_DEVICE_INTEL_IOMMU, /* -device intel-iommu */
QEMU_CAPS_MACHINE_SMM_OPT, /* -machine xxx,smm=on/off/auto */
+ QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, /* virtio-*pci.disable-legacy */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
index 339ee1f..db778ef 100644
--- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
@@ -184,6 +184,7 @@
<flag name='display'/>
<flag name='intel-iommu'/>
<flag name='smm'/>
+ <flag name='virtio-pci-disable-legacy'/>
<version>2004000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
index c1a68d0..fc915ad 100644
--- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
@@ -189,6 +189,7 @@
<flag name='display'/>
<flag name='intel-iommu'/>
<flag name='smm'/>
+ <flag name='virtio-pci-disable-legacy'/>
<version>2005000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
index 85d7d3f..fd14665 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
@@ -158,6 +158,7 @@
<flag name='tls-creds-x509'/>
<flag name='display'/>
<flag name='smm'/>
+ <flag name='virtio-pci-disable-legacy'/>
<version>2005094</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
index deb1257..eb708f8 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
@@ -158,6 +158,7 @@
<flag name='tls-creds-x509'/>
<flag name='display'/>
<flag name='smm'/>
+ <flag name='virtio-pci-disable-legacy'/>
<version>2005094</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
index 2b7ea0e..482b384 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
@@ -152,6 +152,7 @@
<flag name='tls-creds-x509'/>
<flag name='display'/>
<flag name='smm'/>
+ <flag name='virtio-pci-disable-legacy'/>
<version>2005094</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
index 495c114..60f1fcf 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
@@ -195,6 +195,7 @@
<flag name='display'/>
<flag name='intel-iommu'/>
<flag name='smm'/>
+ <flag name='virtio-pci-disable-legacy'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
index fafffa6..ccb190b 100644
--- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
@@ -192,6 +192,7 @@
<flag name='display'/>
<flag name='intel-iommu'/>
<flag name='smm'/>
+ <flag name='virtio-pci-disable-legacy'/>
<version>2006091</version>
<kvmVersion>0</kvmVersion>
<package> (v2.7.0-rc1-52-g42e0d60)</package>
--
2.7.3