From 1ce52846d3ce0e4b58caebcae84719bef6401fbb Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Mon, 26 Jan 2015 21:02:59 -0500 Subject: nbd: Improve error messages This patch makes use of the Error object for nbd_receive_negotiate() so that errors during negotiation look nicer. Furthermore, this patch adds an additional error message if the received magic was wrong, but would be correct for the other protocol version, respectively: So if an export name was specified, but the NBD server magic corresponds to an old handshake, this condition is explicitly signaled to the user, and vice versa. As these messages are now part of the "Could not open image" error message, additional filtering has to be employed in iotest 083, which this patch does as well. Signed-off-by: Max Reitz Reviewed-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- qemu-nbd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'qemu-nbd.c') diff --git a/qemu-nbd.c b/qemu-nbd.c index d222512412..4d8df08385 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -284,6 +284,7 @@ static void *nbd_client_thread(void *arg) int fd, sock; int ret; pthread_t show_parts_thread; + Error *local_error = NULL; sock = unix_socket_outgoing(sockpath); if (sock < 0) { @@ -291,8 +292,12 @@ static void *nbd_client_thread(void *arg) } ret = nbd_receive_negotiate(sock, NULL, &nbdflags, - &size, &blocksize); + &size, &blocksize, &local_error); if (ret < 0) { + if (local_error) { + fprintf(stderr, "%s\n", error_get_pretty(local_error)); + error_free(local_error); + } goto out_socket; } -- cgit v1.2.3