aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2015-01-26 21:02:59 -0500
committerKevin Wolf <kwolf@redhat.com>2015-02-06 17:24:22 +0100
commit1ce52846d3ce0e4b58caebcae84719bef6401fbb (patch)
tree47f86eff873a997ea9eb11e0804cd6b4b5757b61 /block
parenta231cb272611c758d45135f6a35a4dd1beaf5585 (diff)
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 <mreitz@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/nbd-client.c4
-rw-r--r--block/nbd-client.h2
-rw-r--r--block/nbd.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 6e1c97cad0..28bfb62bed 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -373,7 +373,7 @@ void nbd_client_session_close(NbdClientSession *client)
}
int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
- int sock, const char *export)
+ int sock, const char *export, Error **errp)
{
int ret;
@@ -382,7 +382,7 @@ int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
qemu_set_block(sock);
ret = nbd_receive_negotiate(sock, export,
&client->nbdflags, &client->size,
- &client->blocksize);
+ &client->blocksize, errp);
if (ret < 0) {
logout("Failed to negotiate with the NBD server\n");
closesocket(sock);
diff --git a/block/nbd-client.h b/block/nbd-client.h
index cd478f3a98..cfeecc2775 100644
--- a/block/nbd-client.h
+++ b/block/nbd-client.h
@@ -36,7 +36,7 @@ typedef struct NbdClientSession {
} NbdClientSession;
int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
- int sock, const char *export_name);
+ int sock, const char *export_name, Error **errp);
void nbd_client_session_close(NbdClientSession *client);
int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
diff --git a/block/nbd.c b/block/nbd.c
index 04cc845076..2e20831715 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -271,7 +271,7 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
}
/* NBD handshake */
- result = nbd_client_session_init(&s->client, bs, sock, export);
+ result = nbd_client_session_init(&s->client, bs, sock, export, errp);
g_free(export);
return result;
}