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) {