]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm__init: the kernel should support irq and pit
authorAsias He <asias.hejun@gmail.com>
Fri, 28 May 2010 16:47:50 +0000 (20:47 +0400)
committerCyrill Gorcunov <gorcunov@gmail.com>
Fri, 28 May 2010 17:22:01 +0000 (21:22 +0400)
We rely on kenrnel being fresh enough since we're
not going to support non built-in IRQ routing and
PIT emulation.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
tools/kvm/kvm.c

index 9a8d246a22c45ba82e2fe05a4420c756af2f06da..3aac4d49a1c38fe6b1ec2d1bf977aa7386fce88c 100644 (file)
@@ -102,6 +102,7 @@ void kvm__delete(struct kvm *self)
 struct kvm *kvm__init(void)
 {
        struct kvm_userspace_memory_region mem;
+       struct kvm_pit_config pit_config = { .flags = 0, };
        struct kvm *self;
        long page_size;
        int mmap_size;
@@ -121,6 +122,23 @@ struct kvm *kvm__init(void)
        if (self->vm_fd < 0)
                die_perror("KVM_CREATE_VM ioctl");
 
+       if (!kvm__supports_extension(self, KVM_CAP_COALESCED_MMIO))
+               die("KVM_CAP_COALESCED_MMIO is not supported");
+
+       if (!kvm__supports_extension(self, KVM_CAP_SET_TSS_ADDR))
+               die("KVM_CAP_SET_TSS_ADDR is not supported");
+
+       ret = ioctl(self->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000);
+       if (ret < 0)
+               die_perror("KVM_SET_TSS_ADDR ioctl");
+
+       if (!kvm__supports_extension(self, KVM_CAP_PIT2))
+               die("KVM_CAP_PIT2 is not supported");
+
+       ret = ioctl(self->vm_fd, KVM_CREATE_PIT2, &pit_config);
+       if (ret < 0)
+               die_perror("KVM_CREATE_PIT2 ioctl");
+
        if (!kvm__supports_extension(self, KVM_CAP_USER_MEMORY))
                die("KVM_CAP_USER_MEMORY is not supported");
 
@@ -141,12 +159,18 @@ struct kvm *kvm__init(void)
        if (ret < 0)
                die_perror("KVM_SET_USER_MEMORY_REGION ioctl");
 
-       if (!kvm__supports_extension(self, KVM_CAP_SET_TSS_ADDR))
-               die("KVM_CAP_SET_TSS_ADDR is not supported");
+       if (!kvm__supports_extension(self, KVM_CAP_IRQ_ROUTING))
+               die("KVM_CAP_IRQ_ROUTING is not supported");
 
-       ret = ioctl(self->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000);
+       if (!kvm__supports_extension(self, KVM_CAP_IRQCHIP))
+               die("KVM_CAP_IRQCHIP is not supported");
+
+       ret = ioctl(self->vm_fd, KVM_CREATE_IRQCHIP);
        if (ret < 0)
-               die_perror("KVM_SET_TSS_ADDR ioctl");
+               die_perror("KVM_CREATE_IRQCHIP ioctl");
+
+       if (!kvm__supports_extension(self, KVM_CAP_IRQ_INJECT_STATUS))
+               die("KVM_KVM_CAP_IRQ_INJECT_STATUS is not supported");
 
        self->vcpu_fd = ioctl(self->vm_fd, KVM_CREATE_VCPU, 0);
        if (self->vcpu_fd < 0)