From 0076bc0c1d93adcbc7f1af184e04902cf37e9ab8 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 19 Jan 2010 22:15:39 +0100 Subject: [PATCH] block: prevent multiwrite_merge from creating too large iovecs If we go over the maximum number of iovecs support by syscall we get back EINVAL from the kernel which translate to I/O errors for the guest. Signed-off-by: Christoph Hellwig Signed-off-by: Anthony Liguori --- block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block.c b/block.c index 73c26ec410..cde41295bd 100644 --- a/block.c +++ b/block.c @@ -1689,6 +1689,10 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs, merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]); } + if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) { + merge = 0; + } + if (merge) { size_t size; QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov)); -- GitLab