Blob Blame History Raw
From 894b1e28647f0fd46da3ffc64afc358d438153f9 Mon Sep 17 00:00:00 2001
Message-Id: <894b1e28647f0fd46da3ffc64afc358d438153f9@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:04 +0200
Subject: [PATCH] qemu_process: Prefer generic qemuMonitorGetGuestCPU
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When updating guest CPU definition according to the vCPU actually
created by QEMU, we want to use the generic qemuMonitorGetGuestCPU to
get both CPUID and MSR features.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 63acb7bfd56f117309e4fcaf438639d4d7bc7dcb)

https://bugzilla.redhat.com/show_bug.cgi?id=1697627

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <711a363fde6df79fe9a26b6b4cb0a185cc5ad3cb.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_process.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 59a739f262..d147e524ee 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4013,6 +4013,16 @@ qemuProcessVerifyCPUFeatures(virDomainDefPtr def,
 }
 
 
+static const char *
+qemuProcessTranslateCPUFeatures(const char *name,
+                                void *opaque)
+{
+    virQEMUCapsPtr qemuCaps = opaque;
+
+    return virQEMUCapsCPUFeatureFromQEMU(qemuCaps, name);
+}
+
+
 static int
 qemuProcessFetchGuestCPU(virQEMUDriverPtr driver,
                          virDomainObjPtr vm,
@@ -4023,18 +4033,28 @@ qemuProcessFetchGuestCPU(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     virCPUDataPtr dataEnabled = NULL;
     virCPUDataPtr dataDisabled = NULL;
+    bool generic;
     int rc;
 
     *enabled = NULL;
     *disabled = NULL;
 
-    if (!ARCH_IS_X86(vm->def->os.arch))
+    generic = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CPU_UNAVAILABLE_FEATURES);
+
+    if (!generic && !ARCH_IS_X86(vm->def->os.arch))
         return 0;
 
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
         goto error;
 
-    rc = qemuMonitorGetGuestCPUx86(priv->mon, &dataEnabled, &dataDisabled);
+    if (generic) {
+        rc = qemuMonitorGetGuestCPU(priv->mon,
+                                    vm->def->os.arch,
+                                    qemuProcessTranslateCPUFeatures, priv->qemuCaps,
+                                    &dataEnabled, &dataDisabled);
+    } else {
+        rc = qemuMonitorGetGuestCPUx86(priv->mon, &dataEnabled, &dataDisabled);
+    }
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto error;
-- 
2.22.0