]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm: Introduce '--kvm-dev' command line option
authorPekka Enberg <penberg@cs.helsinki.fi>
Sun, 4 Jul 2010 18:57:14 +0000 (21:57 +0300)
committerPekka Enberg <penberg@cs.helsinki.fi>
Sun, 4 Jul 2010 18:57:14 +0000 (21:57 +0300)
This patch introduces a '--kvm-dev' command line option for debugging purposes.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
tools/kvm/include/kvm/kvm.h
tools/kvm/kvm.c
tools/kvm/main.c

index 2d39b6211c0b1904fd0f581238ce5144e09ee0df..1ba844cc19879530163dbc2f02110bad3a9a666c 100644 (file)
@@ -31,7 +31,7 @@ struct kvm {
        struct interrupt_table  interrupt_table;
 };
 
-struct kvm *kvm__init(void);
+struct kvm *kvm__init(const char *kvm_dev);
 void kvm__delete(struct kvm *self);
 void kvm__setup_cpuid(struct kvm *self);
 void kvm__enable_singlestep(struct kvm *self);
index b6a315654fad6d619ddd6187c98e62d38e5b15bc..1e0259e063b6897561953656f65718ff9bbdc77a 100644 (file)
@@ -133,7 +133,7 @@ void kvm__delete(struct kvm *self)
        free(self);
 }
 
-struct kvm *kvm__init(void)
+struct kvm *kvm__init(const char *kvm_dev)
 {
        struct kvm_userspace_memory_region mem;
        struct kvm_pit_config pit_config = { .flags = 0, };
@@ -144,9 +144,13 @@ struct kvm *kvm__init(void)
 
        self = kvm__new();
 
-       self->sys_fd = open("/dev/kvm", O_RDWR);
-       if (self->sys_fd < 0)
+       self->sys_fd = open(kvm_dev, O_RDWR);
+       if (self->sys_fd < 0) {
+               if (errno == ENOENT)
+                       die("'%s' not found. Please make sure you have CONFIG_KVM enabled.", kvm_dev);
+
                die_perror("open");
+       }
 
        ret = ioctl(self->sys_fd, KVM_GET_API_VERSION, 0);
        if (ret != KVM_API_VERSION)
index b8230ecd9717d06d07536aba9aa8194e11782648..6711f85d1ef3abefbe72a862e69ac7b4fee5a27f 100644 (file)
@@ -43,6 +43,7 @@ int main(int argc, char *argv[])
 {
        const char *kernel_filename = NULL;
        const char *kernel_cmdline = NULL;
+       const char *kvm_dev = "/dev/kvm";
        bool single_step = false;
        int i;
 
@@ -55,6 +56,9 @@ int main(int argc, char *argv[])
                } else if (option_matches(argv[i], "--params=")) {
                        kernel_cmdline  = &argv[i][9];
                        continue;
+               } else if (option_matches(argv[i], "--kvm-dev=")) {
+                       kvm_dev         = &argv[i][10];
+                       continue;
                } else if (option_matches(argv[i], "--single-step")) {
                        single_step     = true;
                        continue;
@@ -74,7 +78,7 @@ int main(int argc, char *argv[])
        if (!kernel_filename)
                usage(argv);
 
-       kvm = kvm__init();
+       kvm = kvm__init(kvm_dev);
 
        kvm__setup_cpuid(kvm);