KVM: Portability: move KVM_CHECK_EXTENSION
authorZhang Xiantao <xiantao.zhang@intel.com>
Thu, 15 Nov 2007 15:07:47 +0000 (23:07 +0800)
committerAvi Kivity <avi@qumranet.com>
Wed, 30 Jan 2008 15:53:03 +0000 (17:53 +0200)
Make KVM_CHECK_EXTENSION code into a function, all archs can define its
capability independently.

Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Acked-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm.h
drivers/kvm/kvm_main.c
drivers/kvm/x86.c

index 96d9c7da14c246d711ae1d700ba435993f7b79d0..a7be0733bc48e86ec3f1ad8bf7d228ba414c8729 100644 (file)
@@ -628,6 +628,9 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
                         unsigned int ioctl, unsigned long arg);
 void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
+
+int kvm_dev_ioctl_check_extension(long ext);
+
 int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
                                   struct
                                   kvm_userspace_memory_region *mem,
index e0f20d02028177fa7a68412440c584ec05df2d47..c782f27265de00de1fa65e05301a39bd04c35998 100644 (file)
@@ -1198,23 +1198,9 @@ static long kvm_dev_ioctl(struct file *filp,
                        goto out;
                r = kvm_dev_ioctl_create_vm();
                break;
-       case KVM_CHECK_EXTENSION: {
-               int ext = (long)argp;
-
-               switch (ext) {
-               case KVM_CAP_IRQCHIP:
-               case KVM_CAP_HLT:
-               case KVM_CAP_MMU_SHADOW_CACHE_CONTROL:
-               case KVM_CAP_USER_MEMORY:
-               case KVM_CAP_SET_TSS_ADDR:
-                       r = 1;
-                       break;
-               default:
-                       r = 0;
-                       break;
-               }
+       case KVM_CHECK_EXTENSION:
+               r = kvm_dev_ioctl_check_extension((long)argp);
                break;
-       }
        case KVM_GET_VCPU_MMAP_SIZE:
                r = -EINVAL;
                if (arg)
index bbfa810bf8bdfbe1d2be997a0ba76c2c1fa97dc5..609792637fb4ba54cb7d55ac723ec11cf0608f9e 100644 (file)
@@ -599,6 +599,26 @@ void decache_vcpus_on_cpu(int cpu)
        spin_unlock(&kvm_lock);
 }
 
+int kvm_dev_ioctl_check_extension(long ext)
+{
+       int r;
+
+       switch (ext) {
+       case KVM_CAP_IRQCHIP:
+       case KVM_CAP_HLT:
+       case KVM_CAP_MMU_SHADOW_CACHE_CONTROL:
+       case KVM_CAP_USER_MEMORY:
+       case KVM_CAP_SET_TSS_ADDR:
+               r = 1;
+               break;
+       default:
+               r = 0;
+               break;
+       }
+       return r;
+
+}
+
 long kvm_arch_dev_ioctl(struct file *filp,
                        unsigned int ioctl, unsigned long arg)
 {