When executing the hypervisor-cpu-baseline command and if there is only
a single CPU definition present in the XML file, then libvirt will
print an unhelpful message:
"error: An error occurred, but the cause is unknown"
This is due to no CPU definition ever being "baselined", since the
API expects at least two CPU models.
Let's fix this by performing a CPU model expansion on the single CPU
definition and returning the result to the caller.
Signed-off-by: Collin Walling <walling(a)linux.ibm.com>
---
src/qemu/qemu_driver.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 427d2419f3..97a960a769 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12472,6 +12472,7 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps,
g_autoptr(qemuProcessQMP) proc = NULL;
g_autoptr(virCPUDef) baseline = NULL;
qemuMonitorCPUModelInfoPtr result = NULL;
+ qemuMonitorCPUModelExpansionType expansion_type;
size_t i;
if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps),
@@ -12503,15 +12504,15 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps,
return NULL;
}
- if (expand_features) {
- if (qemuMonitorGetCPUModelExpansion(proc->mon,
- QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
- baseline, true, false, &result) < 0)
- return NULL;
+ expansion_type = expand_features ? QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL
+ : QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC;
- if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
- return NULL;
- }
+ if (qemuMonitorGetCPUModelExpansion(proc->mon, expansion_type,
+ baseline, true, false, &result) < 0)
+ return NULL;
+
+ if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
+ return NULL;
return g_steal_pointer(&baseline);
}
--
2.26.2