KVM: Remove ifdefs from mmu notifier initialization
authorAvi Kivity <avi@redhat.com>
Sun, 20 Dec 2009 12:54:04 +0000 (14:54 +0200)
committerMarcelo Tosatti <mtosatti@redhat.com>
Mon, 1 Mar 2010 15:35:41 +0000 (12:35 -0300)
Signed-off-by: Avi Kivity <avi@redhat.com>
virt/kvm/kvm_main.c

index 92f5c98b6c4d85227c6b713688ffd1c10cb02dec..c10d117c43173c8d33269563804f23547bda6d97 100644 (file)
@@ -341,6 +341,20 @@ static const struct mmu_notifier_ops kvm_mmu_notifier_ops = {
        .change_pte             = kvm_mmu_notifier_change_pte,
        .release                = kvm_mmu_notifier_release,
 };
+
+static int kvm_init_mmu_notifier(struct kvm *kvm)
+{
+       kvm->mmu_notifier.ops = &kvm_mmu_notifier_ops;
+       return mmu_notifier_register(&kvm->mmu_notifier, current->mm);
+}
+
+#else  /* !(CONFIG_MMU_NOTIFIER && KVM_ARCH_WANT_MMU_NOTIFIER) */
+
+static int kvm_init_mmu_notifier(struct kvm *kvm)
+{
+       return 0;
+}
+
 #endif /* CONFIG_MMU_NOTIFIER && KVM_ARCH_WANT_MMU_NOTIFIER */
 
 static struct kvm *kvm_create_vm(void)
@@ -373,11 +387,7 @@ static struct kvm *kvm_create_vm(void)
                        (struct kvm_coalesced_mmio_ring *)page_address(page);
 #endif
 
-#if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
-       kvm->mmu_notifier.ops = &kvm_mmu_notifier_ops;
-       r = mmu_notifier_register(&kvm->mmu_notifier, current->mm);
-#endif
-
+       r = kvm_init_mmu_notifier(kvm);
        if (r) {
 #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
                put_page(page);