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

index f4c9e67d1656d7261c00653e8e4f731870c44f63..c0eef0eb974304c5783bf3960374d844cc3128c0 100644 (file)
@@ -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;