diff options
author | François Revol <revol@free.fr> | 2009-12-22 12:40:49 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-01-08 09:58:40 -0600 |
commit | 95a2f9bc588c3f83375d87b0a9394f89a1bcfada (patch) | |
tree | 8e885b344e8e959ba2afb7397601554b450974ed /block | |
parent | ceb696159d569db5b2a7659ce38752398c236742 (diff) | |
download | qemu-95a2f9bc588c3f83375d87b0a9394f89a1bcfada.tar.gz qemu-95a2f9bc588c3f83375d87b0a9394f89a1bcfada.tar.bz2 qemu-95a2f9bc588c3f83375d87b0a9394f89a1bcfada.zip |
block/vdi: allow disk sizes not multiple of block size
The disk image I created from my old laptop disk with VBoxManage
internalcommand converthd obviously was not a multiple of 1MB as when
created from scratch. This fixes QEMU refusing it. We still require the
size to be a multiple of sector size though.
It then boots correctly.
Allow opening VDI images with size not multiple of 1MB (as when converted from a raw disk).
Signed-off-by: François Revol <revol@free.fr>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/vdi.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/block/vdi.c b/block/vdi.c index 45aa81c700..c91961acb4 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -411,14 +411,17 @@ static int vdi_open(BlockDriverState *bs, const char *filename, int flags) /* We only support data blocks which start on a sector boundary. */ logout("unsupported data offset 0x%x B\n", header.offset_data); goto fail; + } else if (header.disk_size % SECTOR_SIZE != 0) { + logout("unsupported disk size %" PRIu64 " B\n", header.disk_size); + goto fail; } else if (header.sector_size != SECTOR_SIZE) { logout("unsupported sector size %u B\n", header.sector_size); goto fail; } else if (header.block_size != 1 * MiB) { logout("unsupported block size %u B\n", header.block_size); goto fail; - } else if (header.disk_size != - (uint64_t)header.blocks_in_image * header.block_size) { + } else if ((header.disk_size + header.block_size - 1) / header.block_size != + (uint64_t)header.blocks_in_image) { logout("unexpected block number %u B\n", header.blocks_in_image); goto fail; } else if (!uuid_is_null(header.uuid_link)) { |