Request merging must not result in a huge request that exceeds the maximum number of iovec elements. Use BlockLimits.max_iov instead of hardcoding IOV_MAX.
Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> --- block/io.c | 3 ++- hw/block/virtio-blk.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 37bc0dc..66ae770 100644 --- a/block/io.c +++ b/block/io.c @@ -1854,7 +1854,8 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs, merge = 1; } - if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) { + if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > + bs->bl.max_iov) { merge = 0; } diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 6aefda4..a186956 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -407,7 +407,7 @@ void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb) bool merge = true; /* merge would exceed maximum number of IOVs */ - if (niov + req->qiov.niov > IOV_MAX) { + if (niov + req->qiov.niov > blk_get_max_iov(blk)) { merge = false; } -- 2.4.3