From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LiTTN-0004tw-4h for qemu-devel@nongnu.org; Sat, 14 Mar 2009 09:00:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LiTTI-0004qO-GS for qemu-devel@nongnu.org; Sat, 14 Mar 2009 09:00:16 -0400 Received: from [199.232.76.173] (port=54679 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LiTTI-0004qL-92 for qemu-devel@nongnu.org; Sat, 14 Mar 2009 09:00:12 -0400 Received: from verein.lst.de ([213.95.11.210]:54975) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1LiTTH-0007e3-Ks for qemu-devel@nongnu.org; Sat, 14 Mar 2009 09:00:11 -0400 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 n2ED04IF024421 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Sat, 14 Mar 2009 14:00:04 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id n2ED03oI024419 for qemu-devel@nongnu.org; Sat, 14 Mar 2009 14:00:03 +0100 Date: Sat, 14 Mar 2009 14:00:03 +0100 From: Christoph Hellwig Message-ID: <20090314130003.GA24344@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] fix bdrv_check_request for byte-granularity requests Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org We never allow the offset to be byte-granularity for the sector-based interface, instead the negative value for byte values applied to the request length. Signed-off-by: Christoph Hellwig Index: qemu/block.c =================================================================== --- qemu.orig/block.c 2009-03-11 11:50:27.000000000 +0100 +++ qemu/block.c 2009-03-11 11:51:42.000000000 +0100 @@ -542,15 +542,15 @@ static int bdrv_check_byte_request(Block static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { - int64_t offset; + size_t len; /* Deal with byte accesses */ - if (sector_num < 0) - offset = -sector_num; + if (nb_sectors < 0) + len = -nb_sectors; else - offset = sector_num * 512; + len = nb_sectors * 512; - return bdrv_check_byte_request(bs, offset, nb_sectors * 512); + return bdrv_check_byte_request(bs, sector_num * 512, len); } /* return < 0 if error. See bdrv_write() for the return codes */