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;
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");
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)