Error-handling fixes for passt
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.
---
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 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.371.g1d285c8824-goog
Re: [PATCH 1/2] Only kill passt if it wrote a pidfile
Quoted 16 lines · 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.
Signed-off-by Peter Foley <[email protected]>--- net/passt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)net/passt.c +0
-0
net/passt.c static void net_passt_cleanup(NetClientState *nc) · line 110
Quoted 10 lines
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));
PATCH 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.371.g1d285c8824-goog
Re: [PATCH 2/2] Don't try to read the pidfile if passt got a signal
Quoted 15 lines · Peter Foley
g_subprocess_get_if_exitedreturns 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.
Signed-off-by Peter Foley <[email protected]>--- net/passt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)net/passt.c +0
-0@@ -270,8 +270,17 @@ static int net_passt_start_daemon(NetPasstState *s, int sock, Error **errp)return -1 ;
net/passt.c static int net_passt_start_daemon(NetPasstState *s, int sock, Error **errp) · line 278
Quoted 10 lines
net/passt.c +6
-2} -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 ; + }
^^^
Indentation problem (6 spaces instead of 8)
net/passt.c static int net_passt_start_daemon(NetPasstState *s, int sock, Error **errp) · line 286
Quoted 9 lines
net/passt.c +5
-0+ } + +if (g_subprocess_get_if_signaled (daemon)) { +error_setg (errp,"Passt killed with signal %d" , +g_subprocess_get_term_sig (daemon));return -1 ; }
Adding Laurent.
Quoted 20 lines · 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 <[email protected]>---
Peter Foley (2):
Only kill passt if it wrote a pidfile Don't try to read the pidfile if passt got a signalnet/passt.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)---
base-commit:afe653676dc6dfd49f0390239ff90b2f0052c2b8
change-id: 20260223-passt-0708603dc495Best regards,
--
Peter Foley <[email protected]>