aboutsummaryrefslogtreecommitdiff
path: root/block/nbd-client.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2017-09-05 14:11:14 -0500
committerEric Blake <eblake@redhat.com>2017-09-06 10:11:54 -0500
commit030fa7f6f950f5c8963f1dee8e6bb7387ed86a99 (patch)
treec604ccc0c3afbfa97fa60839fce99619bf20e457 /block/nbd-client.c
parente8ffaa311080a570a7c86d03c139c160cd11a831 (diff)
nbd: Use new qio_channel_*_all() functions
Rather than open-coding our own read/write-all functions, we can make use of the recently-added qio code. It slightly changes the error message in one of the iotests. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <20170905191114.5959-4-eblake@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'block/nbd-client.c')
-rw-r--r--block/nbd-client.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c
index f0dbea24d3..ee7f758e68 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -121,7 +121,7 @@ static int nbd_co_send_request(BlockDriverState *bs,
QEMUIOVector *qiov)
{
NBDClientSession *s = nbd_get_client_session(bs);
- int rc, ret, i;
+ int rc, i;
qemu_co_mutex_lock(&s->send_mutex);
while (s->in_flight == MAX_NBD_REQUESTS) {
@@ -156,9 +156,9 @@ static int nbd_co_send_request(BlockDriverState *bs,
qio_channel_set_cork(s->ioc, true);
rc = nbd_send_request(s->ioc, request);
if (rc >= 0 && !s->quit) {
- ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, false,
- NULL);
- if (ret != request->len) {
+ assert(request->len == iov_size(qiov->iov, qiov->niov));
+ if (qio_channel_writev_all(s->ioc, qiov->iov, qiov->niov,
+ NULL) < 0) {
rc = -EIO;
}
}
@@ -184,7 +184,6 @@ static void nbd_co_receive_reply(NBDClientSession *s,
QEMUIOVector *qiov)
{
int i = HANDLE_TO_INDEX(s, request->handle);
- int ret;
/* Wait until we're woken up by nbd_read_reply_entry. */
s->requests[i].receiving = true;
@@ -195,9 +194,9 @@ static void nbd_co_receive_reply(NBDClientSession *s,
reply->error = EIO;
} else {
if (qiov && reply->error == 0) {
- ret = nbd_rwv(s->ioc, qiov->iov, qiov->niov, request->len, true,
- NULL);
- if (ret != request->len) {
+ assert(request->len == iov_size(qiov->iov, qiov->niov));
+ if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov,
+ NULL) < 0) {
reply->error = EIO;
s->quit = true;
}