]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Move CMT feature filtering to QEMU driver
authorJiri Denemark <jdenemar@redhat.com>
Thu, 21 Jul 2016 15:02:37 +0000 (17:02 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 22 Sep 2016 13:40:09 +0000 (15:40 +0200)
It really doesn't belong to the generic CPU driver.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/cpu/cpu_x86.c
src/qemu/qemu_capabilities.c

index 6397dcb2d6ca573a7096bd10c41ab447ebe8af1c..64f1c47f8f6fe73f6ed0c047dd57fd3c6ec79c01 100644 (file)
@@ -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)
index 985b585d4dd5f4de25dad0eeee6c03388955250d..4d859c4dacacda4c510844f9c0bed99f4b67a321 100644 (file)
@@ -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;
     }