render / rpms / libvirt

Forked from rpms/libvirt a year ago
Clone
898951
From 65d750dec286074fc48fdaa64eb3f5029626506f Mon Sep 17 00:00:00 2001
898951
Message-Id: <65d750dec286074fc48fdaa64eb3f5029626506f@dist-git>
898951
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
898951
Date: Tue, 6 May 2014 13:55:44 +0200
898951
Subject: [PATCH] Add invariant TSC cpu flag
898951
898951
Add suport for invariant TSC flag (CPUID 0x80000007, bit 8 of EDX).
898951
If this flag is enabled, the TSC ticks at a constant rate across
898951
all ACPI P-, C- and T-states.
898951
898951
This can be enabled by adding:
898951
<feature name='invtsc'/>
898951
to the <cpu> element.
898951
898951
Migration and saving the domain does not work with this flag.
898951
898951
QEMU support: http://git.qemu.org/?p=qemu.git;a=commitdiff;h=303752a
898951
898951
The feature name "invtsc" differs from the name "" used by the linux kernel:
898951
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/cpu/powerflags.c?id=30321c7b#n18
898951
898951
(cherry picked from commit fba6bc47cbcabbe08d42279691efb0dff3b9c997)
898951
https://bugzilla.redhat.com/show_bug.cgi?id=1185458
898951
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
898951
---
898951
 src/cpu/cpu_map.xml       |  5 +++++
898951
 src/qemu/qemu_migration.c | 15 +++++++++++++++
898951
 src/qemu/qemu_process.c   | 15 +++++++++++++++
898951
 3 files changed, 35 insertions(+)
898951
898951
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
898951
index 6d51283..aa10019 100644
898951
--- a/src/cpu/cpu_map.xml
898951
+++ b/src/cpu/cpu_map.xml
898951
@@ -327,6 +327,11 @@
898951
       <cpuid function='0x00000007' ebx='0x00100000'/>
898951
     </feature>
898951
 
898951
+    
898951
+    <feature name='invtsc'>
898951
+      <cpuid function='0x80000007' edx='0x00000100'/>
898951
+    </feature>
898951
+
898951
     
898951
     <model name='486'>
898951
       <feature name='fpu'/>
898951
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
898951
index deacb66..d979d50 100644
898951
--- a/src/qemu/qemu_migration.c
898951
+++ b/src/qemu/qemu_migration.c
898951
@@ -1506,6 +1506,21 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
898951
         return false;
898951
     }
898951
 
898951
+    for (i = 0; i < def->cpu->nfeatures; i++) {
898951
+        virCPUFeatureDefPtr feature = &def->cpu->features[i];
898951
+
898951
+        if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
898951
+            continue;
898951
+
898951
+        /* QEMU blocks migration and save with invariant TSC enabled */
898951
+        if (STREQ(feature->name, "invtsc")) {
898951
+            virReportError(VIR_ERR_OPERATION_INVALID,
898951
+                           _("domain has CPU feature: %s"),
898951
+                           feature->name);
898951
+            return false;
898951
+        }
898951
+    }
898951
+
898951
     return true;
898951
 }
898951
 
898951
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
898951
index 3eda15b..8c07397 100644
898951
--- a/src/qemu/qemu_process.c
898951
+++ b/src/qemu/qemu_process.c
898951
@@ -3520,6 +3520,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm)
898951
     virCPUDataPtr guestcpu = NULL;
898951
     qemuDomainObjPrivatePtr priv = vm->privateData;
898951
     bool ret = false;
898951
+    size_t i;
898951
 
898951
     switch (arch) {
898951
     case VIR_ARCH_I686:
898951
@@ -3538,6 +3539,20 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm)
898951
                 goto cleanup;
898951
             }
898951
         }
898951
+
898951
+        for (i = 0; i < def->cpu->nfeatures; i++) {
898951
+            virCPUFeatureDefPtr feature = &def->cpu->features[i];
898951
+
898951
+            if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
898951
+                continue;
898951
+
898951
+            if (STREQ(feature->name, "invtsc") &&
898951
+                !cpuHasFeature(guestcpu, feature->name)) {
898951
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
898951
+                               _("host doesn't support invariant TSC"));
898951
+                goto cleanup;
898951
+            }
898951
+        }
898951
         break;
898951
 
898951
     default:
898951
-- 
898951
2.2.2
898951