diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-10-16 15:54:42 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-10-16 15:54:42 +0100 |
commit | 79b2a13aa81724228166c794f48eb75bfb696b88 (patch) | |
tree | b32209496ef08bce1c696b179d93f9bf57c03cb5 /block | |
parent | 48ae1f60d8c9a770e6da64407984d84e25253c69 (diff) | |
parent | 92652b124336f5c08c7eb4616af202ea910dd3ea (diff) | |
download | qemu-79b2a13aa81724228166c794f48eb75bfb696b88.zip qemu-79b2a13aa81724228166c794f48eb75bfb696b88.tar.gz qemu-79b2a13aa81724228166c794f48eb75bfb696b88.tar.bz2 |
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2017-10-14' into staging
nbd patches for 2017-10-14
- Marc-André Lureau - NBD: use g_new() family of functions
- Vladimir Sementsov-Ogievskiy - first half of 00/13 nbd minimal structured read
# gpg: Signature made Sun 15 Oct 2017 01:38:47 BST
# gpg: using RSA key 0xA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>"
# gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>"
# gpg: aka "[jpeg image of size 6874]"
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A
* remotes/ericb/tags/pull-nbd-2017-10-14:
nbd: header constants indenting
nbd/server: simplify reply transmission
nbd/server: refactor nbd_co_send_simple_reply parameters
nbd/server: do not use NBDReply structure
nbd/server: structurize simple reply header sending
nbd: rename some simple-request related objects to be _simple_
block/nbd-client: refactor nbd_co_receive_reply
block/nbd-client: assert qiov len once in nbd_co_request
NBD: use g_new() family of functions
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block')
-rw-r--r-- | block/nbd-client.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c index 72651dc..c0683c3 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -156,7 +156,6 @@ 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) { - assert(request->len == iov_size(qiov->iov, qiov->niov)); if (qio_channel_writev_all(s->ioc, qiov->iov, qiov->niov, NULL) < 0) { rc = -EIO; @@ -181,11 +180,11 @@ err: } static int nbd_co_receive_reply(NBDClientSession *s, - NBDRequest *request, + uint64_t handle, QEMUIOVector *qiov) { int ret; - int i = HANDLE_TO_INDEX(s, request->handle); + int i = HANDLE_TO_INDEX(s, handle); /* Wait until we're woken up by nbd_read_reply_entry. */ s->requests[i].receiving = true; @@ -194,10 +193,9 @@ static int nbd_co_receive_reply(NBDClientSession *s, if (!s->ioc || s->quit) { ret = -EIO; } else { - assert(s->reply.handle == request->handle); + assert(s->reply.handle == handle); ret = -s->reply.error; if (qiov && s->reply.error == 0) { - assert(request->len == iov_size(qiov->iov, qiov->niov)); if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov, NULL) < 0) { ret = -EIO; @@ -231,15 +229,19 @@ static int nbd_co_request(BlockDriverState *bs, NBDClientSession *client = nbd_get_client_session(bs); int ret; - assert(!qiov || request->type == NBD_CMD_WRITE || - request->type == NBD_CMD_READ); + if (qiov) { + assert(request->type == NBD_CMD_WRITE || request->type == NBD_CMD_READ); + assert(request->len == iov_size(qiov->iov, qiov->niov)); + } else { + assert(request->type != NBD_CMD_WRITE && request->type != NBD_CMD_READ); + } ret = nbd_co_send_request(bs, request, request->type == NBD_CMD_WRITE ? qiov : NULL); if (ret < 0) { return ret; } - return nbd_co_receive_reply(client, request, + return nbd_co_receive_reply(client, request->handle, request->type == NBD_CMD_READ ? qiov : NULL); } |