lkml.org 
[lkml]   [2021]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 3/9] KVM: Allow to have arch-specific per-vm debugfs files
    Date
    Allow archs to create arch-specific nodes under kvm->debugfs_dentry directory
    besides the stats fields. The new interface kvm_arch_create_vm_debugfs() is
    defined but not yet used. It's called after kvm->debugfs_dentry is created, so
    it can be referenced directly in kvm_arch_create_vm_debugfs(). Arch should
    define their own versions when they want to create extra debugfs nodes.

    Signed-off-by: Peter Xu <peterx@redhat.com>
    ---
    include/linux/kvm_host.h | 1 +
    virt/kvm/kvm_main.c | 20 +++++++++++++++++++-
    2 files changed, 20 insertions(+), 1 deletion(-)

    diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
    index c6fcd75dd8b9..8521d3492eb2 100644
    --- a/include/linux/kvm_host.h
    +++ b/include/linux/kvm_host.h
    @@ -1035,6 +1035,7 @@ bool kvm_arch_dy_runnable(struct kvm_vcpu *vcpu);
    bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu);
    int kvm_arch_post_init_vm(struct kvm *kvm);
    void kvm_arch_pre_destroy_vm(struct kvm *kvm);
    +int kvm_arch_create_vm_debugfs(struct kvm *kvm);

    #ifndef __KVM_HAVE_ARCH_VM_ALLOC
    /*
    diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
    index 79b0c1b7b284..516ba8d25bda 100644
    --- a/virt/kvm/kvm_main.c
    +++ b/virt/kvm/kvm_main.c
    @@ -895,7 +895,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
    char dir_name[ITOA_MAX_LEN * 2];
    struct kvm_stat_data *stat_data;
    const struct _kvm_stats_desc *pdesc;
    - int i;
    + int i, ret;
    int kvm_debugfs_num_entries = kvm_vm_stats_header.num_desc +
    kvm_vcpu_stats_header.num_desc;

    @@ -940,6 +940,13 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
    kvm->debugfs_dentry, stat_data,
    &stat_fops_per_vm);
    }
    +
    + ret = kvm_arch_create_vm_debugfs(kvm);
    + if (ret) {
    + kvm_destroy_vm_debugfs(kvm);
    + return i;
    + }
    +
    return 0;
    }

    @@ -960,6 +967,17 @@ void __weak kvm_arch_pre_destroy_vm(struct kvm *kvm)
    {
    }

    +/*
    + * Called after per-vm debugfs created. When called kvm->debugfs_dentry should
    + * be setup already, so we can create arch-specific debugfs entries under it.
    + * Cleanup should be automatic done in kvm_destroy_vm_debugfs() recursively, so
    + * a per-arch destroy interface is not needed.
    + */
    +int __weak kvm_arch_create_vm_debugfs(struct kvm *kvm)
    +{
    + return 0;
    +}
    +
    static struct kvm *kvm_create_vm(unsigned long type)
    {
    struct kvm *kvm = kvm_arch_alloc_vm();
    --
    2.31.1
    \
     
     \ /
      Last update: 2021-06-25 17:32    [W:4.254 / U:0.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site