Commit 7e382003 authored by Fam Zheng's avatar Fam Zheng Committed by Stefan Hajnoczi
Browse files

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: default avatarFam Zheng <famz@redhat.com>
Reviewed-by: default avatarBenoit Canet <benoit@irqsave.net>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent e78835b7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;