[lxc-devel] [PATCH 3/2] nbd: exit cleanly if nbd fails to attach
Serge Hallyn
serge.hallyn at ubuntu.com
Thu May 15 15:26:48 UTC 2014
Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
src/lxc/bdev.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
index e22d83d..1d9a25a 100644
--- a/src/lxc/bdev.c
+++ b/src/lxc/bdev.c
@@ -2491,7 +2491,15 @@ static int do_attach_nbd(void *d)
exit(0);
} else if (fdsi.ssi_signo == SIGCHLD) {
int status;
- while (waitpid(-1, &status, WNOHANG) > 0);
+ /* If qemu-nbd fails, or is killed by a signal,
+ * then exit */
+ while (waitpid(-1, &status, WNOHANG) > 0) {
+ if ((WIFEXITED(status) && WEXITSTATUS(status) != 0) ||
+ WIFSIGNALED(status)) {
+ nbd_detach(nbd);
+ exit(1);
+ }
+ }
}
}
}
--
1.9.1
More information about the lxc-devel
mailing list