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(a)redhat.com>
---
Notes:
Version 2:
- new patch
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 cdc3a2d4b0..436d65f578 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2487,15 +2487,15 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
}
-int
-virQEMUCapsFetchCPUModels(qemuMonitorPtr mon,
- virArch arch,
- virDomainCapsCPUModelsPtr *cpuModels)
+static int
+virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon,
+ virArch arch,
+ qemuMonitorCPUDefsPtr *cpuDefs)
{
VIR_AUTOPTR(qemuMonitorCPUDefs) defs = NULL;
size_t i;
- *cpuModels = NULL;
+ *cpuDefs = NULL;
if (qemuMonitorGetCPUDefinitions(mon, &defs) < 0)
return -1;
@@ -2524,7 +2524,24 @@ virQEMUCapsFetchCPUModels(qemuMonitorPtr mon,
}
}
- if (!(*cpuModels = virQEMUCapsCPUDefsToModels(defs, NULL, NULL)))
+ VIR_STEAL_PTR(*cpuDefs, defs);
+ return 0;
+}
+
+
+int
+virQEMUCapsFetchCPUModels(qemuMonitorPtr mon,
+ virArch arch,
+ virDomainCapsCPUModelsPtr *cpuModels)
+{
+ VIR_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