render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
6ae9ed
From 780500abda14bb71111592254d01c973d16be320 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <780500abda14bb71111592254d01c973d16be320@dist-git>
6ae9ed
From: Jiri Denemark <jdenemar@redhat.com>
6ae9ed
Date: Tue, 28 Jun 2016 10:51:41 +0200
6ae9ed
Subject: [PATCH] cpu_x86: Introduce x86FeatureIsMigratable
6ae9ed
6ae9ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6ae9ed
(cherry picked from commit dbb14bb0f1316d92c89541fca816c91dce0dc8fb)
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 | 37 +++++++++++++++++++++++--------------
6ae9ed
 1 file changed, 23 insertions(+), 14 deletions(-)
6ae9ed
6ae9ed
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
6ae9ed
index d9646eb..7bb2bb6 100644
6ae9ed
--- a/src/cpu/cpu_x86.c
6ae9ed
+++ b/src/cpu/cpu_x86.c
6ae9ed
@@ -767,6 +767,22 @@ x86FeatureFindInternal(const char *name)
6ae9ed
 }
6ae9ed
 
6ae9ed
 
6ae9ed
+static bool
6ae9ed
+x86FeatureIsMigratable(const char *name,
6ae9ed
+                       void *cpu_map)
6ae9ed
+{
6ae9ed
+    virCPUx86MapPtr map = cpu_map;
6ae9ed
+    size_t i;
6ae9ed
+
6ae9ed
+    for (i = 0; i < map->nblockers; i++) {
6ae9ed
+        if (STREQ(name, map->migrate_blockers[i]->name))
6ae9ed
+            return false;
6ae9ed
+    }
6ae9ed
+
6ae9ed
+    return true;
6ae9ed
+}
6ae9ed
+
6ae9ed
+
6ae9ed
 static char *
6ae9ed
 x86FeatureNames(virCPUx86MapPtr map,
6ae9ed
                 const char *separator,
6ae9ed
@@ -1801,14 +1817,10 @@ x86Decode(virCPUDefPtr cpu,
6ae9ed
      * features directly */
6ae9ed
     if (flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE) {
6ae9ed
         for (i = 0; i < cpuModel->nfeatures; i++) {
6ae9ed
-            size_t j;
6ae9ed
-            for (j = 0; j < map->nblockers; j++) {
6ae9ed
-                if (STREQ(map->migrate_blockers[j]->name,
6ae9ed
-                          cpuModel->features[i].name)) {
6ae9ed
-                    VIR_FREE(cpuModel->features[i].name);
6ae9ed
-                    VIR_DELETE_ELEMENT_INPLACE(cpuModel->features, i,
6ae9ed
-                                               cpuModel->nfeatures);
6ae9ed
-                }
6ae9ed
+            if (!x86FeatureIsMigratable(cpuModel->features[i].name, map)) {
6ae9ed
+                VIR_FREE(cpuModel->features[i].name);
6ae9ed
+                VIR_DELETE_ELEMENT_INPLACE(cpuModel->features, i,
6ae9ed
+                                           cpuModel->nfeatures);
6ae9ed
             }
6ae9ed
         }
6ae9ed
     }
6ae9ed
@@ -2531,12 +2543,9 @@ x86UpdateHostModel(virCPUDefPtr guest,
6ae9ed
      * Note: this only works as long as no CPU model contains non-migratable
6ae9ed
      * features directly */
6ae9ed
     for (i = 0; i < guest->nfeatures; i++) {
6ae9ed
-        size_t j;
6ae9ed
-        for (j = 0; j < map->nblockers; j++) {
6ae9ed
-            if (STREQ(map->migrate_blockers[j]->name, guest->features[i].name)) {
6ae9ed
-                VIR_FREE(guest->features[i].name);
6ae9ed
-                VIR_DELETE_ELEMENT_INPLACE(guest->features, i, guest->nfeatures);
6ae9ed
-            }
6ae9ed
+        if (!x86FeatureIsMigratable(guest->features[i].name, map)) {
6ae9ed
+            VIR_FREE(guest->features[i].name);
6ae9ed
+            VIR_DELETE_ELEMENT_INPLACE(guest->features, i, guest->nfeatures);
6ae9ed
         }
6ae9ed
     }
6ae9ed
     for (i = 0; !passthrough && i < oldguest->nfeatures; i++) {
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed