qemu: Add -machine suffix automatically

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>
This commit is contained in:
Andrea Bolognani 2019-05-16 10:18:58 +02:00
parent 295a42e19f
commit f3f9d8e376
1 changed files with 7 additions and 2 deletions

View 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;