render / rpms / libvirt

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