]> git.proxmox.com Git - qemu.git/commitdiff
block: Round up total_sectors
authorFam Zheng <famz@redhat.com>
Wed, 6 Nov 2013 11:48:06 +0000 (19:48 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 8 Nov 2013 09:44:24 +0000 (10:44 +0100)
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 <famz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block.c

diff --git a/block.c b/block.c
index 0e96a223a6e4e55dced699713c36fd82598500a1..6d5c80475c2b3d80f1e4641c802d2a820c06724b 100644 (file)
--- 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;