net/passt: Only kill passt if it wrote a pidfile

Avoid killing qemu if passt failed before writing a pidfile.

pid is initialized to 0, so calling pid in this scenario would kill the
entire process group.

Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Peter Foley <pefoley@google.com>
Message-ID: <20260305-passt-v2-1-f0582198afc0@google.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Peter Foley
2026-03-05 11:04:56 -05:00
committed by Philippe Mathieu-Daudé
parent 4efd93949f
commit a1596cdc37

View File

@@ -102,7 +102,9 @@ static void net_passt_cleanup(NetClientState *nc)
}
#endif
kill(s->pid, SIGTERM);
if (s->pid > 0) {
kill(s->pid, SIGTERM);
}
if (g_remove(s->pidfile) != 0) {
warn_report("Failed to remove passt pidfile %s: %s",
s->pidfile, strerror(errno));