From: Glauber Costa <glom...@redhat.com> use upstream check_extension code
Signed-off-by: Glauber Costa <glom...@redhat.com> Signed-off-by: Marcelo Tosatti <mtosa...@redhat.com> diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 88c3baf..75db546 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -639,7 +639,7 @@ static int assign_device(AssignedDevInfo *adev) /* We always enable the IOMMU if present * (or when not disabled on the command line) */ - r = kvm_check_extension(kvm_context, KVM_CAP_IOMMU); + r = kvm_check_extension(kvm_state, KVM_CAP_IOMMU); if (r && !adev->disable_iommu) assigned_dev_data.flags |= KVM_DEV_ASSIGN_ENABLE_IOMMU; #endif diff --git a/kvm-all.c b/kvm-all.c index 0ec6475..b4b5a35 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -383,6 +383,7 @@ int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size) return ret; } +#endif int kvm_check_extension(KVMState *s, unsigned int extension) { int ret; @@ -394,6 +395,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension) return ret; } +#ifdef KVM_UPSTREAM int kvm_init(int smp_cpus) { diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 428e831..e4ae582 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -348,7 +348,7 @@ int kvm_has_pit_state2(kvm_context_t kvm) int r = 0; #ifdef KVM_CAP_PIT_STATE2 - r = kvm_check_extension(kvm, KVM_CAP_PIT_STATE2); + r = kvm_check_extension(kvm_state, KVM_CAP_PIT_STATE2); #endif return r; } @@ -702,7 +702,7 @@ uint32_t kvm_get_supported_cpuid(kvm_context_t kvm, uint32_t function, int reg) uint32_t ret = 0; uint32_t cpuid_1_edx; - if (!kvm_check_extension(kvm, KVM_CAP_EXT_CPUID)) { + if (!kvm_check_extension(kvm_state, KVM_CAP_EXT_CPUID)) { return -1U; } @@ -1234,7 +1234,7 @@ static int get_para_features(kvm_context_t kvm_context) int i, features = 0; for (i = 0; i < ARRAY_SIZE(para_features)-1; i++) { - if (kvm_check_extension(kvm_context, para_features[i].cap)) + if (kvm_check_extension(kvm_state, para_features[i].cap)) features |= (1 << para_features[i].feature); } diff --git a/qemu-kvm.c b/qemu-kvm.c index 98cfee0..e200dea 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -589,16 +589,6 @@ static int kvm_create_default_phys_mem(kvm_context_t kvm, return -1; } -int kvm_check_extension(kvm_context_t kvm, int ext) -{ - int ret; - - ret = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, ext); - if (ret > 0) - return ret; - return 0; -} - void kvm_create_irqchip(kvm_context_t kvm) { int r; @@ -1345,7 +1335,7 @@ int kvm_has_gsi_routing(kvm_context_t kvm) int r = 0; #ifdef KVM_CAP_IRQ_ROUTING - r = kvm_check_extension(kvm, KVM_CAP_IRQ_ROUTING); + r = kvm_check_extension(kvm_state, KVM_CAP_IRQ_ROUTING); #endif return r; } @@ -1353,7 +1343,7 @@ int kvm_has_gsi_routing(kvm_context_t kvm) int kvm_get_gsi_count(kvm_context_t kvm) { #ifdef KVM_CAP_IRQ_ROUTING - return kvm_check_extension(kvm, KVM_CAP_IRQ_ROUTING); + return kvm_check_extension(kvm_state, KVM_CAP_IRQ_ROUTING); #else return -EINVAL; #endif @@ -1606,7 +1596,7 @@ int kvm_irqfd(kvm_context_t kvm, int gsi, int flags) int r; int fd; - if (!kvm_check_extension(kvm, KVM_CAP_IRQFD)) + if (!kvm_check_extension(kvm_state, KVM_CAP_IRQFD)) return -ENOENT; fd = eventfd(0, 0); @@ -2381,7 +2371,7 @@ int kvm_setup_guest_memory(void *area, unsigned long size) int kvm_qemu_check_extension(int ext) { - return kvm_check_extension(kvm_context, ext); + return kvm_check_extension(kvm_state, ext); } int kvm_qemu_init_env(CPUState *cenv) diff --git a/qemu-kvm.h b/qemu-kvm.h index 8c9b72f..ec35f29 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -167,7 +167,6 @@ int kvm_create(kvm_context_t kvm, unsigned long phys_mem_bytes, void **phys_mem); int kvm_create_vm(kvm_context_t kvm); -int kvm_check_extension(kvm_context_t kvm, int ext); void kvm_create_irqchip(kvm_context_t kvm); /*! @@ -1198,5 +1197,6 @@ extern KVMState *kvm_state; int kvm_ioctl(KVMState *s, int type, ...); int kvm_vm_ioctl(KVMState *s, int type, ...); +int kvm_check_extension(KVMState *s, unsigned int ext); #endif -- To unsubscribe from this list: send the line "unsubscribe kvm-commits" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html