Message ID | 20220720092259.3491733-7-oliver.upton@linux.dev (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: Clean up debugfs init/destroy | expand |
On Wed, Jul 20, 2022, Oliver Upton wrote: > From: Oliver Upton <oupton@google.com> > > Since KVM now sanely handles debugfs init/destroy w.r.t. the VM, it is > safe to hoist kvm_create_vm_debugfs() back into kvm_create_vm(). The > author of this commit remains bitter for having been burned by the old > wreck in commit a44a4cc1c969 ("KVM: Don't create VM debugfs files > outside of the VM directory"). > > Signed-off-by: Oliver Upton <oupton@google.com> > Reviewed-by: Sean Christopherson <seanjc@google.com> Heh, so this amusingly has my review, but I'd rather omit this patch and leave the initialization with the pile of other code that initializes fields for which zero-initialization is insufficient/incorrect. Any objections to dropping this? > --- > virt/kvm/kvm_main.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 609f49a133f8..7ac60f75cfa1 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -1032,6 +1032,12 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, const char *fdname) > int kvm_debugfs_num_entries = kvm_vm_stats_header.num_desc + > kvm_vcpu_stats_header.num_desc; > > + /* > + * Force subsequent debugfs file creations to fail if the VM directory > + * is not created. > + */ > + kvm->debugfs_dentry = ERR_PTR(-ENOENT); > + > if (!debugfs_initialized()) > return 0; > > @@ -1154,12 +1160,6 @@ static struct kvm *kvm_create_vm(unsigned long type, const char *fdname) > > BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX); > > - /* > - * Force subsequent debugfs file creations to fail if the VM directory > - * is not created (by kvm_create_vm_debugfs()). > - */ > - kvm->debugfs_dentry = ERR_PTR(-ENOENT); > - > snprintf(kvm->stats_id, sizeof(kvm->stats_id), "kvm-%d", > task_pid_nr(current)); > > -- > 2.37.0.170.g444d1eabd0-goog >
On 8/5/22 21:02, Sean Christopherson wrote: > Heh, so this amusingly has my review, but I'd rather omit this patch and leave > the initialization with the pile of other code that initializes fields for which > zero-initialization is insufficient/incorrect. > > Any objections to dropping this? Yeah, I was going to say the same. The points before and after this patch are far enough that I'm a bit more confident leaving it out. Paolo
On Tue, Aug 09, 2022 at 04:56:28PM +0200, Paolo Bonzini wrote: > On 8/5/22 21:02, Sean Christopherson wrote: > > Heh, so this amusingly has my review, but I'd rather omit this patch and leave > > the initialization with the pile of other code that initializes fields for which > > zero-initialization is insufficient/incorrect. > > > > Any objections to dropping this? > > Yeah, I was going to say the same. The points before and after this patch > are far enough that I'm a bit more confident leaving it out. Sounds reasonable to me. To be fair, I mostly threw this patch at the end to poke fun at the original mistake :) -- Thanks, Oliver
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 609f49a133f8..7ac60f75cfa1 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1032,6 +1032,12 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, const char *fdname) int kvm_debugfs_num_entries = kvm_vm_stats_header.num_desc + kvm_vcpu_stats_header.num_desc; + /* + * Force subsequent debugfs file creations to fail if the VM directory + * is not created. + */ + kvm->debugfs_dentry = ERR_PTR(-ENOENT); + if (!debugfs_initialized()) return 0; @@ -1154,12 +1160,6 @@ static struct kvm *kvm_create_vm(unsigned long type, const char *fdname) BUILD_BUG_ON(KVM_MEM_SLOTS_NUM > SHRT_MAX); - /* - * Force subsequent debugfs file creations to fail if the VM directory - * is not created (by kvm_create_vm_debugfs()). - */ - kvm->debugfs_dentry = ERR_PTR(-ENOENT); - snprintf(kvm->stats_id, sizeof(kvm->stats_id), "kvm-%d", task_pid_nr(current));