Skip to content

Commit aa8d594

Browse files
committed
KVM: Move irq routing to generic code
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>
1 parent 7eee2ef commit aa8d594

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

virt/kvm/assigned-dev.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -983,36 +983,6 @@ long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl,
983983
goto out;
984984
break;
985985
}
986-
#ifdef KVM_CAP_IRQ_ROUTING
987-
case KVM_SET_GSI_ROUTING: {
988-
struct kvm_irq_routing routing;
989-
struct kvm_irq_routing __user *urouting;
990-
struct kvm_irq_routing_entry *entries;
991-
992-
r = -EFAULT;
993-
if (copy_from_user(&routing, argp, sizeof(routing)))
994-
goto out;
995-
r = -EINVAL;
996-
if (routing.nr >= KVM_MAX_IRQ_ROUTES)
997-
goto out;
998-
if (routing.flags)
999-
goto out;
1000-
r = -ENOMEM;
1001-
entries = vmalloc(routing.nr * sizeof(*entries));
1002-
if (!entries)
1003-
goto out;
1004-
r = -EFAULT;
1005-
urouting = argp;
1006-
if (copy_from_user(entries, urouting->entries,
1007-
routing.nr * sizeof(*entries)))
1008-
goto out_free_irq_routing;
1009-
r = kvm_set_irq_routing(kvm, entries, routing.nr,
1010-
routing.flags);
1011-
out_free_irq_routing:
1012-
vfree(entries);
1013-
break;
1014-
}
1015-
#endif /* KVM_CAP_IRQ_ROUTING */
1016986
#ifdef __KVM_HAVE_MSIX
1017987
case KVM_ASSIGN_SET_MSIX_NR: {
1018988
struct kvm_assigned_msix_nr entry_nr;

virt/kvm/kvm_main.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,36 @@ static long kvm_vm_ioctl(struct file *filp,
22742274
break;
22752275
}
22762276
#endif
2277+
#ifdef CONFIG_HAVE_KVM_IRQ_ROUTING
2278+
case KVM_SET_GSI_ROUTING: {
2279+
struct kvm_irq_routing routing;
2280+
struct kvm_irq_routing __user *urouting;
2281+
struct kvm_irq_routing_entry *entries;
2282+
2283+
r = -EFAULT;
2284+
if (copy_from_user(&routing, argp, sizeof(routing)))
2285+
goto out;
2286+
r = -EINVAL;
2287+
if (routing.nr >= KVM_MAX_IRQ_ROUTES)
2288+
goto out;
2289+
if (routing.flags)
2290+
goto out;
2291+
r = -ENOMEM;
2292+
entries = vmalloc(routing.nr * sizeof(*entries));
2293+
if (!entries)
2294+
goto out;
2295+
r = -EFAULT;
2296+
urouting = argp;
2297+
if (copy_from_user(entries, urouting->entries,
2298+
routing.nr * sizeof(*entries)))
2299+
goto out_free_irq_routing;
2300+
r = kvm_set_irq_routing(kvm, entries, routing.nr,
2301+
routing.flags);
2302+
out_free_irq_routing:
2303+
vfree(entries);
2304+
break;
2305+
}
2306+
#endif /* CONFIG_HAVE_KVM_IRQ_ROUTING */
22772307
default:
22782308
r = kvm_arch_vm_ioctl(filp, ioctl, arg);
22792309
if (r == -ENOTTY)

0 commit comments

Comments
 (0)