OSDN Git Service

block: prevent multiwrite_merge from creating too large iovecs
authorChristoph Hellwig <hch@lst.de>
Tue, 19 Jan 2010 21:15:39 +0000 (22:15 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 20 Jan 2010 14:51:40 +0000 (08:51 -0600)
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>
block.c

diff --git a/block.c b/block.c
index 73c26ec..cde4129 100644 (file)
--- 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));