public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Error-handling fixes for passt
@ 2026-03-05 16:04 Peter Foley
  2026-03-05 16:04 ` [PATCH v2 1/2] Only kill passt if it wrote a pidfile Peter Foley
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Foley @ 2026-03-05 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jason Wang, Laurent Vivier, Peter Foley

Some fixes for passt error handling that showed up when
trying to enable support with an internal Google framework.

Signed-off-by: Peter Foley <pefoley@google.com>
---
Changes in v2:
- Fixed indentation.
- Added Reviewed-By.
- Link to v1: https://lore.kernel.org/qemu-devel/20260223-passt-v1-0-101c6ba1c88a@google.com

---
Peter Foley (2):
      Only kill passt if it wrote a pidfile
      Don't try to read the pidfile if passt got a signal

 net/passt.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
---
base-commit: afe653676dc6dfd49f0390239ff90b2f0052c2b8
change-id: 20260223-passt-0708603dc495

Best regards,
-- 
Peter Foley <pefoley@google.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] Only kill passt if it wrote a pidfile
  2026-03-05 16:04 [PATCH v2 0/2] Error-handling fixes for passt Peter Foley
@ 2026-03-05 16:04 ` Peter Foley
  2026-03-05 16:04 ` [PATCH v2 2/2] Don't try to read the pidfile if passt got a signal Peter Foley
  2026-03-09 14:15 ` [PATCH v2 0/2] Error-handling fixes for passt Philippe Mathieu-Daudé
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Foley @ 2026-03-05 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jason Wang, Laurent Vivier, Peter Foley

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>
---
 net/passt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/passt.c b/net/passt.c
index 9ed811a514..b3d4b71314 100644
--- a/net/passt.c
+++ b/net/passt.c
@@ -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));

-- 
2.53.0.473.g4a7958ca14-goog



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] Don't try to read the pidfile if passt got a signal
  2026-03-05 16:04 [PATCH v2 0/2] Error-handling fixes for passt Peter Foley
  2026-03-05 16:04 ` [PATCH v2 1/2] Only kill passt if it wrote a pidfile Peter Foley
@ 2026-03-05 16:04 ` Peter Foley
  2026-03-09 14:15 ` [PATCH v2 0/2] Error-handling fixes for passt Philippe Mathieu-Daudé
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Foley @ 2026-03-05 16:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jason Wang, Laurent Vivier, Peter Foley

g_subprocess_get_if_exited returns false if passt was killed by a signal, so we fall through to trying to read the pidfile.

Update the error when passt exits to include the exit code.

Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Peter Foley <pefoley@google.com>
---
 net/passt.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/passt.c b/net/passt.c
index b3d4b71314..4ff94ee509 100644
--- a/net/passt.c
+++ b/net/passt.c
@@ -270,8 +270,17 @@ static int net_passt_start_daemon(NetPasstState *s, int sock, Error **errp)
         return -1;
     }
 
-    if (g_subprocess_get_if_exited(daemon) &&
-        g_subprocess_get_exit_status(daemon)) {
+    if (g_subprocess_get_if_exited(daemon)) {
+        gint status = g_subprocess_get_exit_status(daemon);
+        if (status) {
+            error_setg(errp, "Passt exited with code %d", status);
+            return -1;
+        }
+    }
+
+    if (g_subprocess_get_if_signaled(daemon)) {
+        error_setg(errp, "Passt killed with signal %d",
+                   g_subprocess_get_term_sig(daemon));
         return -1;
     }
 

-- 
2.53.0.473.g4a7958ca14-goog



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] Error-handling fixes for passt
  2026-03-05 16:04 [PATCH v2 0/2] Error-handling fixes for passt Peter Foley
  2026-03-05 16:04 ` [PATCH v2 1/2] Only kill passt if it wrote a pidfile Peter Foley
  2026-03-05 16:04 ` [PATCH v2 2/2] Don't try to read the pidfile if passt got a signal Peter Foley
@ 2026-03-09 14:15 ` Philippe Mathieu-Daudé
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-03-09 14:15 UTC (permalink / raw)
  To: Peter Foley, qemu-devel; +Cc: Jason Wang, Laurent Vivier

On 5/3/26 17:04, Peter Foley wrote:

> Peter Foley (2):
>        Only kill passt if it wrote a pidfile
>        Don't try to read the pidfile if passt got a signal

I'll queue these via my hw-misc tree, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-09 14:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 16:04 [PATCH v2 0/2] Error-handling fixes for passt Peter Foley
2026-03-05 16:04 ` [PATCH v2 1/2] Only kill passt if it wrote a pidfile Peter Foley
2026-03-05 16:04 ` [PATCH v2 2/2] Don't try to read the pidfile if passt got a signal Peter Foley
2026-03-09 14:15 ` [PATCH v2 0/2] Error-handling fixes for passt Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox