From: Paolo Bonzini <pbonzini@redhat.com>
To: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>,
David Hildenbrand <david@redhat.com>
Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/1] KVM: trigger uevents when starting or stopping a VM
Date: Mon, 10 Jul 2017 13:54:04 +0200 [thread overview]
Message-ID: <d328ae8a-68c8-ac95-29c6-1c685ca1bfa4@redhat.com> (raw)
In-Reply-To: <20170710135311.24600ce2@p-imbrenda.boeblingen.de.ibm.com>
On 10/07/2017 13:53, Claudio Imbrenda wrote:
> On Mon, 10 Jul 2017 11:40:55 +0200
> David Hildenbrand <david@redhat.com> wrote:
>
>> On 10.07.2017 11:20, Claudio Imbrenda wrote:
>>
>> Minor minor nit:
>>
>> The subject should state "creating or destroying a VM"
>
> I'll fix it
I can fix it when applying, no problem.
Paolo
> [...]
>
>>> +static void kvm_uevent_notify_change(unsigned int type, struct kvm
>>> *kvm) +{
>>> + char cbuf[32], abuf[32], pidbuf[32], evbuf[16];
>>
>> do we really need that much space for a pid?
>
> unfortunately yes. we don't have access to the pid when destroying the
> VM, so I take it from the debugfs entry, and that has the format
> "%d-%d", with pid and file descriptor, both can be 10 bytes long.
>
>>> + const char pathvar[11] = "STATS_PATH=";
>>> + char *ptr[6] = {cbuf, abuf, pidbuf, NULL, NULL, NULL};
>>> + char *tmp, *pathbuf;
>>> + unsigned long long created, active;
>>> + int idx = 3;
>>> +
>>> + if (!kvm_dev.this_device || !kvm || !kvm->debugfs_dentry)
>>> + return;
>>> +
>>> + spin_lock(&kvm_lock);
>>> + if (type == KVM_EVENT_CREATE_VM) {
>>> + kvm_createvm_count++;
>>> + kvm_active_vms++;
>>> + } else if (type == KVM_EVENT_DESTROY_VM) {
>>> + kvm_active_vms--;
>>> + }
>>> + created = kvm_createvm_count;
>>> + active = kvm_active_vms;
>>> + spin_unlock(&kvm_lock);
>>> +
>>> + pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
>>> + if (pathbuf) {
>>> + tmp = dentry_path_raw(kvm->debugfs_dentry,
>>> + pathbuf + sizeof(pathvar),
>>> + PATH_MAX - sizeof(pathvar));
>>> + if (!IS_ERR(tmp)) {
>>> + memcpy(tmp - sizeof(pathvar), pathvar,
>>> sizeof(pathvar));
>>> + ptr[idx++] = tmp - sizeof(pathvar);
>>> + }
>>> + }
>>> + snprintf(cbuf, sizeof(cbuf), "CREATED=%llu", created);
>>
>> Did you think about using struct kobj_uevent_env / add_uevent_var()?
>
> for what I could see, that only works with a more invasive patch. I'll
> see what I can do.
>
>> But most probably the problem here is special handling for
>> dentry_path_raw().
>
>
prev parent reply other threads:[~2017-07-10 11:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-10 9:20 [PATCH v3 0/1] Claudio Imbrenda
2017-07-10 9:20 ` [PATCH v3 1/1] KVM: trigger uevents when starting or stopping a VM Claudio Imbrenda
2017-07-10 9:40 ` David Hildenbrand
2017-07-10 11:53 ` Claudio Imbrenda
2017-07-10 11:54 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d328ae8a-68c8-ac95-29c6-1c685ca1bfa4@redhat.com \
--to=pbonzini@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=david@redhat.com \
--cc=imbrenda@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®