From: Collin Walling Date: Fri, 25 Sep 2020 00:22:37 +0000 (-0400) Subject: qemu: report error if missing model name when baselining X-Git-Tag: v6.10.0-rc1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2df0b488aa3cf24c722e3734e653009135adde4;p=thirdparty%2Flibvirt.git qemu: report error if missing model name when baselining When executing the hypervisor-cpu-baseline command and the XML file contains a CPU definition without a model name, or an invalid CPU definition, then the commands will fail and return an error message from the QMP response. Let's clean this up by checking for a valid definition and presence of a model name. This code is copied from virCPUBaseline. Signed-off-by: Collin Walling Reviewed-by: Jiri Denemark --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f4c9e67d16..c0eef0eb97 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12424,6 +12424,19 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps, qemuMonitorCPUModelInfoPtr result = NULL; size_t i; + for (i = 0; i < ncpus; i++) { + if (!cpus[i]) { + virReportError(VIR_ERR_INVALID_ARG, + _("invalid CPU definition at index %zu"), i); + return NULL; + } + if (!cpus[i]->model) { + virReportError(VIR_ERR_INVALID_ARG, + _("no CPU model specified at index %zu"), i); + return NULL; + } + } + if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps), libDir, runUid, runGid, false))) return NULL;