diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2013-02-28 06:33:18 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2013-03-05 17:12:16 -0500 |
commit | a0f155e9646d5f1c263f6f9aae880151100243bb (patch) | |
tree | 761de60204c9c0a5c2208775295c6baa9e5693fb | |
parent | 6a773cb825afb74a600a08fe87fab55ee98ec2ac (diff) |
KVM: Initialize irqfd from kvm_init().
Currently, eventfd introduces module_init/module_exit functions
to initialize/cleanup the irqfd workqueue. This only works, however,
if no other module_init/module_exit functions are built into the
same module.
Let's just move the initialization and cleanup to kvm_init and kvm_exit.
This way, it is also clearer where kvm startup may fail.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | include/linux/kvm_host.h | 13 | ||||
-rw-r--r-- | virt/kvm/eventfd.c | 7 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 6 |
3 files changed, 21 insertions, 5 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index ac584cc53581..d50fe173028b 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -424,6 +424,19 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); | |||
424 | int __must_check vcpu_load(struct kvm_vcpu *vcpu); | 424 | int __must_check vcpu_load(struct kvm_vcpu *vcpu); |
425 | void vcpu_put(struct kvm_vcpu *vcpu); | 425 | void vcpu_put(struct kvm_vcpu *vcpu); |
426 | 426 | ||
427 | #ifdef __KVM_HAVE_IOAPIC | ||
428 | int kvm_irqfd_init(void); | ||
429 | void kvm_irqfd_exit(void); | ||
430 | #else | ||
431 | static inline int kvm_irqfd_init(void) | ||
432 | { | ||
433 | return 0; | ||
434 | } | ||
435 | |||
436 | static inline void kvm_irqfd_exit(void) | ||
437 | { | ||
438 | } | ||
439 | #endif | ||
427 | int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, | 440 | int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, |
428 | struct module *module); | 441 | struct module *module); |
429 | void kvm_exit(void); | 442 | void kvm_exit(void); |
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index adb17f266b28..0b6fe69bb03d 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c | |||
@@ -543,7 +543,7 @@ void kvm_irq_routing_update(struct kvm *kvm, | |||
543 | * aggregated from all vm* instances. We need our own isolated single-thread | 543 | * aggregated from all vm* instances. We need our own isolated single-thread |
544 | * queue to prevent deadlock against flushing the normal work-queue. | 544 | * queue to prevent deadlock against flushing the normal work-queue. |
545 | */ | 545 | */ |
546 | static int __init irqfd_module_init(void) | 546 | int kvm_irqfd_init(void) |
547 | { | 547 | { |
548 | irqfd_cleanup_wq = create_singlethread_workqueue("kvm-irqfd-cleanup"); | 548 | irqfd_cleanup_wq = create_singlethread_workqueue("kvm-irqfd-cleanup"); |
549 | if (!irqfd_cleanup_wq) | 549 | if (!irqfd_cleanup_wq) |
@@ -552,13 +552,10 @@ static int __init irqfd_module_init(void) | |||
552 | return 0; | 552 | return 0; |
553 | } | 553 | } |
554 | 554 | ||
555 | static void __exit irqfd_module_exit(void) | 555 | void kvm_irqfd_exit(void) |
556 | { | 556 | { |
557 | destroy_workqueue(irqfd_cleanup_wq); | 557 | destroy_workqueue(irqfd_cleanup_wq); |
558 | } | 558 | } |
559 | |||
560 | module_init(irqfd_module_init); | ||
561 | module_exit(irqfd_module_exit); | ||
562 | #endif | 559 | #endif |
563 | 560 | ||
564 | /* | 561 | /* |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 0e919a1d4d56..faf05bddd131 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -2898,6 +2898,9 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, | |||
2898 | int r; | 2898 | int r; |
2899 | int cpu; | 2899 | int cpu; |
2900 | 2900 | ||
2901 | r = kvm_irqfd_init(); | ||
2902 | if (r) | ||
2903 | goto out_irqfd; | ||
2901 | r = kvm_arch_init(opaque); | 2904 | r = kvm_arch_init(opaque); |
2902 | if (r) | 2905 | if (r) |
2903 | goto out_fail; | 2906 | goto out_fail; |
@@ -2978,6 +2981,8 @@ out_free_0a: | |||
2978 | out_free_0: | 2981 | out_free_0: |
2979 | kvm_arch_exit(); | 2982 | kvm_arch_exit(); |
2980 | out_fail: | 2983 | out_fail: |
2984 | kvm_irqfd_exit(); | ||
2985 | out_irqfd: | ||
2981 | return r; | 2986 | return r; |
2982 | } | 2987 | } |
2983 | EXPORT_SYMBOL_GPL(kvm_init); | 2988 | EXPORT_SYMBOL_GPL(kvm_init); |
@@ -2994,6 +2999,7 @@ void kvm_exit(void) | |||
2994 | on_each_cpu(hardware_disable_nolock, NULL, 1); | 2999 | on_each_cpu(hardware_disable_nolock, NULL, 1); |
2995 | kvm_arch_hardware_unsetup(); | 3000 | kvm_arch_hardware_unsetup(); |
2996 | kvm_arch_exit(); | 3001 | kvm_arch_exit(); |
3002 | kvm_irqfd_exit(); | ||
2997 | free_cpumask_var(cpus_hardware_enabled); | 3003 | free_cpumask_var(cpus_hardware_enabled); |
2998 | } | 3004 | } |
2999 | EXPORT_SYMBOL_GPL(kvm_exit); | 3005 | EXPORT_SYMBOL_GPL(kvm_exit); |