]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: check if cpu model is supported before baselining
authorCollin Walling <walling@linux.ibm.com>
Fri, 25 Sep 2020 00:22:38 +0000 (20:22 -0400)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 24 Nov 2020 20:04:07 +0000 (21:04 +0100)
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 <walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_driver.c

index c0eef0eb974304c5783bf3960374d844cc3128c0..5f2f267fb4c1f9f653dd57c4ce9f7060972d5f36 100644 (file)
@@ -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,