Most of the code moved to a new virQEMUCapsFetchCPUDefinitions function and the existing virQEMUCapsFetchCPUModels just becomes a small wrapper around virQEMUCapsFetchCPUDefinitions and virQEMUCapsCPUDefsToModels. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx> --- Notes: Version 2: - new patch Version 3: - g_autoptr, g_steal_pointer src/qemu/qemu_capabilities.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index dfffc45d1d..431841e61e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2471,15 +2471,15 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps, } -int -virQEMUCapsFetchCPUModels(qemuMonitorPtr mon, - virArch arch, - virDomainCapsCPUModelsPtr *cpuModels) +static int +virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon, + virArch arch, + qemuMonitorCPUDefsPtr *cpuDefs) { g_autoptr(qemuMonitorCPUDefs) defs = NULL; size_t i; - *cpuModels = NULL; + *cpuDefs = NULL; if (qemuMonitorGetCPUDefinitions(mon, &defs) < 0) return -1; @@ -2507,7 +2507,24 @@ virQEMUCapsFetchCPUModels(qemuMonitorPtr mon, } } - if (!(*cpuModels = virQEMUCapsCPUDefsToModels(defs, NULL, NULL))) + *cpuDefs = g_steal_pointer(&defs); + return 0; +} + + +int +virQEMUCapsFetchCPUModels(qemuMonitorPtr mon, + virArch arch, + virDomainCapsCPUModelsPtr *cpuModels) +{ + g_autoptr(qemuMonitorCPUDefs) defs = NULL; + + *cpuModels = NULL; + + if (virQEMUCapsFetchCPUDefinitions(mon, arch, &defs) < 0) + return -1; + + if (defs && !(*cpuModels = virQEMUCapsCPUDefsToModels(defs, NULL, NULL))) return -1; return 0; -- 2.23.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list