]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Add -machine suffix automatically
authorAndrea Bolognani <abologna@redhat.com>
Thu, 16 May 2019 08:18:58 +0000 (10:18 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 17 May 2019 12:59:31 +0000 (14:59 +0200)
The QOM type for machine types is the machine type name
followed by the -machine suffix. Since this is always the
case, we can make virQEMUCapsMachineProps more readable
and avoid repetition by not including the suffix there and
adding it automatically while processing the data; moreover,
when later on we will start figuring out which specific
versioned machine type to probe at runtime instead of doing
so statically, adding the suffix dynamically will become
necessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_capabilities.c

index 5aa337c40c60e3774752c936df9c14b647e81189..89bedd7dc03dba9aaf43b2d7548115ba7478e396 100644 (file)
@@ -1407,7 +1407,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsSPAPR[] = {
 };
 
 static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
-    { "spapr-machine", virQEMUCapsMachinePropsSPAPR,
+    { "spapr", virQEMUCapsMachinePropsSPAPR,
       ARRAY_CARDINALITY(virQEMUCapsMachinePropsSPAPR),
       -1 },
 };
@@ -2357,7 +2357,12 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
 
     for (i = 0; i < ARRAY_CARDINALITY(virQEMUCapsMachineProps); i++) {
         virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
-        const char *type = props.type;
+        VIR_AUTOFREE(char *) type = NULL;
+
+        /* The QOM type for machine types is the machine type name
+         * followed by the -machine suffix */
+        if (virAsprintf(&type, "%s-machine", props.type) < 0)
+            return -1;
 
         if ((nvalues = qemuMonitorGetObjectProps(mon, type, &values)) < 0)
             return -1;