@@ -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
@@ -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)
{
@@ -328,7 +328,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;
}
@@ -652,7 +652,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;
}
@@ -1184,7 +1184,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);
}
@@ -590,16 +590,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;
@@ -1378,7 +1368,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;
}
@@ -1386,7 +1376,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
@@ -1660,7 +1650,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);
@@ -2431,7 +2421,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)
@@ -163,7 +163,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);
/*!
@@ -1179,5 +1178,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
use upstream check_extension code Signed-off-by: Glauber Costa <glommer@redhat.com> --- hw/device-assignment.c | 2 +- kvm-all.c | 2 ++ qemu-kvm-x86.c | 6 +++--- qemu-kvm.c | 18 ++++-------------- qemu-kvm.h | 2 +- 5 files changed, 11 insertions(+), 19 deletions(-)