Skip to contentSkip to conversation

Error-handling fixes for passt

PATCH In review Peter Foley 2 participants 4 messages Mar 5 – Mar 9 Networking

lore
Share & tools
lore
#0 lore raw

v2 cover Error-handling fixes for passt

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

---
Changes in v2:
- Fixed indentation.
- Added Reviewed-By.
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]

---
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,

Signature · 1 line
Peter Foley <[email protected]>
#1 lore raw

PATCH v2 1/2 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.

---
 net/passt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/passt.c +3 -1
index 9ed811a514..b3d4b71314 100644
@@ -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));
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
#2 lore raw

PATCH v2 2/2 Don't try to read the pidfile if passt got a signal

In reply to 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.

---
 net/passt.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
net/passt.c +11 -2
index b3d4b71314..4ff94ee509 100644
@@ -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;
     }
 
Signature · 1 line
2.53.0.473.g4a7958ca14-goog