]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Check for KVM_CAP_USER_MEMORY
authorPekka Enberg <penberg@cs.helsinki.fi>
Mon, 22 Mar 2010 21:34:02 +0000 (23:34 +0200)
committerPekka Enberg <penberg@cs.helsinki.fi>
Mon, 22 Mar 2010 21:34:02 +0000 (23:34 +0200)
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
tools/kvm/kvm.c

index 5ae47edd48c63e26e652d02caa6848165e08a656..c6d460fa13db90160e847c49678ed3e6962b4a90 100644 (file)
@@ -1,6 +1,7 @@
 #include "kvm/cpu.h"
 
 #include <linux/kvm.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <fcntl.h>
 
@@ -9,6 +10,17 @@ struct kvm {
        int                     vmfd;
 };
 
+static inline bool kvm__supports_extension(struct kvm *self, unsigned int extension)
+{
+       int ret;
+
+       ret = ioctl(self->fd, KVM_CHECK_EXTENSION, extension);
+       if (ret < 0)
+               return false;
+
+       return ret;
+}
+
 static void die(const char *s)
 {
        perror(s);
@@ -44,6 +56,9 @@ int main(int argc, char *argv[])
        if (kvm.vmfd < 0)
                die("open");
 
+       if (!kvm__supports_extension(&kvm, KVM_CAP_USER_MEMORY))
+               die("KVM_CAP_USER_MEMORY");
+
        cpu = cpu__new();
 
        cpu__reset(cpu);