Up until now we've probed machine type properties, along with
properties for other types, in virQEMUCapsProbeQMPDevices(), but
soon we're going to need some logic that is specific to machine
types and as such wouldn't quite fit into that function.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 52 ++++++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a0b2ca73fb..66745ab4e2 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1391,12 +1391,6 @@ static struct virQEMUCapsStringFlags
virQEMUCapsObjectPropsMemoryBackendMemfd[]
{ "hugetlb", QEMU_CAPS_OBJECT_MEMORY_MEMFD_HUGETLB },
};
-static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsSPAPRMachine[] = {
- { "cap-hpt-max-page-size", QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE
},
- { "cap-htm", QEMU_CAPS_MACHINE_PSERIES_CAP_HTM },
- { "cap-nested-hv", QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV },
-};
-
static virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
{ "memory-backend-file", virQEMUCapsObjectPropsMemoryBackendFile,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendFile),
@@ -1404,8 +1398,17 @@ static virQEMUCapsObjectTypeProps virQEMUCapsObjectProps[] = {
{ "memory-backend-memfd", virQEMUCapsObjectPropsMemoryBackendMemfd,
ARRAY_CARDINALITY(virQEMUCapsObjectPropsMemoryBackendMemfd),
QEMU_CAPS_OBJECT_MEMORY_MEMFD },
- { "spapr-machine", virQEMUCapsObjectPropsSPAPRMachine,
- ARRAY_CARDINALITY(virQEMUCapsObjectPropsSPAPRMachine),
+};
+
+static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsSPAPR[] = {
+ { "cap-hpt-max-page-size", QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE
},
+ { "cap-htm", QEMU_CAPS_MACHINE_PSERIES_CAP_HTM },
+ { "cap-nested-hv", QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV },
+};
+
+static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
+ { "spapr-machine", virQEMUCapsMachinePropsSPAPR,
+ ARRAY_CARDINALITY(virQEMUCapsMachinePropsSPAPR),
-1 },
};
@@ -2341,6 +2344,37 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
}
+static int
+virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
+ qemuMonitorPtr mon)
+{
+ char **values;
+ int nvalues;
+ size_t i;
+
+ /* We need qom-list-properties for this to work */
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES))
+ return 0;
+
+ for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsMachineProps); i++) {
+ virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
+ const char *type = props.type;
+
+ if ((nvalues = qemuMonitorGetObjectProps(mon, type, &values)) < 0)
+ return -1;
+
+ virQEMUCapsProcessStringFlags(qemuCaps,
+ props.nprops,
+ props.props,
+ nvalues, values);
+
+ virStringListFreeCount(values, nvalues);
+ }
+
+ return 0;
+}
+
+
virDomainCapsCPUModelsPtr
virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
{
@@ -4355,6 +4389,8 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
return -1;
if (virQEMUCapsProbeQMPDevices(qemuCaps, mon) < 0)
return -1;
+ if (virQEMUCapsProbeQMPMachineProps(qemuCaps, mon) < 0)
+ return -1;
if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, mon) < 0)
return -1;
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, mon, false) < 0)
--
2.21.0