From aae262c711f14fd99bca27842f9accd08d55d578 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Tue, 6 Mar 2018 14:44:49 +0100 Subject: [PATCH] qemu: Remove virQEMUCapsProcessProps() This function was introduced in commit 41f5c2ca2776 as a way to probe the same property for multiple devices at once. Although the resulting representation is very compact, it doesn't provide any extra features compared to the existing virQEMUCapsProcessStringFlags() mechanism, which is already used for pretty much all device properties. Drop the custom function and datatypes and start using the standard ones instead. Note that, in theory, the end result is not identical because we're no longer probing properties for virtio-serial-pci virtio-9p-pci virtio-rng-pci virtio-input-host-pci virtio-keyboard-pci virtio-mouse-pci virtio-tablet-pci However, chances of any of those devices being compiled into a QEMU binary where virtio-balloon-pci virtio-blk-pci virtio-scsi-pci virtio-net-pci virtio-gpu-pci are compiled out are slim enough that it doesn't make any difference in practice, as the lack of test suite churn shows. Signed-off-by: Andrea Bolognani --- src/qemu/qemu_capabilities.c | 78 +++++++----------------------------- 1 file changed, 15 insertions(+), 63 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 853e8cefcf..3eb5ed6d1a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1698,6 +1698,9 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = { { "deflate-on-oom", QEMU_CAPS_VIRTIO_BALLOON_AUTODEFLATE }, + { "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY }, + { "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM }, + { "ats", QEMU_CAPS_VIRTIO_PCI_ATS }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { @@ -1709,6 +1712,9 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { { "logical_block_size", QEMU_CAPS_BLOCKIO }, { "num-queues", QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES }, { "share-rw", QEMU_CAPS_DISK_SHARE_RW }, + { "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY }, + { "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM }, + { "ats", QEMU_CAPS_VIRTIO_PCI_ATS }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioNet[] = { @@ -1717,6 +1723,9 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioNet[] = { { "rx_queue_size", QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE }, { "tx_queue_size", QEMU_CAPS_VIRTIO_NET_TX_QUEUE_SIZE }, { "host_mtu", QEMU_CAPS_VIRTIO_NET_HOST_MTU }, + { "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY }, + { "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM }, + { "ats", QEMU_CAPS_VIRTIO_PCI_ATS }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsSpaprPCIHostBridge[] = { @@ -1725,6 +1734,9 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsSpaprPCIHostBridge[] static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioSCSI[] = { { "iothread", QEMU_CAPS_VIRTIO_SCSI_IOTHREAD }, + { "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY }, + { "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM }, + { "ats", QEMU_CAPS_VIRTIO_PCI_ATS }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsPCIAssign[] = { @@ -1799,6 +1811,9 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQxl[] = { static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioGpu[] = { { "virgl", QEMU_CAPS_VIRTIO_GPU_VIRGL }, { "max_outputs", QEMU_CAPS_VIRTIO_GPU_MAX_OUTPUTS }, + { "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY }, + { "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM }, + { "ats", QEMU_CAPS_VIRTIO_PCI_ATS }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsICH9[] = { @@ -1934,40 +1949,6 @@ static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = { QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE }, }; -struct virQEMUCapsPropTypeObjects { - const char *prop; - int flag; - const char **objects; -}; - -static const char *virQEMUCapsVirtioPCIObjects[] = { - "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 virQEMUCapsPropTypeObjects virQEMUCapsPropObjects[] = { - { "disable-legacy", - QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, - virQEMUCapsVirtioPCIObjects }, - { "iommu_platform", - QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, - virQEMUCapsVirtioPCIObjects }, - { "ats", - QEMU_CAPS_VIRTIO_PCI_ATS, - virQEMUCapsVirtioPCIObjects }, -}; - static void virQEMUCapsProcessStringFlags(virQEMUCapsPtr qemuCaps, @@ -1991,31 +1972,6 @@ virQEMUCapsProcessStringFlags(virQEMUCapsPtr qemuCaps, } -static void -virQEMUCapsProcessProps(virQEMUCapsPtr qemuCaps, - size_t nprops, - struct virQEMUCapsPropTypeObjects *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 (virStringListHasString(props[i].objects, object)) - virQEMUCapsSet(qemuCaps, props[i].flag); - break; - } - } - } -} - - #define OBJECT_TYPE_PREFIX "name \"" static int @@ -2908,10 +2864,6 @@ virQEMUCapsProbeQMPObjects(virQEMUCapsPtr qemuCaps, virQEMUCapsObjectProps[i].nprops, virQEMUCapsObjectProps[i].props, nvalues, values); - virQEMUCapsProcessProps(qemuCaps, - ARRAY_CARDINALITY(virQEMUCapsPropObjects), - virQEMUCapsPropObjects, type, - nvalues, values); virStringListFreeCount(values, nvalues); }