diff options
author | Asias He <asias.hejun@gmail.com> | 2010-05-28 20:47:50 +0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2015-06-01 16:39:39 +0100 |
commit | 9687927d6877711102197dc9508dc23a67769b29 (patch) | |
tree | 00cab41fcfd9bbf6dc37e954011e0b2318b9caba /kvm.c | |
parent | b6e68186d17ee53ff2255546eb60713ed07feb5f (diff) | |
download | kvmtool-9687927d6877711102197dc9508dc23a67769b29.tar.gz |
kvm__init: the kernel should support irq and pit
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>
Diffstat (limited to 'kvm.c')
-rw-r--r-- | kvm.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -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) |