all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] qmeventd: explicitly close() pidfds
Date: Tue,  9 Feb 2021 16:24:07 +0100	[thread overview]
Message-ID: <20210209152407.5871-1-s.reiter@proxmox.com> (raw)

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 <s.reiter@proxmox.com>
---

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





             reply	other threads:[~2021-02-09 15:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-09 15:24 Stefan Reiter [this message]
2021-02-11 16:17 ` [pve-devel] applied: " Thomas Lamprecht

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=20210209152407.5871-1-s.reiter@proxmox.com \
    --to=s.reiter@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal