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