$ rm -f /tmp/sock /tmp/pid $ qemu-img create -f qcow2 /tmp/disk.qcow2 1M $ qemu-nbd -t --format=qcow2 --socket=/tmp/sock --pid-file=/tmp/pid /tmp/disk.qcow2 & $ nbdsh -u 'nbd+unix:///?socket=/tmp/sock' -c 'h.get_size()' qemu-nbd: Disconnect client, due to: Failed to send reply: Unable to write to socket: Broken pipe $ killall qemu-nbd
nbdsh is abruptly dropping the NBD connection here which is a valid way to close the connection. It seems unnecessary to print an error in this case so this commit suppresses it. Note that if you call the nbdsh h.shutdown() method then the message was not printed: $ nbdsh -u 'nbd+unix:///?socket=/tmp/sock' -c 'h.get_size()' -c 'h.shutdown()' Signed-off-by: Richard W.M. Jones <rjo...@redhat.com> --- nbd/server.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nbd/server.c b/nbd/server.c index b60ebc3ab6..0f86535b88 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2668,7 +2668,11 @@ static coroutine_fn void nbd_trip(void *opaque) ret = nbd_handle_request(client, &request, req->data, &local_err); } if (ret < 0) { - error_prepend(&local_err, "Failed to send reply: "); + if (errno != EPIPE) { + error_prepend(&local_err, "Failed to send reply: "); + } else { + local_err = NULL; + } goto disconnect; } -- 2.32.0