kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: move kvm_create_vcpu_debugfs after last failure point
@ 2020-03-31 22:42 Paolo Bonzini
  2020-04-13  9:13 ` Emanuele Giuseppe Esposito
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2020-03-31 22:42 UTC (permalink / raw)
  To: linux-kernel, kvm; +Cc: eesposit

The placement of kvm_create_vcpu_debugfs is more or less irrelevant, since
it cannot fail and userspace should not care about the debugfs entries until
it knows the vcpu has been created.  Moving it after the last failure
point removes the need to remove the directory when unwinding the creation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 virt/kvm/kvm_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 027259af883e..0a78e1d874ed 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2823,8 +2823,6 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
 	if (r)
 		goto vcpu_free_run_page;
 
-	kvm_create_vcpu_debugfs(vcpu);
-
 	mutex_lock(&kvm->lock);
 	if (kvm_get_vcpu_by_id(kvm, id)) {
 		r = -EEXIST;
@@ -2853,11 +2851,11 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
 
 	mutex_unlock(&kvm->lock);
 	kvm_arch_vcpu_postcreate(vcpu);
+	kvm_create_vcpu_debugfs(vcpu);
 	return r;
 
 unlock_vcpu_destroy:
 	mutex_unlock(&kvm->lock);
-	debugfs_remove_recursive(vcpu->debugfs_dentry);
 	kvm_arch_vcpu_destroy(vcpu);
 vcpu_free_run_page:
 	free_page((unsigned long)vcpu->run);
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: x86: move kvm_create_vcpu_debugfs after last failure point
  2020-03-31 22:42 [PATCH] KVM: x86: move kvm_create_vcpu_debugfs after last failure point Paolo Bonzini
@ 2020-04-13  9:13 ` Emanuele Giuseppe Esposito
  0 siblings, 0 replies; 2+ messages in thread
From: Emanuele Giuseppe Esposito @ 2020-04-13  9:13 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: linux-kernel, kvm



On 01/04/2020 00:42, Paolo Bonzini wrote:
> The placement of kvm_create_vcpu_debugfs is more or less irrelevant, since
> it cannot fail and userspace should not care about the debugfs entries until
> it knows the vcpu has been created.  Moving it after the last failure
> point removes the need to remove the directory when unwinding the creation.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>

> ---
>   virt/kvm/kvm_main.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 027259af883e..0a78e1d874ed 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2823,8 +2823,6 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
>   	if (r)
>   		goto vcpu_free_run_page;
>   
> -	kvm_create_vcpu_debugfs(vcpu);
> -
>   	mutex_lock(&kvm->lock);
>   	if (kvm_get_vcpu_by_id(kvm, id)) {
>   		r = -EEXIST;
> @@ -2853,11 +2851,11 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
>   
>   	mutex_unlock(&kvm->lock);
>   	kvm_arch_vcpu_postcreate(vcpu);
> +	kvm_create_vcpu_debugfs(vcpu);
>   	return r;
>   
>   unlock_vcpu_destroy:
>   	mutex_unlock(&kvm->lock);
> -	debugfs_remove_recursive(vcpu->debugfs_dentry);
>   	kvm_arch_vcpu_destroy(vcpu);
>   vcpu_free_run_page:
>   	free_page((unsigned long)vcpu->run);
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-13  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-31 22:42 [PATCH] KVM: x86: move kvm_create_vcpu_debugfs after last failure point Paolo Bonzini
2020-04-13  9:13 ` Emanuele Giuseppe Esposito

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).