summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-01-19 22:15:39 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-20 08:51:40 -0600
commit0076bc0c1d93adcbc7f1af184e04902cf37e9ab8 (patch)
tree7c0bc0f4f0ab2d7424d3d162e56f394ef11c5584
parent1d44952fc7f4de113eae892401e4d50ee476e82e (diff)
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 <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--block.c4
1 files changed, 4 insertions, 0 deletions
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));