3e5111
From 363d20b7336faeb280bf583d9d148e441d4286be Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <363d20b7336faeb280bf583d9d148e441d4286be@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Tue, 16 May 2017 10:44:50 +0200
3e5111
Subject: [PATCH] qemu: allow conditional device property probing
3e5111
MIME-Version: 1.0
3e5111
Content-Type: text/plain; charset=UTF-8
3e5111
Content-Transfer-Encoding: 8bit
3e5111
3e5111
Do not probe for devices that QEMU does not know
3e5111
when probing for device options.
3e5111
3e5111
(cherry picked from commit 4ae59411fa3f16e18e16cc4db7894fe5fd6404ce)
3e5111
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1427005
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_capabilities.c | 99 ++++++++++++++++++++++++++++++--------------
3e5111
 1 file changed, 68 insertions(+), 31 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
3e5111
index b76b79342..49fb52e03 100644
3e5111
--- a/src/qemu/qemu_capabilities.c
3e5111
+++ b/src/qemu/qemu_capabilities.c
3e5111
@@ -1728,71 +1728,103 @@ struct virQEMUCapsObjectTypeProps {
3e5111
     const char *type;
3e5111
     struct virQEMUCapsStringFlags *props;
3e5111
     size_t nprops;
3e5111
+    int capsCondition;
3e5111
 };
3e5111
 
3e5111
 static struct virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
3e5111
     { "virtio-blk-pci", virQEMUCapsObjectPropsVirtioBlk,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
3e5111
+      -1 },
3e5111
     { "virtio-net-pci", virQEMUCapsObjectPropsVirtioNet,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
3e5111
+      -1 },
3e5111
     { "virtio-scsi-pci", virQEMUCapsObjectPropsVirtioSCSI,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI),
3e5111
+      -1 },
3e5111
     { "virtio-blk-ccw", virQEMUCapsObjectPropsVirtioBlk,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
3e5111
+      -1 },
3e5111
     { "virtio-net-ccw", virQEMUCapsObjectPropsVirtioNet,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
3e5111
+      -1 },
3e5111
     { "virtio-scsi-ccw", virQEMUCapsObjectPropsVirtioSCSI,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioSCSI),
3e5111
+      -1 },
3e5111
     { "virtio-blk-s390", virQEMUCapsObjectPropsVirtioBlk,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBlk),
3e5111
+      -1 },
3e5111
     { "virtio-net-s390", virQEMUCapsObjectPropsVirtioNet,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioNet),
3e5111
+      -1 },
3e5111
     { "pci-assign", virQEMUCapsObjectPropsPCIAssign,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign),
3e5111
+      -1 },
3e5111
     { "kvm-pci-assign", virQEMUCapsObjectPropsPCIAssign,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPCIAssign),
3e5111
+      -1 },
3e5111
     { "vfio-pci", virQEMUCapsObjectPropsVfioPCI,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVfioPCI) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVfioPCI),
3e5111
+      -1 },
3e5111
     { "scsi-disk", virQEMUCapsObjectPropsSCSIDisk,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIDisk) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIDisk),
3e5111
+      -1 },
3e5111
     { "ide-drive", virQEMUCapsObjectPropsIDEDrive,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsIDEDrive) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsIDEDrive),
3e5111
+      -1 },
3e5111
     { "PIIX4_PM", virQEMUCapsObjectPropsPiix4PM,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPiix4PM) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsPiix4PM),
3e5111
+      -1 },
3e5111
     { "usb-redir", virQEMUCapsObjectPropsUSBRedir,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBRedir) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBRedir),
3e5111
+      -1 },
3e5111
     { "usb-host", virQEMUCapsObjectPropsUSBHost,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBHost) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBHost),
3e5111
+      -1 },
3e5111
     { "scsi-generic", virQEMUCapsObjectPropsSCSIGeneric,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIGeneric) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsSCSIGeneric),
3e5111
+      -1 },
3e5111
     { "i440FX-pcihost", virQEMUCapsObjectPropsI440FXPCIHost,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsI440FXPCIHost) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsI440FXPCIHost),
3e5111
+      -1 },
3e5111
     { "q35-pcihost", virQEMUCapsObjectPropsQ35PCIHost,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQ35PCIHost) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQ35PCIHost),
3e5111
+      -1 },
3e5111
     { "usb-storage", virQEMUCapsObjectPropsUSBStorage,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBStorage) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBStorage),
3e5111
+      -1 },
3e5111
     { "kvm-pit", virQEMUCapsObjectPropsKVMPit,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsKVMPit) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsKVMPit),
3e5111
+      -1 },
3e5111
     { "VGA", virQEMUCapsObjectPropsVGA,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVGA) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVGA),
3e5111
+      -1 },
3e5111
     { "vmware-svga", virQEMUCapsObjectPropsVmwareSvga,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVmwareSvga) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVmwareSvga),
3e5111
+      -1 },
3e5111
     { "qxl", virQEMUCapsObjectPropsQxl,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxl) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsQxl),
3e5111
+      -1 },
3e5111
     { "virtio-gpu-pci", virQEMUCapsObjectPropsVirtioGpu,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu),
3e5111
+      -1 },
3e5111
     { "virtio-gpu-device", virQEMUCapsObjectPropsVirtioGpu,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioGpu),
3e5111
+      -1 },
3e5111
     { "ICH9-LPC", virQEMUCapsObjectPropsICH9,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsICH9) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsICH9),
3e5111
+      -1 },
3e5111
     { "virtio-balloon-pci", virQEMUCapsObjectPropsVirtioBalloon,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
3e5111
+      -1 },
3e5111
     { "virtio-balloon-ccw", virQEMUCapsObjectPropsVirtioBalloon,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
3e5111
+      -1 },
3e5111
     { "virtio-balloon-device", virQEMUCapsObjectPropsVirtioBalloon,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsVirtioBalloon),
3e5111
+      -1 },
3e5111
     { "nec-usb-xhci", virQEMUCapsObjectPropsUSBNECXHCI,
3e5111
-      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI) },
3e5111
+      ARRAY_CARDINALITY(virQEMUCapsObjectPropsUSBNECXHCI),
3e5111
+      -1 },
3e5111
 };
3e5111
 
3e5111
 struct virQEMUCapsPropTypeObjects {
3e5111
@@ -2767,6 +2799,11 @@ virQEMUCapsProbeQMPObjects(virQEMUCapsPtr qemuCaps,
3e5111
 
3e5111
     for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsObjectProps); i++) {
3e5111
         const char *type = virQEMUCapsObjectProps[i].type;
3e5111
+        int cap = virQEMUCapsObjectProps[i].capsCondition;
3e5111
+
3e5111
+        if (cap >= 0 && !virQEMUCapsGet(qemuCaps, cap))
3e5111
+            continue;
3e5111
+
3e5111
         if ((nvalues = qemuMonitorGetObjectProps(mon,
3e5111
                                                  type,
3e5111
                                                  &values)) < 0)
3e5111
-- 
3e5111
2.13.0
3e5111