From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C034B6331B for ; Tue, 9 Feb 2021 16:24:18 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B10582F418 for ; Tue, 9 Feb 2021 16:24:18 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1F1E72F40D for ; Tue, 9 Feb 2021 16:24:17 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id D981A454E9 for ; Tue, 9 Feb 2021 16:24:16 +0100 (CET) From: Stefan Reiter To: pve-devel@lists.proxmox.com Date: Tue, 9 Feb 2021 16:24:07 +0100 Message-Id: <20210209152407.5871-1-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.036 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Subject: [pve-devel] [PATCH qemu-server] qmeventd: explicitly close() pidfds X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2021 15:24:18 -0000 In most circumstances a pidfd gets closed automatically once the child dies, and that *should* be guaranteed by us calling SIGKILL - however, it seems that sometimes that doesn't happen, leading to leaked file descriptors[0]. Also add a small note to verbose mode showing when the late-cleanup actually happens, helped during debug. [0] https://forum.proxmox.com/threads/cannot-shutdown-vm.83911/ Signed-off-by: Stefan Reiter --- I'm puzzled by this, and I'm not entirely sure this is the full fix, but it does seem like a good idea to close the fds explicitly anyway. qmeventd/qmeventd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qmeventd/qmeventd.c b/qmeventd/qmeventd.c index 57f1867..a14c331 100644 --- a/qmeventd/qmeventd.c +++ b/qmeventd/qmeventd.c @@ -600,6 +600,7 @@ sigkill(void *ptr, __attribute__((unused)) void *unused) if (data.pidfd > 0) { err = pidfd_send_signal(data.pidfd, SIGKILL, NULL, 0); + (void)close(data.pidfd); } else { err = kill(data.pid, SIGKILL); } @@ -619,6 +620,7 @@ static void handle_forced_cleanup() { if (alarm_triggered) { + VERBOSE_PRINT("clearing forced cleanup backlog\n"); alarm_triggered = 0; g_slist_foreach(forced_cleanups, sigkill, NULL); g_slist_free_full(forced_cleanups, free); -- 2.20.1