KVM: Move irq routing to generic code
authorAlexander Graf <agraf@suse.de>
Mon, 15 Apr 2013 19:12:53 +0000 (21:12 +0200)
committerAlexander Graf <agraf@suse.de>
Fri, 26 Apr 2013 18:27:17 +0000 (20:27 +0200)
The IRQ routing set ioctl lives in the hacky device assignment code inside
of KVM today. This is definitely the wrong place for it. Move it to the much
more natural kvm_main.c.

Signed-off-by: Alexander Graf <agraf@suse.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
virt/kvm/assigned-dev.c
virt/kvm/kvm_main.c

index f4c7f591b5d8e6b2fbeb413947028f104a3bb37b..8db43701016f30cebeb37ab7e4d581166606b86f 100644 (file)
@@ -983,36 +983,6 @@ long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl,
                        goto out;
                break;
        }
-#ifdef KVM_CAP_IRQ_ROUTING
-       case KVM_SET_GSI_ROUTING: {
-               struct kvm_irq_routing routing;
-               struct kvm_irq_routing __user *urouting;
-               struct kvm_irq_routing_entry *entries;
-
-               r = -EFAULT;
-               if (copy_from_user(&routing, argp, sizeof(routing)))
-                       goto out;
-               r = -EINVAL;
-               if (routing.nr >= KVM_MAX_IRQ_ROUTES)
-                       goto out;
-               if (routing.flags)
-                       goto out;
-               r = -ENOMEM;
-               entries = vmalloc(routing.nr * sizeof(*entries));
-               if (!entries)
-                       goto out;
-               r = -EFAULT;
-               urouting = argp;
-               if (copy_from_user(entries, urouting->entries,
-                                  routing.nr * sizeof(*entries)))
-                       goto out_free_irq_routing;
-               r = kvm_set_irq_routing(kvm, entries, routing.nr,
-                                       routing.flags);
-       out_free_irq_routing:
-               vfree(entries);
-               break;
-       }
-#endif /* KVM_CAP_IRQ_ROUTING */
 #ifdef __KVM_HAVE_MSIX
        case KVM_ASSIGN_SET_MSIX_NR: {
                struct kvm_assigned_msix_nr entry_nr;
index 2c3b226bc13ba77194e947ffb8ebaa9ea4102483..b6f33547b3dbd42626dce6b774a8d8330b36cc9f 100644 (file)
@@ -2274,6 +2274,36 @@ static long kvm_vm_ioctl(struct file *filp,
                break;
        }
 #endif
+#ifdef CONFIG_HAVE_KVM_IRQ_ROUTING
+       case KVM_SET_GSI_ROUTING: {
+               struct kvm_irq_routing routing;
+               struct kvm_irq_routing __user *urouting;
+               struct kvm_irq_routing_entry *entries;
+
+               r = -EFAULT;
+               if (copy_from_user(&routing, argp, sizeof(routing)))
+                       goto out;
+               r = -EINVAL;
+               if (routing.nr >= KVM_MAX_IRQ_ROUTES)
+                       goto out;
+               if (routing.flags)
+                       goto out;
+               r = -ENOMEM;
+               entries = vmalloc(routing.nr * sizeof(*entries));
+               if (!entries)
+                       goto out;
+               r = -EFAULT;
+               urouting = argp;
+               if (copy_from_user(entries, urouting->entries,
+                                  routing.nr * sizeof(*entries)))
+                       goto out_free_irq_routing;
+               r = kvm_set_irq_routing(kvm, entries, routing.nr,
+                                       routing.flags);
+       out_free_irq_routing:
+               vfree(entries);
+               break;
+       }
+#endif /* CONFIG_HAVE_KVM_IRQ_ROUTING */
        default:
                r = kvm_arch_vm_ioctl(filp, ioctl, arg);
                if (r == -ENOTTY)