Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753925AbdGJLyL (ORCPT ); Mon, 10 Jul 2017 07:54:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37266 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753649AbdGJLyJ (ORCPT ); Mon, 10 Jul 2017 07:54:09 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3E5DA80481 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=pbonzini@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3E5DA80481 Subject: Re: [PATCH v3 1/1] KVM: trigger uevents when starting or stopping a VM To: Claudio Imbrenda , David Hildenbrand Cc: kvm@vger.kernel.org, borntraeger@de.ibm.com, linux-kernel@vger.kernel.org References: <1499678444-21879-1-git-send-email-imbrenda@linux.vnet.ibm.com> <1499678444-21879-2-git-send-email-imbrenda@linux.vnet.ibm.com> <852e01e7-81f4-7fcb-dc55-80f4aed029c0@redhat.com> <20170710135311.24600ce2@p-imbrenda.boeblingen.de.ibm.com> From: Paolo Bonzini Message-ID: Date: Mon, 10 Jul 2017 13:54:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20170710135311.24600ce2@p-imbrenda.boeblingen.de.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 10 Jul 2017 11:54:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2031 Lines: 70 On 10/07/2017 13:53, Claudio Imbrenda wrote: > On Mon, 10 Jul 2017 11:40:55 +0200 > David Hildenbrand 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(). > >