From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQgOL-0002ZL-70 for qemu-devel@nongnu.org; Wed, 25 Feb 2015 13:09:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQgOK-0001ic-7U for qemu-devel@nongnu.org; Wed, 25 Feb 2015 13:09:01 -0500 From: Max Reitz Date: Wed, 25 Feb 2015 13:08:20 -0500 Message-Id: <1424887718-10800-8-git-send-email-mreitz@redhat.com> In-Reply-To: <1424887718-10800-1-git-send-email-mreitz@redhat.com> References: <1424887718-10800-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 07/25] nbd: Add "failed to open export" error message List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz In case the connection is closed before the export length can be read, and an export name had been specified, this generally indicates that for some reason the export could not be opened (e.g. there is no export with that name). Make the error message reflect this. Signed-off-by: Max Reitz --- nbd.c | 6 +++++- tests/qemu-iotests/096.out | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nbd.c b/nbd.c index 77d1158..ad0948b 100644 --- a/nbd.c +++ b/nbd.c @@ -600,7 +600,11 @@ int nbd_receive_negotiate(int csock, const char *name, uint32_t *flags, } if (read_sync(csock, &s, sizeof(s)) != sizeof(s)) { - error_setg(errp, "Failed to read export length"); + if (name) { + error_setg(errp, "Failed to open export"); + } else { + error_setg(errp, "Failed to read export length"); + } goto fail; } *size = be64_to_cpu(s); diff --git a/tests/qemu-iotests/096.out b/tests/qemu-iotests/096.out index cc10e51..80d542a 100644 --- a/tests/qemu-iotests/096.out +++ b/tests/qemu-iotests/096.out @@ -9,7 +9,7 @@ read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "drv", "tray-open": true}} {"return": {}} -qemu-io: can't open device nbd://127.0.0.1:PORT/drv: Failed to read export length +qemu-io: can't open device nbd://127.0.0.1:PORT/drv: Failed to open export no file open, try 'help open' {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} -- 2.1.0