6ae9ed
From cdc937aeef0901ba76e3b51029b8ae3cef58c9de Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <cdc937aeef0901ba76e3b51029b8ae3cef58c9de@dist-git>
6ae9ed
From: Jiri Denemark <jdenemar@redhat.com>
6ae9ed
Date: Tue, 9 Aug 2016 15:15:20 +0200
6ae9ed
Subject: [PATCH] cpu_x86: Fix host-model CPUs on hosts with CMT
6ae9ed
6ae9ed
Since the introduction of CMT features (commit v1.3.5-461-gf294b83)
6ae9ed
starting a domain with host-model CPU on a host which supports CMT fails
6ae9ed
because QEMU complains about unknown 'cmt' feature:
6ae9ed
6ae9ed
    qemu-system-x86_64: CPU feature cmt not found
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1355857
6ae9ed
6ae9ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6ae9ed
(cherry picked from commit 300f668c665f1ec0f834917fe8a58b5991322441)
6ae9ed
6ae9ed
RHEL changes:
6ae9ed
    - since commit v2.0.0-8-g0c8ec3b libvirt in RHEL always passes
6ae9ed
      +rtm,+hle options to Haswell and Broadwell CPUs
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1365500
6ae9ed
6ae9ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6ae9ed
---
6ae9ed
 src/cpu/cpu_x86.c                                           | 8 ++++++--
6ae9ed
 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args | 2 +-
6ae9ed
 2 files changed, 7 insertions(+), 3 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
6ae9ed
index 24ef76b..670b02e 100644
6ae9ed
--- a/src/cpu/cpu_x86.c
6ae9ed
+++ b/src/cpu/cpu_x86.c
6ae9ed
@@ -2542,12 +2542,16 @@ x86UpdateHostModel(virCPUDefPtr guest,
6ae9ed
             goto cleanup;
6ae9ed
     }
6ae9ed
 
6ae9ed
-    /* Remove non-migratable features by default
6ae9ed
+    /* Remove non-migratable features and CMT related features which QEMU
6ae9ed
+     * knows nothing about.
6ae9ed
      * Note: this only works as long as no CPU model contains non-migratable
6ae9ed
      * features directly */
6ae9ed
     i = 0;
6ae9ed
     while (i < guest->nfeatures) {
6ae9ed
-        if (x86FeatureIsMigratable(guest->features[i].name, map)) {
6ae9ed
+        if (x86FeatureIsMigratable(guest->features[i].name, map) &&
6ae9ed
+            STRNEQ(guest->features[i].name, "cmt") &&
6ae9ed
+            STRNEQ(guest->features[i].name, "mbm_total") &&
6ae9ed
+            STRNEQ(guest->features[i].name, "mbm_local")) {
6ae9ed
             i++;
6ae9ed
         } else {
6ae9ed
             VIR_FREE(guest->features[i].name);
6ae9ed
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
6ae9ed
index 884ca57..b7fdf4b 100644
6ae9ed
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
6ae9ed
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
6ae9ed
@@ -9,7 +9,7 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -S \
6ae9ed
 -M pc \
6ae9ed
 -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
6ae9ed
-+smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+cmt,+pdpe1gb,+abm,+rtm,+hle \
6ae9ed
++smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+rtm,+hle \
6ae9ed
 -m 214 \
6ae9ed
 -smp 6 \
6ae9ed
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed