Error-handling fixes for passt
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]>
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
@@ -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
PATCH v2 2/2 Don't try to read the pidfile if passt got a signal
In reply to Peter Foleyg_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
@@ -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
Quoted 3 lines · Peter Foley
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.