]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: substitute missing model name for host-passthrough
authorCollin Walling <walling@linux.ibm.com>
Wed, 23 Sep 2020 07:26:58 +0000 (09:26 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 23 Sep 2020 19:20:06 +0000 (21:20 +0200)
Before:
  $ uname -m
  s390x
  $ cat passthrough-cpu.xml
  <cpu check="none" mode="host-passthrough" />
  $ virsh hypervisor-cpu-compare passthrough-cpu.xml
  error: Failed to compare hypervisor CPU with passthrough-cpu.xml
  error: internal error: unable to execute QEMU command 'query-cpu-model-comp
  arison': Invalid parameter type for 'modelb.name', expected: string

After:
  $ virsh hypervisor-cpu-compare passthrough-cpu.xml
  CPU described in passthrough-cpu.xml is identical to the CPU provided by hy
  pervisor on the host

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_driver.c

index ae715c01d71862a3154b035c8d01f82e06268d40..1cecef01f71571d5f1c2b70a08db9325b1c6d153 100644 (file)
@@ -12336,6 +12336,15 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
         if (virCPUDefParseXMLString(xmlCPU, VIR_CPU_TYPE_AUTO, &cpu) < 0)
             goto cleanup;
 
+        if (!cpu->model) {
+            if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) {
+                cpu->model = g_strdup("host");
+            } else {
+                virReportError(VIR_ERR_INVALID_ARG, "%s",
+                               _("cpu parameter is missing a model name"));
+                goto cleanup;
+            }
+        }
         ret = qemuConnectCPUModelComparison(qemuCaps, cfg->libDir,
                                             cfg->user, cfg->group,
                                             hvCPU, cpu, failIncompatible);