Received: from eggs.gnu.org ([140.186.70.92]:42315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROv1j-0005mO-SA for qemu-devel@nongnu.org; Fri, 11 Nov 2011 12:36:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROv1i-0000IW-UB for qemu-devel@nongnu.org; Fri, 11 Nov 2011 12:36:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROv1i-0000IB-Ht for qemu-devel@nongnu.org; Fri, 11 Nov 2011 12:36:30 -0500 From: Kevin Wolf Date: Fri, 11 Nov 2011 18:39:17 +0100 Message-Id: <1321033168-8739-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1321033168-8739-1-git-send-email-kwolf@redhat.com> References: <1321033168-8739-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 05/16] nbd: treat EPIPE from NBD_DO_IT as success List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Paolo Bonzini This can be seen with "qemu-nbd -v -c", which returns 1 instead of 0 when you disconnect with "qemu-nbd -d". Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- nbd.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/nbd.c b/nbd.c index fb5e424..e6c931c 100644 --- a/nbd.c +++ b/nbd.c @@ -425,6 +425,13 @@ int nbd_client(int fd) TRACE("Doing NBD loop"); ret = ioctl(fd, NBD_DO_IT); + if (ret == -1 && errno == EPIPE) { + /* NBD_DO_IT normally returns EPIPE when someone has disconnected + * the socket via NBD_DISCONNECT. We do not want to return 1 in + * that case. + */ + ret = 0; + } serrno = errno; TRACE("NBD loop returned %d: %s", ret, strerror(serrno)); -- 1.7.6.4