qemu: Don't query unavailable-features if qom-list-get is supported

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>
This commit is contained in:
Jiri Denemark committed 2025-09-08 15:32:48 +02:00
1 parent e18bc30236
commit d05443820e
3 files changed
+27 -42

No files matched your search

+27 -5
View 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;
}
@@ -2960,26 +2960,3 @@
],
"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"
}
@@ -2951,17 +2951,3 @@
],
"id": "libvirt-1"
}
{
"execute": "qom-get",
"arguments": {
"path": "/machine/unattached/device[0]",
"property": "unavailable-features"
},
"id": "libvirt-2"
}
{
"return": [],
"id": "libvirt-2"
}