aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-03-05 08:56:10 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-04-19 16:36:43 +0200
commit185b43386ad999c80bdc58e41b87f05e5b3e8463 (patch)
tree326967bbfb0f72801848e9aebbad859f33873828 /block
parentfc19f8a02e45c4d8ad24dd7eb374330b03dfc28e (diff)
downloadqemu-185b43386ad999c80bdc58e41b87f05e5b3e8463.zip
qemu-185b43386ad999c80bdc58e41b87f05e5b3e8463.tar.gz
qemu-185b43386ad999c80bdc58e41b87f05e5b3e8463.tar.bz2
nbd: consistently return negative errno values
In the next patch we need to look at the return code of nbd_wr_sync. To avoid percolating the socket_error() ugliness all around, let's handle errors by returning negative errno values. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/nbd.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/block/nbd.c b/block/nbd.c
index 25e5268..1b0e384 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -200,8 +200,7 @@ static int nbd_co_send_request(BDRVNBDState *s, struct nbd_request *request,
if (rc >= 0 && iov) {
ret = qemu_co_sendv(s->sock, iov, request->len, offset);
if (ret != request->len) {
- errno = -EIO;
- rc = -1;
+ return -EIO;
}
}
qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, NULL,
@@ -271,7 +270,7 @@ static int nbd_establish_connection(BlockDriverState *bs)
if (ret < 0) {
logout("Failed to negotiate with the NBD server\n");
closesocket(sock);
- return -errno;
+ return ret;
}
/* Now that we're connected, set the socket to be non-blocking and
@@ -340,7 +339,7 @@ static int nbd_co_readv_1(BlockDriverState *bs, int64_t sector_num,
nbd_coroutine_start(s, &request);
ret = nbd_co_send_request(s, &request, NULL, 0);
if (ret < 0) {
- reply.error = errno;
+ reply.error = -ret;
} else {
nbd_co_receive_reply(s, &request, &reply, qiov->iov, offset);
}
@@ -369,7 +368,7 @@ static int nbd_co_writev_1(BlockDriverState *bs, int64_t sector_num,
nbd_coroutine_start(s, &request);
ret = nbd_co_send_request(s, &request, qiov->iov, offset);
if (ret < 0) {
- reply.error = errno;
+ reply.error = -ret;
} else {
nbd_co_receive_reply(s, &request, &reply, NULL, 0);
}
@@ -437,7 +436,7 @@ static int nbd_co_flush(BlockDriverState *bs)
nbd_coroutine_start(s, &request);
ret = nbd_co_send_request(s, &request, NULL, 0);
if (ret < 0) {
- reply.error = errno;
+ reply.error = -ret;
} else {
nbd_co_receive_reply(s, &request, &reply, NULL, 0);
}
@@ -463,7 +462,7 @@ static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num,
nbd_coroutine_start(s, &request);
ret = nbd_co_send_request(s, &request, NULL, 0);
if (ret < 0) {
- reply.error = errno;
+ reply.error = -ret;
} else {
nbd_co_receive_reply(s, &request, &reply, NULL, 0);
}