From c7c6b6f28c2c006c059d40d5d6a7032f42ad8252 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 19 Jan 2024 18:05:32 +0100 Subject: [PATCH] vmspawn: close host vsock fd once we passed it to the child Without this I qemu simply froze in a weird state for me if I kill it: it was supposedly a zombie, but we'd get the pidfd POLLIN event for it only once the fd is closed. Hence let's close it right-away. (Smells like a kernel issue actually, but too lazy to bother with this). --- src/vmspawn/vmspawn.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index a136ae4c3c..5341699b79 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -696,6 +696,9 @@ static int run_virtual_machine(void) { _exit(EXIT_FAILURE); } + /* Close the vsock fd we passed to qemu in the parent. We don't need it anymore. */ + child_vsock_fd = safe_close(child_vsock_fd); + int exit_status = INT_MAX; if (use_vsock) { r = setup_notify_parent(event, vsock_fd, &exit_status, ¬ify_event_source);