aboutsummaryrefslogtreecommitdiff
path: root/block/nbd-client.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2017-10-12 12:53:07 +0300
committerEric Blake <eblake@redhat.com>2017-10-12 16:19:35 -0500
commit4bfe4478d17679464a2aaa91ed703522ed9af8a0 (patch)
treea0e8b0eff0ed422ed66e999e850b643a34703187 /block/nbd-client.c
parente8d3eb74bf11dff6920b8d0884c28f93e0d0d732 (diff)
block/nbd-client: assert qiov len once in nbd_co_request
Also improve the assertion: check that qiov is NULL for other commands than CMD_READ and CMD_WRITE. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20171012095319.136610-2-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block/nbd-client.c')
-rw-r--r--block/nbd-client.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/block/nbd-client.c b/block/nbd-client.c
index 72651dcdb1..ddf273a6a4 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;
@@ -197,7 +196,6 @@ static int nbd_co_receive_reply(NBDClientSession *s,
assert(s->reply.handle == request->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,8 +229,12 @@ 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) {