]> git.proxmox.com Git - mirror_qemu.git/commitdiff
nbd: treat EPIPE from NBD_DO_IT as success
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 4 Nov 2011 14:51:18 +0000 (15:51 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 11 Nov 2011 13:02:58 +0000 (14:02 +0100)
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 <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
nbd.c

diff --git a/nbd.c b/nbd.c
index fb5e424abe9d2120a353049e87970d7176ad36fc..e6c931c5ceed95387dd7455bfb2110a23a96caf7 100644 (file)
--- 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));