mirror of
https://github.com/Motorhead1991/qemu.git
synced 2026-01-02 20:50:32 -07:00
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 <famz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
e78835b722
commit
7e382003f1
1 changed files with 1 additions and 1 deletions
2
block.c
2
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue