]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vmspawn: close host vsock fd once we passed it to the child
authorLennart Poettering <lennart@poettering.net>
Fri, 19 Jan 2024 17:05:32 +0000 (18:05 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 22 Jan 2024 13:03:09 +0000 (14:03 +0100)
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

index a136ae4c3c324b7734e3b33bd4983a6601c7fac0..5341699b79cb34425b6d0b7c1c1d48296f0237af 100644 (file)
@@ -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, &notify_event_source);