From 7e382003f1bd9d8a441ecc5ac8a74bad3564d943 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Wed, 6 Nov 2013 19:48:06 +0800 Subject: [PATCH] block: Round up total_sectors 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 0e96a223a6..6d5c80475c 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;