The size calculated from the CHS values is not the real image (disk) size, but usually a smaller value (this is caused by rounding effects).
Only older operating systems use CHS. Such guests won't be able to use the whole disk. This patch fixes https://bugs.launchpad.net/qemu/+bug/1105670/. Signed-off-by: Stefan Weil <s...@weilnetz.de> --- block/vpc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index fff103b..799b1c9 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -198,11 +198,10 @@ static int vpc_open(BlockDriverState *bs, int flags) /* Write 'checksum' back to footer, or else will leave it with zero. */ footer->checksum = be32_to_cpu(checksum); - // The visible size of a image in Virtual PC depends on the geometry - // rather than on the size stored in the footer (the size in the footer - // is too large usually) - bs->total_sectors = (int64_t) - be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl; + /* The visible size of an image in Virtual PC may depend on the geometry + * rather than on the size stored in the footer (the size in the footer + * is usually larger). Nevertheless we must use the real size here. */ + bs->total_sectors = be64_to_cpu(footer->size) / 512; /* Allow a maximum disk size of approximately 2 TB */ if (bs->total_sectors >= 65535LL * 255 * 255) { -- 1.7.10.4