9119d9
From 9f8e2e68bb6cebe92dbf7258553b46007a544e0a Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <9f8e2e68bb6cebe92dbf7258553b46007a544e0a@dist-git>
9119d9
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
9119d9
Date: Tue, 30 Sep 2014 11:04:26 +0200
9119d9
Subject: [PATCH] Don't verify CPU features with host-passthrough
9119d9
9119d9
Commit fba6bc4 introduced the non-migratable invtsc feature,
9119d9
breaking save/migration with host-model and host-passthrough.
9119d9
9119d9
On hosts with this feature present it was automatically included
9119d9
in the CPU definition, regardless of QEMU support.
9119d9
9119d9
Commit de0aeaf stopped including it by default for host-model,
9119d9
but failed to fix host-passthrough.
9119d9
9119d9
This commit ignores checking of CPU features with host-passthrough,
9119d9
since we don't pass them to QEMU (only -cpu host is passed),
9119d9
allowing domains using host-passthrough that were saved with
9119d9
the broken version of libvirtd to be restored.
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1147584
9119d9
(cherry picked from commit ec5f817f2e108ef2164bd4cefd9ad37319cc7518)
9119d9
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_migration.c | 22 ++++++++++++----------
9119d9
 src/qemu/qemu_process.c   |  5 +++++
9119d9
 2 files changed, 17 insertions(+), 10 deletions(-)
9119d9
9119d9
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
9119d9
index 1db9108..2b922fe 100644
9119d9
--- a/src/qemu/qemu_migration.c
9119d9
+++ b/src/qemu/qemu_migration.c
9119d9
@@ -1714,18 +1714,20 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
9119d9
         return false;
9119d9
     }
9119d9
 
9119d9
-    for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
9119d9
-        virCPUFeatureDefPtr feature = &def->cpu->features[i];
9119d9
+    if (def->cpu && def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH) {
9119d9
+        for (i = 0; i < def->cpu->nfeatures; i++) {
9119d9
+            virCPUFeatureDefPtr feature = &def->cpu->features[i];
9119d9
 
9119d9
-        if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
9119d9
-            continue;
9119d9
+            if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
9119d9
+                continue;
9119d9
 
9119d9
-        /* QEMU blocks migration and save with invariant TSC enabled */
9119d9
-        if (STREQ(feature->name, "invtsc")) {
9119d9
-            virReportError(VIR_ERR_OPERATION_INVALID,
9119d9
-                           _("domain has CPU feature: %s"),
9119d9
-                           feature->name);
9119d9
-            return false;
9119d9
+            /* QEMU blocks migration and save with invariant TSC enabled */
9119d9
+            if (STREQ(feature->name, "invtsc")) {
9119d9
+                virReportError(VIR_ERR_OPERATION_INVALID,
9119d9
+                               _("domain has CPU feature: %s"),
9119d9
+                               feature->name);
9119d9
+                return false;
9119d9
+            }
9119d9
         }
9119d9
     }
9119d9
 
9119d9
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
9119d9
index d675add..6565956 100644
9119d9
--- a/src/qemu/qemu_process.c
9119d9
+++ b/src/qemu/qemu_process.c
9119d9
@@ -3785,6 +3785,11 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver,
9119d9
     bool ret = false;
9119d9
     size_t i;
9119d9
 
9119d9
+    /* no features are passed to QEMU with -cpu host
9119d9
+     * so it makes no sense to verify them */
9119d9
+    if (def->cpu && def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH)
9119d9
+        return true;
9119d9
+
9119d9
     switch (arch) {
9119d9
     case VIR_ARCH_I686:
9119d9
     case VIR_ARCH_X86_64:
9119d9
-- 
9119d9
2.1.2
9119d9