From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve1ar-0001Ty-Nd for qemu-devel@nongnu.org; Wed, 06 Nov 2013 06:48:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve1al-0004oD-Ld for qemu-devel@nongnu.org; Wed, 06 Nov 2013 06:48:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve1al-0004o8-Dz for qemu-devel@nongnu.org; Wed, 06 Nov 2013 06:48:11 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA6Bm9NR032648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Nov 2013 06:48:09 -0500 From: Fam Zheng Date: Wed, 6 Nov 2013 19:48:06 +0800 Message-Id: <1383738486-21045-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH] block: Round up total_sectors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com 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 --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index 58efb5b..f706634 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