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