From: "François Revol" <revol@free.fr>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] block/vdi: allow disk sizes not multiple of block size
Date: Tue, 08 Dec 2009 15:34:18 +0100 CET [thread overview]
Message-ID: <630568266-BeMail@laptop> (raw)
[-- Attachment #1: Type: text/plain, Size: 297 bytes --]
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.
Signed-off-by:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qemu-vdi-unrounded-disk-size-fix.diff --]
[-- Type: text/x-patch; name=qemu-vdi-unrounded-disk-size-fix.diff, Size: 1333 bytes --]
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>
diff --git a/block/vdi.c b/block/vdi.c
index 45aa81c..c91961a 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)) {
reply other threads:[~2009-12-08 14:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=630568266-BeMail@laptop \
--to=revol@free.fr \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.