diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-01-26 20:26:54 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-01-26 20:26:54 +0000 |
commit | 1fa792286c03bb5d966bf04a614e0302ae61bdf3 (patch) | |
tree | 51f8ce37bd9ea9358b52a39938889143ab91ce97 /block-vpc.c | |
parent | 2cfacb629365afba4ec8e2fd80a46f6d083c3a78 (diff) |
block-vpc: Fix disk size (Kevin Wolf)
VirtualPC bases the virtual disk size on the geometry rather than on
the size stored in the header.
Signed-off-by: Kevin Wolf <kwolf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6456 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block-vpc.c')
-rw-r--r-- | block-vpc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/block-vpc.c b/block-vpc.c index 3f257859a7..3c92bb39fb 100644 --- a/block-vpc.c +++ b/block-vpc.c @@ -150,6 +150,12 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) if (strncmp(footer->creator, "conectix", 8)) goto fail; + // 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; + lseek(s->fd, be64_to_cpu(footer->data_offset), SEEK_SET); if (read(fd, buf, HEADER_SIZE) != HEADER_SIZE) goto fail; @@ -160,9 +166,6 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) if (strncmp(dyndisk_header->magic, "cxsparse", 8)) goto fail; - bs->total_sectors = ((uint64_t)be32_to_cpu(dyndisk_header->max_table_entries) * - be32_to_cpu(dyndisk_header->block_size)) / 512; - lseek(s->fd, be64_to_cpu(dyndisk_header->table_offset), SEEK_SET); s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries); |