[PATCH v2 4/5] qemu: check if cpu model is supported before baselining

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1c5b1dcfee..fe572b13e1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12453,12 +12453,13 @@ 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;
     qemuMonitorCPUModelInfoPtr result = NULL;
-    size_t i;
+    size_t i, j;
 
     for (i = 0; i < ncpus; i++) {
         if (!cpus[i]) {
@@ -12471,6 +12472,16 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps,
                            _("no CPU model specified at index %zu"), i);
             return NULL;
         }
+        for (j = 0; j < cpuModels->nmodels; j++) {
+            if (STREQ(cpus[i]->model, cpuModels->models[j].name))
+                break;
+        }
+        if (j == cpuModels->nmodels) {
+            virReportError(VIR_ERR_INVALID_ARG,
+                           _("CPU model '%s' not supported by hypervisor"),
+                           cpus[i]->model);
+            return NULL;
+        }
     }
 
     if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps),
@@ -12582,7 +12593,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,
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux