Commit 1fa792286c03bb5d966bf04a614e0302ae61bdf3
1 parent
2cfacb62
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
Showing
1 changed file
with
6 additions
and
3 deletions
block-vpc.c
@@ -150,6 +150,12 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) | @@ -150,6 +150,12 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) | ||
150 | if (strncmp(footer->creator, "conectix", 8)) | 150 | if (strncmp(footer->creator, "conectix", 8)) |
151 | goto fail; | 151 | goto fail; |
152 | 152 | ||
153 | + // The visible size of a image in Virtual PC depends on the geometry | ||
154 | + // rather than on the size stored in the footer (the size in the footer | ||
155 | + // is too large usually) | ||
156 | + bs->total_sectors = (int64_t) | ||
157 | + be16_to_cpu(footer->cyls) * footer->heads * footer->secs_per_cyl; | ||
158 | + | ||
153 | lseek(s->fd, be64_to_cpu(footer->data_offset), SEEK_SET); | 159 | lseek(s->fd, be64_to_cpu(footer->data_offset), SEEK_SET); |
154 | if (read(fd, buf, HEADER_SIZE) != HEADER_SIZE) | 160 | if (read(fd, buf, HEADER_SIZE) != HEADER_SIZE) |
155 | goto fail; | 161 | goto fail; |
@@ -160,9 +166,6 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) | @@ -160,9 +166,6 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) | ||
160 | if (strncmp(dyndisk_header->magic, "cxsparse", 8)) | 166 | if (strncmp(dyndisk_header->magic, "cxsparse", 8)) |
161 | goto fail; | 167 | goto fail; |
162 | 168 | ||
163 | - bs->total_sectors = ((uint64_t)be32_to_cpu(dyndisk_header->max_table_entries) * | ||
164 | - be32_to_cpu(dyndisk_header->block_size)) / 512; | ||
165 | - | ||
166 | lseek(s->fd, be64_to_cpu(dyndisk_header->table_offset), SEEK_SET); | 169 | lseek(s->fd, be64_to_cpu(dyndisk_header->table_offset), SEEK_SET); |
167 | 170 | ||
168 | s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries); | 171 | s->max_table_entries = be32_to_cpu(dyndisk_header->max_table_entries); |