From patchwork Tue Jan 19 21:15:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 43229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8CA59B7D86 for ; Wed, 20 Jan 2010 08:19:00 +1100 (EST) Received: from localhost ([127.0.0.1]:46545 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXLRd-0001nT-1l for incoming@patchwork.ozlabs.org; Tue, 19 Jan 2010 16:17:01 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXLQQ-0001n4-Gr for qemu-devel@nongnu.org; Tue, 19 Jan 2010 16:15:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXLQL-0001l4-V5 for qemu-devel@nongnu.org; Tue, 19 Jan 2010 16:15:46 -0500 Received: from [199.232.76.173] (port=42214 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXLQL-0001kz-OO for qemu-devel@nongnu.org; Tue, 19 Jan 2010 16:15:41 -0500 Received: from verein.lst.de ([213.95.11.210]:43615) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1NXLQL-00050v-5N for qemu-devel@nongnu.org; Tue, 19 Jan 2010 16:15:41 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o0JLFdWY004431 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 19 Jan 2010 22:15:39 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o0JLFdxb004430 for qemu-devel@nongnu.org; Tue, 19 Jan 2010 22:15:39 +0100 Date: Tue, 19 Jan 2010 22:15:39 +0100 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20100119211539.GA4383@lst.de> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Spam-Score: -0.001 () BAYES_44 X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH] block: prevent multiwrite_merge from creating too large iovecs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Index: qemu/block.c =================================================================== --- qemu.orig/block.c 2010-01-19 22:10:19.797003226 +0100 +++ qemu/block.c 2010-01-19 22:11:08.226005767 +0100 @@ -1711,6 +1711,10 @@ static int multiwrite_merge(BlockDriverS 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));