[libvirt] [PATCH v2 45/45] Move CMT feature filtering to QEMU driver

Jiri Denemark jdenemar at redhat.com
Mon Sep 19 13:30:54 UTC 2016


It really doesn't belong to the generic CPU driver.

Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---

Notes:
    Version 2:
    - no change

 src/cpu/cpu_x86.c            | 16 ++--------------
 src/qemu/qemu_capabilities.c | 16 +++++++++++++++-
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 6397dcb..64f1c47 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2559,22 +2559,10 @@ x86UpdateHostModel(virCPUDefPtr guest,
     /* Remove non-migratable features by default */
     updated->type = VIR_CPU_TYPE_GUEST;
     updated->mode = VIR_CPU_MODE_CUSTOM;
-    if (virCPUDefCopyModel(updated, host, true) < 0)
+    if (virCPUDefCopyModelFilter(updated, host, true,
+                                 x86FeatureIsMigratable, map) < 0)
         goto cleanup;
 
-    i = 0;
-    while (i < updated->nfeatures) {
-        if (x86FeatureIsMigratable(updated->features[i].name, map) &&
-            STRNEQ(updated->features[i].name, "cmt") &&
-            STRNEQ(updated->features[i].name, "mbm_total") &&
-            STRNEQ(updated->features[i].name, "mbm_local")) {
-            i++;
-        } else {
-            VIR_FREE(updated->features[i].name);
-            VIR_DELETE_ELEMENT_INPLACE(updated->features, i, updated->nfeatures);
-        }
-    }
-
     if (guest->vendor_id) {
         VIR_FREE(updated->vendor_id);
         if (VIR_STRDUP(updated->vendor_id, guest->vendor_id) < 0)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 985b585..4d859c4 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2947,6 +2947,19 @@ int virQEMUCapsProbeQMP(virQEMUCapsPtr qemuCaps,
 }
 
 
+static bool
+virQEMUCapsCPUFilterFeatures(const char *name,
+                             void *opaque ATTRIBUTE_UNUSED)
+{
+    if (STREQ(name, "cmt") ||
+        STREQ(name, "mbm_total") ||
+        STREQ(name, "mbm_local"))
+        return false;
+
+    return true;
+}
+
+
 void
 virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
                             virCapsHostPtr host)
@@ -2965,7 +2978,8 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps,
         cpu->mode = VIR_CPU_MODE_CUSTOM;
         cpu->match = VIR_CPU_MATCH_EXACT;
 
-        if (virCPUDefCopyModel(cpu, host->cpu, true) < 0)
+        if (virCPUDefCopyModelFilter(cpu, host->cpu, true,
+                                     virQEMUCapsCPUFilterFeatures, NULL) < 0)
             goto error;
     }
 
-- 
2.10.0




More information about the libvir-list mailing list