From 85ac61a95b3817ffcb653856f40b7c4ee86c876e Mon Sep 17 00:00:00 2001
Message-Id: <85ac61a95b3817ffcb653856f40b7c4ee86c876e@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Mon, 6 Jan 2020 16:43:40 +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>
(cherry picked from commit 6244ce5a6ff5121fff9aaffe1689912955af6372)
https://bugzilla.redhat.com/show_bug.cgi?id=1787556
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <0ac3b5185c3a0aa514742752c84fae8d23c5e2c8.1578325371.git.jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@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 307098cd63..b8b12491a3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5776,6 +5776,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
unsigned int flags)
{
int ret = -1;
+ bool host_model = false;
if (!def->cpu)
return 0;
@@ -5822,6 +5823,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)
@@ -5831,6 +5834,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.1