When executing the hypervisor-cpu-compare/baseline commands and the XML file contains a CPU definition using host-passthrough and no model name, the commands will fail and return an error message from the QMP response.
Let's fix this by checking for host-passthrough and a missing model name when converting a CPU definition to a JSON object. If these conditions are matched, then the JSON object will be constructed using "host" as the model name. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1850680 Signed-off-by: Collin Walling <wall...@linux.ibm.com> --- src/qemu/qemu_monitor_json.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3070c1e6b3..448a3a9356 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5804,9 +5804,20 @@ qemuMonitorJSONMakeCPUModel(virCPUDefPtr cpu, { virJSONValuePtr model = virJSONValueNewObject(); virJSONValuePtr props = NULL; + const char *model_name = cpu->model; size_t i; - if (virJSONValueObjectAppendString(model, "name", cpu->model) < 0) + if (!model_name) { + if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) { + model_name = "host"; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cpu parameter is missing a model name")); + goto error; + } + } + + if (virJSONValueObjectAppendString(model, "name", model_name) < 0) goto error; if (cpu->nfeatures || !migratable) { -- 2.26.2