From: Serge Hallyn Date: Thu, 15 May 2014 15:26:48 +0000 (+0000) Subject: nbd: exit cleanly if nbd fails to attach X-Git-Tag: lxc-1.1.0.alpha1~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3abd3e54eb69201ccb72f758d1cd126311dc3055;p=thirdparty%2Flxc.git nbd: exit cleanly if nbd fails to attach Signed-off-by: Serge Hallyn Acked-by: Dwight Engen --- diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c index e22d83dba..751fa9fc6 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); + } + } } } }