Disable KVM support if the kernel modules have broken memory slot handling
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Tue, 9 Dec 2008 19:59:09 +0000 (19:59 +0000)
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Tue, 9 Dec 2008 19:59:09 +0000 (19:59 +0000)
Prior to kvm-80, memory slot deletion was broken in the KVM kernel
modules.  In kvm-81, a new capability is introduced to signify that this
problem has been fixed.

Since we rely on being able to delete memory slots, refuse to work with
any kernel module that does not have this capability present.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5960 c046a42c-6fe2-441c-8c8c-71466251a162

configure
kvm-all.c

index b90c47f..13f6358 100755 (executable)
--- a/configure
+++ b/configure
@@ -933,7 +933,8 @@ if test "$kvm" = "yes" ; then
     KVM_API_VERSION < 12 || \
     KVM_API_VERSION > 12 || \
     !defined(KVM_CAP_USER_MEMORY) || \
-    !defined(KVM_CAP_SET_TSS_ADDR)
+    !defined(KVM_CAP_SET_TSS_ADDR) || \
+    !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
 #error Invalid KVM version
 #endif
 int main(void) { return 0; }
index 69ca46b..8615bf6 100644 (file)
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -283,6 +283,21 @@ int kvm_init(int smp_cpus)
         goto err;
     }
 
+    /* There was a nasty bug in < kvm-80 that prevents memory slots from being
+     * destroyed properly.  Since we rely on this capability, refuse to work
+     * with any kernel without this capability. */
+    ret = kvm_ioctl(s, KVM_CHECK_EXTENSION,
+                    KVM_CAP_DESTROY_MEMORY_REGION_WORKS);
+    if (ret <= 0) {
+        if (ret == 0)
+            ret = -EINVAL;
+
+        fprintf(stderr,
+                "KVM kernel module broken (DESTROY_MEMORY_REGION)\n"
+                "Please upgrade to at least kvm-81.\n");
+        goto err;
+    }
+
     ret = kvm_arch_init(s, smp_cpus);
     if (ret < 0)
         goto err;