Received: from eggs.gnu.org ([2001:4830:134:3::10]:38389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vej4o-0005Qr-Fw for qemu-devel@nongnu.org; Fri, 08 Nov 2013 05:14:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vej4j-0005tf-H5 for qemu-devel@nongnu.org; Fri, 08 Nov 2013 05:14:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27691) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vej4j-0005tX-9g for qemu-devel@nongnu.org; Fri, 08 Nov 2013 05:14:01 -0500 From: Stefan Hajnoczi Date: Fri, 8 Nov 2013 11:12:31 +0100 Message-Id: <1383905551-16411-38-git-send-email-stefanha@redhat.com> In-Reply-To: <1383905551-16411-1-git-send-email-stefanha@redhat.com> References: <1383905551-16411-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL v2 37/37] block: Round up total_sectors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Fam Zheng , Stefan Hajnoczi , Anthony Liguori From: Fam Zheng Since b94a2610, bdrv_getlength() is omitted when probing image. VMDK monolithicFlat is broken by that because a file < 512 bytes can't be read with its total_sectors truncated to 0. This patch round up the size to BDRV_SECTOR_SIZE, when a image size is not sector aligned. Signed-off-by: Fam Zheng Reviewed-by: Benoit Canet Signed-off-by: Stefan Hajnoczi --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index 0e96a22..6d5c804 100644 --- a/block.c +++ b/block.c @@ -640,7 +640,7 @@ static int refresh_total_sectors(BlockDriverState *bs, int64_t hint) if (length < 0) { return length; } - hint = length >> BDRV_SECTOR_BITS; + hint = DIV_ROUND_UP(length, BDRV_SECTOR_SIZE); } bs->total_sectors = hint; -- 1.8.3.1