]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: clean up directives to compile out irqfds
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 18 Oct 2023 16:18:00 +0000 (12:18 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 8 Dec 2023 20:43:34 +0000 (15:43 -0500)
Keep all #ifdef CONFIG_HAVE_KVM_IRQCHIP parts of eventfd.c together, and
compile out the irqfds field of struct kvm if the symbol is not defined.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/linux/kvm_host.h
virt/kvm/eventfd.c

index 1bba24a13ec93834b41941072a9695083e07bc55..7e7fd25b09b3ebe3d81e30fb23f506a9ee5a6519 100644 (file)
@@ -782,6 +782,7 @@ struct kvm {
        struct list_head vm_list;
        struct mutex lock;
        struct kvm_io_bus __rcu *buses[KVM_NR_BUSES];
+#ifdef CONFIG_HAVE_KVM_IRQCHIP
        struct {
                spinlock_t        lock;
                struct list_head  items;
@@ -789,6 +790,7 @@ struct kvm {
                struct list_head  resampler_list;
                struct mutex      resampler_lock;
        } irqfds;
+#endif
        struct list_head ioeventfds;
        struct kvm_vm_stat stat;
        struct kvm_arch arch;
index 19534156d48c5ab3366bb74cbcf0b4a926301bd7..d516e6d33f56f188eb3d27c181e2b1df2d1ec83b 100644 (file)
@@ -526,21 +526,7 @@ void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
        synchronize_srcu(&kvm->irq_srcu);
        kvm_arch_post_irq_ack_notifier_list_update(kvm);
 }
-#endif
-
-void
-kvm_eventfd_init(struct kvm *kvm)
-{
-#ifdef CONFIG_HAVE_KVM_IRQCHIP
-       spin_lock_init(&kvm->irqfds.lock);
-       INIT_LIST_HEAD(&kvm->irqfds.items);
-       INIT_LIST_HEAD(&kvm->irqfds.resampler_list);
-       mutex_init(&kvm->irqfds.resampler_lock);
-#endif
-       INIT_LIST_HEAD(&kvm->ioeventfds);
-}
 
-#ifdef CONFIG_HAVE_KVM_IRQCHIP
 /*
  * shutdown any irqfd's that match fd+gsi
  */
@@ -1012,3 +998,15 @@ kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 
        return kvm_assign_ioeventfd(kvm, args);
 }
+
+void
+kvm_eventfd_init(struct kvm *kvm)
+{
+#ifdef CONFIG_HAVE_KVM_IRQCHIP
+       spin_lock_init(&kvm->irqfds.lock);
+       INIT_LIST_HEAD(&kvm->irqfds.items);
+       INIT_LIST_HEAD(&kvm->irqfds.resampler_list);
+       mutex_init(&kvm->irqfds.resampler_lock);
+#endif
+       INIT_LIST_HEAD(&kvm->ioeventfds);
+}