render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 0c42b50b3f2e3cb84d704268fcb267a5b0fabdec Mon Sep 17 00:00:00 2001
Message-Id: <0c42b50b3f2e3cb84d704268fcb267a5b0fabdec@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 27 Mar 2015 12:48:40 +0100
Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs

RHEL-only

Upstream tried to solve the change of Broadwell and Haswell CPUs by
removing rtm and hle features from the corresponding CPU models for new
machine types. Then they reverted this and introduced new *-noTSX models
instead. However, the original fix was backported to RHEL.

This patch makes sure Broadwell and Haswell will always contain rtm and
hle features regardless on RHEL version or machine type used.

https://bugzilla.redhat.com/show_bug.cgi?id=1199446

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_command.c                       | 21 +++++++++++++++++++
 tests/qemuxml2argvdata/cpu-Haswell.args       |  2 +-
 .../qemuxml2argvdata/cpu-host-model-cmt.args  |  2 +-
 .../cpu-translation.x86_64-4.0.0.args         |  2 +-
 .../cpu-translation.x86_64-latest.args        |  2 +-
 tests/qemuxml2argvdata/cpu-tsc-frequency.args |  2 +-
 tests/qemuxml2argvdata/q35-acpi-nouefi.args   |  2 +-
 tests/qemuxml2argvdata/q35-acpi-uefi.args     |  2 +-
 tests/qemuxml2argvdata/q35-noacpi-nouefi.args |  2 +-
 9 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 156af4caee..b37d693c72 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6343,6 +6343,8 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
 {
     size_t i;
     virCPUDef *cpu = def->cpu;
+    bool hle = false;
+    bool rtm = false;
 
     switch ((virCPUMode) cpu->mode) {
     case VIR_CPU_MODE_HOST_PASSTHROUGH:
@@ -6407,6 +6409,11 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
         virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id);
 
     for (i = 0; i < cpu->nfeatures; i++) {
+        if (STREQ("rtm", cpu->features[i].name))
+            rtm = true;
+        if (STREQ("hle", cpu->features[i].name))
+            hle = true;
+
         switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
         case VIR_CPU_FEATURE_FORCE:
         case VIR_CPU_FEATURE_REQUIRE:
@@ -6424,6 +6431,20 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
         }
     }
 
+    /* Some versions of qemu-kvm in RHEL provide Broadwell and Haswell CPU
+     * models which lack rtm and hle features when used with some machine
+     * types. Let's make sure Broadwell and Haswell will always have these
+     * features. But only if the features were not explicitly mentioned in
+     * the guest CPU definition.
+     */
+    if (STREQ_NULLABLE(cpu->model, "Broadwell") ||
+        STREQ_NULLABLE(cpu->model, "Haswell")) {
+        if (!rtm)
+            qemuBuildCpuFeature(qemuCaps, buf, "rtm", true);
+        if (!hle)
+            qemuBuildCpuFeature(qemuCaps, buf, "hle", true);
+    }
+
     return 0;
 }
 
diff --git a/tests/qemuxml2argvdata/cpu-Haswell.args b/tests/qemuxml2argvdata/cpu-Haswell.args
index 8bbd6277fd..55b66b343d 100644
--- a/tests/qemuxml2argvdata/cpu-Haswell.args
+++ b/tests/qemuxml2argvdata/cpu-Haswell.args
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
 -name QEMUGuest1 \
 -S \
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
--cpu Haswell \
+-cpu Haswell,+rtm,+hle \
 -m 214 \
 -realtime mlock=off \
 -smp 6,sockets=6,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/cpu-host-model-cmt.args b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
index e21a889bee..5092e9f43a 100644
--- a/tests/qemuxml2argvdata/cpu-host-model-cmt.args
+++ b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
 -name QEMUGuest1 \
 -S \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm \
+-cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+rtm,+hle \
 -m 214 \
 -realtime mlock=off \
 -smp 6,sockets=6,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
index 79bb77cc68..ac7694ada1 100644
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
 -S \
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -machine pc-i440fx-4.0,accel=tcg,usb=off,dump-guest-core=off \
--cpu Haswell,pclmuldq=on,ds_cpl=on,tsc_adjust=on,fxsr_opt=on,lahf_lm=on,cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,kvm_pv_eoi=on,kvm_pv_unhalt=on \
+-cpu Haswell,pclmuldq=on,ds_cpl=on,tsc_adjust=on,fxsr_opt=on,lahf_lm=on,cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,rtm=on,hle=on,kvm_pv_eoi=on,kvm_pv_unhalt=on \
 -m 214 \
 -overcommit mem-lock=off \
 -smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
index bb6b5c9986..f4a9fde2bf 100644
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
@@ -11,7 +11,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
 -S \
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
--cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
+-cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
 -m 214 \
 -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
 -overcommit mem-lock=off \
diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.args b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
index 0f6f79653e..207ac0a0bb 100644
--- a/tests/qemuxml2argvdata/cpu-tsc-frequency.args
+++ b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
 -name QEMUGuest1 \
 -S \
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
--cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+invtsc,tsc-frequency=3504000000 \
+-cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,+smx,+est,+tm2,+xtpr,+pdcm,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+invtsc,+rtm,+hle,tsc-frequency=3504000000 \
 -m 214 \
 -realtime mlock=off \
 -smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/q35-acpi-nouefi.args b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
index f3d255e76e..bdb94c6fb5 100644
--- a/tests/qemuxml2argvdata/q35-acpi-nouefi.args
+++ b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
 -name guest \
 -S \
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
--cpu Haswell \
+-cpu Haswell,+rtm,+hle \
 -m 1024 \
 -realtime mlock=off \
 -smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/q35-acpi-uefi.args b/tests/qemuxml2argvdata/q35-acpi-uefi.args
index b51a102e01..3ca8ac98a9 100644
--- a/tests/qemuxml2argvdata/q35-acpi-uefi.args
+++ b/tests/qemuxml2argvdata/q35-acpi-uefi.args
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
 -name guest \
 -S \
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
--cpu Haswell \
+-cpu Haswell,+rtm,+hle \
 -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
 -drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,unit=1 \
 -m 1024 \
diff --git a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
index 0cee789ad1..39f28e8c6d 100644
--- a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
+++ b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
@@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \
 -name guest \
 -S \
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
--cpu Haswell \
+-cpu Haswell,+rtm,+hle \
 -m 1024 \
 -realtime mlock=off \
 -smp 1,sockets=1,cores=1,threads=1 \
-- 
2.32.0