Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: Get rid of return value from kvm_arch_create_vm_debugfs()

The general expectation with debugfs is that any initialization failure
is nonfatal. Nevertheless, kvm_arch_create_vm_debugfs() allows
implementations to return an error and kvm_create_vm_debugfs() allows
that to fail VM creation.

Change to a void return to discourage architectures from making debugfs
failures fatal for the VM. Seems like everyone already had the right
idea, as all implementations already return 0 unconditionally.

Acked-by: Marc Zyngier <maz@kernel.org>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Link: https://lore.kernel.org/r/20240216155941.2029458-1-oliver.upton@linux.dev
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>

+5 -11
+1 -2
arch/powerpc/kvm/powerpc.c
··· 2538 2538 vcpu->kvm->arch.kvm_ops->create_vcpu_debugfs(vcpu, debugfs_dentry); 2539 2539 } 2540 2540 2541 - int kvm_arch_create_vm_debugfs(struct kvm *kvm) 2541 + void kvm_arch_create_vm_debugfs(struct kvm *kvm) 2542 2542 { 2543 2543 if (kvm->arch.kvm_ops->create_vm_debugfs) 2544 2544 kvm->arch.kvm_ops->create_vm_debugfs(kvm); 2545 - return 0; 2546 2545 }
+1 -2
arch/x86/kvm/debugfs.c
··· 189 189 .release = kvm_mmu_rmaps_stat_release, 190 190 }; 191 191 192 - int kvm_arch_create_vm_debugfs(struct kvm *kvm) 192 + void kvm_arch_create_vm_debugfs(struct kvm *kvm) 193 193 { 194 194 debugfs_create_file("mmu_rmaps_stat", 0644, kvm->debugfs_dentry, kvm, 195 195 &mmu_rmaps_stat_fops); 196 - return 0; 197 196 }
+1 -1
include/linux/kvm_host.h
··· 1507 1507 bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu); 1508 1508 int kvm_arch_post_init_vm(struct kvm *kvm); 1509 1509 void kvm_arch_pre_destroy_vm(struct kvm *kvm); 1510 - int kvm_arch_create_vm_debugfs(struct kvm *kvm); 1510 + void kvm_arch_create_vm_debugfs(struct kvm *kvm); 1511 1511 1512 1512 #ifndef __KVM_HAVE_ARCH_VM_ALLOC 1513 1513 /*
+2 -6
virt/kvm/kvm_main.c
··· 1150 1150 &stat_fops_per_vm); 1151 1151 } 1152 1152 1153 - ret = kvm_arch_create_vm_debugfs(kvm); 1154 - if (ret) 1155 - goto out_err; 1156 - 1153 + kvm_arch_create_vm_debugfs(kvm); 1157 1154 return 0; 1158 1155 out_err: 1159 1156 kvm_destroy_vm_debugfs(kvm); ··· 1180 1183 * Cleanup should be automatic done in kvm_destroy_vm_debugfs() recursively, so 1181 1184 * a per-arch destroy interface is not needed. 1182 1185 */ 1183 - int __weak kvm_arch_create_vm_debugfs(struct kvm *kvm) 1186 + void __weak kvm_arch_create_vm_debugfs(struct kvm *kvm) 1184 1187 { 1185 - return 0; 1186 1188 } 1187 1189 1188 1190 static struct kvm *kvm_create_vm(unsigned long type, const char *fdname)