[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/7] block/vpc: Fix size calculation
From: |
Stefan Weil |
Subject: |
[Qemu-devel] [PATCH 5/7] block/vpc: Fix size calculation |
Date: |
Fri, 1 Feb 2013 22:51:32 +0100 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH 4/7] block/vpc: Improve vpc_open (optimisation and error handling), (continued)
[Qemu-devel] [PATCH 3/7] block/vpc: Replace HEADER_SIZE by FOOTER_SIZE, Stefan Weil, 2013/02/01
[Qemu-devel] [PATCH 6/7] block/vpc: Remove workaround for geometry calculation, Stefan Weil, 2013/02/01