79b470
From 961deedc28962b55c37430f974016aced31e1120 Mon Sep 17 00:00:00 2001
79b470
Message-Id: <961deedc28962b55c37430f974016aced31e1120@dist-git>
79b470
From: Collin Walling <walling@linux.ibm.com>
79b470
Date: Fri, 2 Oct 2020 10:13:11 +0200
79b470
Subject: [PATCH] qemu: substitute missing model name for host-passthrough
79b470
79b470
Before:
79b470
  $ uname -m
79b470
  s390x
79b470
  $ cat passthrough-cpu.xml
79b470
  <cpu check="none" mode="host-passthrough" />
79b470
  $ virsh hypervisor-cpu-compare passthrough-cpu.xml
79b470
  error: Failed to compare hypervisor CPU with passthrough-cpu.xml
79b470
  error: internal error: unable to execute QEMU command 'query-cpu-model-comp
79b470
  arison': Invalid parameter type for 'modelb.name', expected: string
79b470
79b470
After:
79b470
  $ virsh hypervisor-cpu-compare passthrough-cpu.xml
79b470
  CPU described in passthrough-cpu.xml is identical to the CPU provided by hy
79b470
  pervisor on the host
79b470
79b470
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
79b470
Signed-off-by: Collin Walling <walling@linux.ibm.com>
79b470
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
79b470
(cherry picked from commit 9c6996124f4ef1635fbfe47090dadaf5a12b42e9)
79b470
79b470
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1850680
79b470
79b470
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
79b470
Message-Id: <20201002081311.449901-2-twiederh@redhat.com>
79b470
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
79b470
---
79b470
 src/qemu/qemu_driver.c | 9 +++++++++
79b470
 1 file changed, 9 insertions(+)
79b470
79b470
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
79b470
index b5df0c63d4..f8a259e020 100644
79b470
--- a/src/qemu/qemu_driver.c
79b470
+++ b/src/qemu/qemu_driver.c
79b470
@@ -13539,6 +13539,15 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
79b470
         if (virCPUDefParseXMLString(xmlCPU, VIR_CPU_TYPE_AUTO, &cpu) < 0)
79b470
             goto cleanup;
79b470
 
79b470
+        if (!cpu->model) {
79b470
+            if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) {
79b470
+                cpu->model = g_strdup("host");
79b470
+            } else {
79b470
+                virReportError(VIR_ERR_INVALID_ARG, "%s",
79b470
+                               _("cpu parameter is missing a model name"));
79b470
+                goto cleanup;
79b470
+            }
79b470
+        }
79b470
         ret = qemuConnectCPUModelComparison(qemuCaps, cfg->libDir,
79b470
                                             cfg->user, cfg->group,
79b470
                                             hvCPU, cpu, failIncompatible);
79b470
-- 
79b470
2.28.0
79b470