render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c1c534
From 01e432517f0a44054a5317cea7f8a1171a3b10c7 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <01e432517f0a44054a5317cea7f8a1171a3b10c7@dist-git>
6d3351
From: Jiri Denemark <jdenemar@redhat.com>
6d3351
Date: Fri, 27 Mar 2015 12:48:40 +0100
6d3351
Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs
6d3351
6d3351
RHEL-only
6d3351
6d3351
Upstream tried to solve the change of Broadwell and Haswell CPUs by
6d3351
removing rtm and hle features from the corresponding CPU models for new
6d3351
machine types. Then they reverted this and introduced new *-noTSX models
6d3351
instead. However, the original fix was backported to RHEL.
6d3351
6d3351
This patch makes sure Broadwell and Haswell will always contain rtm and
6d3351
hle features regardless on RHEL version or machine type used.
6d3351
6d3351
https://bugzilla.redhat.com/show_bug.cgi?id=1199446
6d3351
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
c1c534
 src/qemu/qemu_command.c                            | 29 ++++++++++++++++++++++
c1c534
 .../qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args |  2 +-
c1c534
 .../qemuxml2argv-cpu-host-model-cmt.args           |  3 ++-
c1c534
 .../qemuxml2argv-cpu-tsc-frequency.args            |  2 +-
c1c534
 .../qemuxml2argv-q35-acpi-nouefi.args              |  2 +-
c1c534
 .../qemuxml2argv-q35-acpi-uefi.args                |  2 +-
c1c534
 .../qemuxml2argv-q35-noacpi-nouefi.args            |  2 +-
c1c534
 7 files changed, 36 insertions(+), 6 deletions(-)
6d3351
6d3351
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c1c534
index b1cfafa790..365555ca87 100644
6d3351
--- a/src/qemu/qemu_command.c
6d3351
+++ b/src/qemu/qemu_command.c
c1c534
@@ -6857,6 +6857,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
6d3351
     size_t i;
6d3351
     virCapsPtr caps = NULL;
6d3351
     virCPUDefPtr cpu = def->cpu;
6d3351
+    bool hle = false;
6d3351
+    bool rtm = false;
6d3351
 
6d3351
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
6d3351
         goto cleanup;
c1c534
@@ -6911,6 +6913,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
6d3351
         virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id);
6d3351
 
6d3351
     for (i = 0; i < cpu->nfeatures; i++) {
6d3351
+        if (STREQ("rtm", cpu->features[i].name))
6d3351
+            rtm = true;
6d3351
+        if (STREQ("hle", cpu->features[i].name))
6d3351
+            hle = true;
6d3351
+
6d3351
         switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
6d3351
         case VIR_CPU_FEATURE_FORCE:
6d3351
         case VIR_CPU_FEATURE_REQUIRE:
c1c534
@@ -6934,6 +6941,28 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
6d3351
         }
6d3351
     }
6d3351
 
6d3351
+    /* Some versions of qemu-kvm in RHEL provide Broadwell and Haswell CPU
6d3351
+     * models which lack rtm and hle features when used with some machine
6d3351
+     * types. Let's make sure Broadwell and Haswell will always have these
6d3351
+     * features. But only if the features were not explicitly mentioned in
6d3351
+     * the guest CPU definition.
6d3351
+     */
6d3351
+    if (STREQ_NULLABLE(cpu->model, "Broadwell") ||
6d3351
+        STREQ_NULLABLE(cpu->model, "Haswell")) {
c1c534
+        if (!rtm) {
c1c534
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
c1c534
+                virBufferAddLit(buf, ",rtm=on");
c1c534
+            else
c1c534
+                virBufferAddLit(buf, ",+rtm");
c1c534
+        }
c1c534
+        if (!hle) {
c1c534
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
c1c534
+                virBufferAddLit(buf, ",hle=on");
c1c534
+            else
c1c534
+                virBufferAddLit(buf, ",+hle");
c1c534
+        }
6d3351
+    }
6d3351
+
6d3351
     ret = 0;
6d3351
  cleanup:
6d3351
     virObjectUnref(caps);
6d3351
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
c1c534
index 06c9eed5b9..553b91c83b 100644
6d3351
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
6d3351
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
6d3351
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
6d3351
 -name QEMUGuest1 \
6d3351
 -S \
6d3351
 -M pc \
6d3351
--cpu Haswell \
6d3351
+-cpu Haswell,+rtm,+hle \
6d3351
 -m 214 \
6d3351
 -smp 6,sockets=6,cores=1,threads=1 \
6d3351
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
6d3351
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
c1c534
index ef45d98300..28cdf92782 100644
6d3351
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
6d3351
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
6d3351
@@ -9,7 +9,8 @@ QEMU_AUDIO_DRV=none \
6d3351
 -S \
6d3351
 -M pc \
6d3351
 -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
6d3351
-+smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm \
6d3351
++smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+rtm,\
6d3351
++hle \
6d3351
 -m 214 \
6d3351
 -smp 6,sockets=6,cores=1,threads=1 \
6d3351
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
6d3351
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args
c1c534
index 3e2da0f242..53193c6fe2 100644
6d3351
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args
6d3351
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args
6d3351
@@ -10,7 +10,7 @@ QEMU_AUDIO_DRV=none \
6d3351
 -M pc \
6d3351
 -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
6d3351
 +smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,\
6d3351
-+invtsc,tsc-frequency=3504000000 \
6d3351
++invtsc,+rtm,+hle,tsc-frequency=3504000000 \
6d3351
 -m 214 \
6d3351
 -smp 1,sockets=1,cores=1,threads=1 \
6d3351
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
c1c534
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
c1c534
index 503045de6b..5e1d3b4eb0 100644
c1c534
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
c1c534
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-nouefi.args
c1c534
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
c1c534
 -name guest \
c1c534
 -S \
c1c534
 -M q35 \
c1c534
--cpu Haswell \
c1c534
+-cpu Haswell,+rtm,+hle \
c1c534
 -m 1024 \
c1c534
 -smp 1,sockets=1,cores=1,threads=1 \
c1c534
 -uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
c1c534
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
c1c534
index fbbbcf9812..40214c69e8 100644
c1c534
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
c1c534
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-acpi-uefi.args
c1c534
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
c1c534
 -name guest \
c1c534
 -S \
c1c534
 -M q35 \
c1c534
--cpu Haswell \
c1c534
+-cpu Haswell,+rtm,+hle \
c1c534
 -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,\
c1c534
 readonly=on \
c1c534
 -drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,\
c1c534
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
c1c534
index de2a7f30bc..1be5968e02 100644
c1c534
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
c1c534
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-noacpi-nouefi.args
c1c534
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
c1c534
 -name guest \
c1c534
 -S \
c1c534
 -M q35 \
c1c534
--cpu Haswell \
c1c534
+-cpu Haswell,+rtm,+hle \
c1c534
 -m 1024 \
c1c534
 -smp 1,sockets=1,cores=1,threads=1 \
c1c534
 -uuid 496d7ea8-9739-544b-4ebd-ef08be936e8b \
6d3351
-- 
c1c534
2.14.3
6d3351