From: Collin Walling Date: Fri, 25 Sep 2020 00:22:38 +0000 (-0400) Subject: qemu: check if cpu model is supported before baselining X-Git-Tag: v6.10.0-rc1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5ed1fdee234788c28d1c1b156f2a2b4498f17e4;p=thirdparty%2Flibvirt.git qemu: check if cpu model is supported before baselining Check the provided CPU models against the CPU models known by the hypervisor before baselining and print an error if an unrecognized model is found. Signed-off-by: Collin Walling Reviewed-by: Jiri Denemark --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c0eef0eb97..5f2f267fb4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12417,7 +12417,8 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps, gid_t runGid, bool expand_features, virCPUDefPtr *cpus, - int ncpus) + int ncpus, + virDomainCapsCPUModelsPtr cpuModels) { g_autoptr(qemuProcessQMP) proc = NULL; g_autoptr(virCPUDef) baseline = NULL; @@ -12435,6 +12436,13 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps, _("no CPU model specified at index %zu"), i); return NULL; } + + if (!virDomainCapsCPUModelsGet(cpuModels, cpus[i]->model)) { + virReportError(VIR_ERR_INVALID_ARG, + _("CPU model '%s' not supported by hypervisor"), + cpus[i]->model); + return NULL; + } } if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps), @@ -12545,7 +12553,8 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, if (!(cpu = qemuConnectCPUModelBaseline(qemuCaps, cfg->libDir, cfg->user, cfg->group, - expand_features, cpus, ncpus))) + expand_features, cpus, ncpus, + cpuModels))) goto cleanup; } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED,