[PATCH 5/9] qemu: allow conditional device property probing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Do not probe for devices that QEMU does not know
when probing for device options.
---
 src/qemu/qemu_capabilities.c | 99 ++++++++++++++++++++++++++++++--------------
 1 file changed, 68 insertions(+), 31 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 05d0a91..278badf 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1742,71 +1742,103 @@ struct virQEMUCapsObjectTypeProps {
     const char *type;
     struct virQEMUCapsStringFlags *props;
     size_t nprops;
+    int capsCondition;
 };
 
 static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
     { "virtio-blk-pci", virQEMUCapsObjectPropsVirtioBlk,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
+      -1 },
     { "virtio-net-pci", virQEMUCapsObjectPropsVirtioNet,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
+      -1 },
     { "virtio-scsi-pci", virQEMUCapsObjectPropsVirtioSCSI,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI),
+      -1 },
     { "virtio-blk-ccw", virQEMUCapsObjectPropsVirtioBlk,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
+      -1 },
     { "virtio-net-ccw", virQEMUCapsObjectPropsVirtioNet,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
+      -1 },
     { "virtio-scsi-ccw", virQEMUCapsObjectPropsVirtioSCSI,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI),
+      -1 },
     { "virtio-blk-s390", virQEMUCapsObjectPropsVirtioBlk,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
+      -1 },
     { "virtio-net-s390", virQEMUCapsObjectPropsVirtioNet,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
+      -1 },
     { "pci-assign", virQEMUCapsObjectPropsPCIAssign,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign),
+      -1 },
     { "kvm-pci-assign", virQEMUCapsObjectPropsPCIAssign,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign),
+      -1 },
     { "vfio-pci", virQEMUCapsObjectPropsVfioPCI,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVfioPCI) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVfioPCI),
+      -1 },
     { "scsi-disk", virQEMUCapsObjectPropsSCSIDisk,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIDisk) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIDisk),
+      -1 },
     { "ide-drive", virQEMUCapsObjectPropsIDEDrive,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsIDEDrive) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsIDEDrive),
+      -1 },
     { "PIIX4_PM", virQEMUCapsObjectPropsPiix4PM,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPiix4PM) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPiix4PM),
+      -1 },
     { "usb-redir", virQEMUCapsObjectPropsUSBRedir,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBRedir) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBRedir),
+      -1 },
     { "usb-host", virQEMUCapsObjectPropsUSBHost,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBHost) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBHost),
+      -1 },
     { "scsi-generic", virQEMUCapsObjectPropsSCSIGeneric,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIGeneric) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIGeneric),
+      -1 },
     { "i440FX-pcihost", virQEMUCapsObjectPropsI440FXPCIHost,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsI440FXPCIHost) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsI440FXPCIHost),
+      -1 },
     { "q35-pcihost", virQEMUCapsObjectPropsQ35PCIHost,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQ35PCIHost) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQ35PCIHost),
+      -1 },
     { "usb-storage", virQEMUCapsObjectPropsUSBStorage,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBStorage) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBStorage),
+      -1 },
     { "kvm-pit", virQEMUCapsObjectPropsKVMPit,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsKVMPit) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsKVMPit),
+      -1 },
     { "VGA", virQEMUCapsObjectPropsVGA,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVGA) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVGA),
+      -1 },
     { "vmware-svga", virQEMUCapsObjectPropsVmwareSvga,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVmwareSvga) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVmwareSvga),
+      -1 },
     { "qxl", virQEMUCapsObjectPropsQxl,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxl) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxl),
+      -1 },
     { "virtio-gpu-pci", virQEMUCapsObjectPropsVirtioGpu,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu),
+      -1 },
     { "virtio-gpu-device", virQEMUCapsObjectPropsVirtioGpu,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu),
+      -1 },
     { "ICH9-LPC", virQEMUCapsObjectPropsICH9,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsICH9) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsICH9),
+      -1 },
     { "virtio-balloon-pci", virQEMUCapsObjectPropsVirtioBalloon,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
+      -1 },
     { "virtio-balloon-ccw", virQEMUCapsObjectPropsVirtioBalloon,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
+      -1 },
     { "virtio-balloon-device", virQEMUCapsObjectPropsVirtioBalloon,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
+      -1 },
     { "nec-usb-xhci", virQEMUCapsObjectPropsUSBNECXHCI,
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI) },
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI),
+      -1 },
 };
 
 struct virQEMUCapsPropTypeObjects {
@@ -2719,6 +2751,11 @@ virQEMUCapsProbeQMPObjects(virQEMUCapsPtr qemuCaps,
 
     for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsObjectProps); i++) {
         const char *type = virQEMUCapsObjectProps[i].type;
+        int cap = virQEMUCapsObjectProps[i].capsCondition;
+
+        if (cap >= 0 && !virQEMUCapsGet(qemuCaps, cap))
+            continue;
+
         if ((nvalues = qemuMonitorGetObjectProps(mon,
                                                  type,
                                                  &values)) < 0)
-- 
2.10.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux