This patch introduces a '--kvm-dev' command line option for debugging purposes.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
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);
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, };
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)
{
const char *kernel_filename = NULL;
const char *kernel_cmdline = NULL;
+ const char *kvm_dev = "/dev/kvm";
bool single_step = false;
int i;
} 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;
if (!kernel_filename)
usage(argv);
- kvm = kvm__init();
+ kvm = kvm__init(kvm_dev);
kvm__setup_cpuid(kvm);