d759b5
From 6244ce5a6ff5121fff9aaffe1689912955af6372 Mon Sep 17 00:00:00 2001
d759b5
Message-Id: <6244ce5a6ff5121fff9aaffe1689912955af6372@dist-git>
43f536
From: Jiri Denemark <jdenemar@redhat.com>
d759b5
Date: Fri, 29 Nov 2019 19:14:36 +0100
43f536
Subject: [PATCH] RHEL: qemu: Enable virt-ssbd for host-model with old QEMU
43f536
43f536
RHEL-only hack for qemu-kvm-1.5.3-*
43f536
43f536
RHEL version of QEMU in contrast to qemu-kvm-rhev does not support
43f536
reporting what CPU features can be enabled on current host and thus we
43f536
have no idea whether virt-ssbd can be enabled or not. We will just
43f536
blindly enable it when starting a domain with host-model CPU on old
43f536
QEMU, detect whether it was actually enabled once QEMU starts and update
43f536
the live XML accordingly.
43f536
43f536
We just need to make sure qemu-kvm is new enough (at least 1.5.3-158) to
43f536
support virt-ssbd otherwise QEMU would fail to start complaining about
43f536
unknown feature. Luckily, such qemu-kvm was already present in RHEL-7.6.
43f536
43f536
https://bugzilla.redhat.com/show_bug.cgi?id=1745181
43f536
43f536
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43f536
Message-Id: <ed6ce8fd56f059d856fed2774a3186882af3cf06.1575051264.git.jdenemar@redhat.com>
43f536
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
43f536
---
43f536
 libvirt.spec.in         |  1 +
43f536
 src/qemu/qemu_process.c | 14 ++++++++++++++
43f536
 2 files changed, 15 insertions(+)
43f536
43f536
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
d759b5
index 4a2864af27..0add197af5 100644
43f536
--- a/src/qemu/qemu_process.c
43f536
+++ b/src/qemu/qemu_process.c
d759b5
@@ -5780,6 +5780,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
43f536
                           unsigned int flags)
43f536
 {
43f536
     int ret = -1;
43f536
+    bool host_model = false;
43f536
 
43f536
     if (!def->cpu)
43f536
         return 0;
d759b5
@@ -5826,6 +5827,8 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
43f536
                       def->cpu, true) < 0)
43f536
         return -1;
43f536
 
43f536
+    host_model = def->cpu->mode == VIR_CPU_MODE_HOST_MODEL;
43f536
+
43f536
     if (virCPUUpdate(def->os.arch, def->cpu,
43f536
                      virQEMUCapsGetHostModel(qemuCaps, def->virtType,
43f536
                                              VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE)) < 0)
d759b5
@@ -5835,6 +5838,17 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
43f536
                         virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType)) < 0)
43f536
         goto cleanup;
43f536
 
43f536
+    if (host_model &&
43f536
+        ARCH_IS_X86(def->os.arch) &&
43f536
+        caps->host.cpu &&
43f536
+        STREQ_NULLABLE(caps->host.cpu->vendor, "AMD")) {
43f536
+        virCPUDefPtr hostCPU;
43f536
+        hostCPU = virQEMUCapsGetHostModel(qemuCaps, def->virtType,
43f536
+                                         VIR_QEMU_CAPS_HOST_CPU_REPORTED);
43f536
+        if (hostCPU->fallback == VIR_CPU_FALLBACK_ALLOW)
43f536
+            virCPUDefUpdateFeature(def->cpu, "virt-ssbd", VIR_CPU_FEATURE_REQUIRE);
43f536
+    }
43f536
+
43f536
     def->cpu->fallback = VIR_CPU_FALLBACK_FORBID;
43f536
     ret = 0;
43f536
 
43f536
-- 
d759b5
2.24.0
43f536