]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Don't query unavailable-features if qom-list-get is supported
authorJiri Denemark <jdenemar@redhat.com>
Thu, 4 Sep 2025 13:49:01 +0000 (15:49 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 8 Sep 2025 13:32:48 +0000 (15:32 +0200)
With qom-list-get we already have the value of unavailable-features
property in the returned object (just like we have all values of all
bool properties). Let's use the value from there instead of querying for
it separately using qom-get.

After this patch only a single QMP command is used for getting all the
required info about guest CPUs created by QEMU 10.1 or newer.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor_json.c
tests/qemumonitorjsondata/get-guest-cpu-SierraForest.json
tests/qemumonitorjsondata/get-guest-cpu-SkylakeClient.json

index c139edaf158a6424797c2f0dab4295ae199f3e8b..2c8ae5198cdfcfaaaf485ea3b4ef0ed8d51d5e4c 100644 (file)
@@ -6598,6 +6598,7 @@ struct _qemuMonitorJSONCPUPropsFilterData {
     qemuMonitor *mon;
     bool values;
     const char *cpuQOMPath;
+    virJSONValue *unavailableFeatures;
 };
 
 static int
@@ -6607,8 +6608,22 @@ qemuMonitorJSONCPUPropsFilter(const char *name,
 {
     struct _qemuMonitorJSONCPUPropsFilterData *data = opaque;
     bool enabled = false;
+    const char *type = virJSONValueObjectGetString(propData, "type");
 
-    if (STRNEQ_NULLABLE(virJSONValueObjectGetString(propData, "type"), "bool"))
+    if (data->values &&
+        STREQ(name, "unavailable-features") &&
+        STREQ_NULLABLE(type, "strList")) {
+        data->unavailableFeatures = virJSONValueObjectGetArray(propData, "value");
+        if (!data->unavailableFeatures) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("property '%1$s' in reply data was missing value"),
+                           name);
+            return -1;
+        }
+        return 1;
+    }
+
+    if (STRNEQ_NULLABLE(type, "bool"))
         return 1;
 
     if (data->values) {
@@ -6651,6 +6666,7 @@ qemuMonitorJSONGetCPUProperties(qemuMonitor *mon,
         .mon = mon,
         .values = qomListGet,
         .cpuQOMPath = cpuQOMPath,
+        .unavailableFeatures = NULL,
     };
 
     *propsEnabled = NULL;
@@ -6703,10 +6719,16 @@ qemuMonitorJSONGetCPUProperties(qemuMonitor *mon,
                                       &filterData, propsEnabled) < 0)
         return -1;
 
-    if (qemuMonitorJSONGetStringListProperty(mon, cpuQOMPath,
-                                             "unavailable-features",
-                                             propsDisabled) < 0)
-        return -1;
+    if (filterData.unavailableFeatures) {
+        *propsDisabled = virJSONValueArrayToStringList(filterData.unavailableFeatures);
+        if (!*propsDisabled)
+            return -1;
+    } else {
+        if (qemuMonitorJSONGetStringListProperty(mon, cpuQOMPath,
+                                                 "unavailable-features",
+                                                 propsDisabled) < 0)
+            return -1;
+    }
 
     return 0;
 }
index d64ae8453294279d0a187174e80a201fe0e1d737..f5c41cf9b687414f4889e4480d1467400d7d44ae 100644 (file)
   ],
   "id": "libvirt-1"
 }
-
-{
-  "execute": "qom-get",
-  "arguments": {
-    "path": "/machine/unattached/device[0]",
-    "property": "unavailable-features"
-  },
-  "id": "libvirt-2"
-}
-
-{
-  "return": [
-    "bus-lock-detect",
-    "cmpccxadd",
-    "avx-ifma",
-    "wbnoinvd",
-    "pbrsb-no",
-    "avx-vnni-int8",
-    "avx-ne-convert",
-    "mcdt-no"
-  ],
-  "id": "libvirt-2"
-}
index 76b66ded20a1bfdbec9d3eb22d88279225b740ad..b5bea8fd61a25283613381cd8b2f8cc7fe693b89 100644 (file)
   ],
   "id": "libvirt-1"
 }
-
-{
-  "execute": "qom-get",
-  "arguments": {
-    "path": "/machine/unattached/device[0]",
-    "property": "unavailable-features"
-  },
-  "id": "libvirt-2"
-}
-
-{
-  "return": [],
-  "id": "libvirt-2"
-}