From f3f9d8e37662f67a0f611c697ab6b359b9adb252 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Thu, 16 May 2019 10:18:58 +0200 Subject: [PATCH] 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 Reviewed-by: Pavel Hrdina --- src/qemu/qemu_capabilities.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5aa337c40c..89bedd7dc0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -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; -- 2.39.5