[PATCH 2/8] virQEMUCapsProbeQMPDeviceProperties: Switch to local implementation

Peter Krempa pkrempa at redhat.com
Thu May 7 05:57:57 UTC 2020


Reimplement device property detection directly rather than using
virQEMUCapsProbeQMPGenericProps in preparation for changes to the
detection code.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_capabilities.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index dadbef32a2..5e72dead45 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2610,11 +2610,27 @@ static int
 virQEMUCapsProbeQMPDeviceProperties(virQEMUCapsPtr qemuCaps,
                                     qemuMonitorPtr mon)
 {
-    return virQEMUCapsProbeQMPGenericProps(qemuCaps,
-                                           mon,
-                                           virQEMUCapsDeviceProps,
-                                           G_N_ELEMENTS(virQEMUCapsDeviceProps),
-                                           qemuMonitorGetDeviceProps);
+    size_t i;
+
+    for (i = 0; i < G_N_ELEMENTS(virQEMUCapsDeviceProps); i++) {
+        virQEMUCapsObjectTypeProps *device = virQEMUCapsDeviceProps + i;
+        VIR_AUTOSTRINGLIST values = NULL;
+        int nvalues;
+
+        if (device->capsCondition >= 0 &&
+            !virQEMUCapsGet(qemuCaps, device->capsCondition))
+            continue;
+
+        if ((nvalues = qemuMonitorGetDeviceProps(mon, device->type, &values)) < 0)
+            return -1;
+
+        virQEMUCapsProcessStringFlags(qemuCaps,
+                                      device->nprops,
+                                      device->props,
+                                      nvalues, values);
+    }
+
+    return 0;
 }


-- 
2.26.2




More information about the libvir-list mailing list