From patchwork Tue Dec 22 11:40:49 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Revol?= X-Patchwork-Id: 41606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 65B96B7BC9 for ; Tue, 22 Dec 2009 22:43:35 +1100 (EST) Received: from localhost ([127.0.0.1]:38973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NN39I-0007Fi-Ce for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2009 06:43:32 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NN38j-0007Cw-3N for qemu-devel@nongnu.org; Tue, 22 Dec 2009 06:42:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NN38f-00079d-Dj for qemu-devel@nongnu.org; Tue, 22 Dec 2009 06:42:56 -0500 Received: from [199.232.76.173] (port=41816 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NN38e-00079X-Pe for qemu-devel@nongnu.org; Tue, 22 Dec 2009 06:42:52 -0500 Received: from smtp2-g21.free.fr ([212.27.42.2]:35009) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NN38d-0004bK-Ld for qemu-devel@nongnu.org; Tue, 22 Dec 2009 06:42:52 -0500 Received: from smtp2-g21.free.fr (localhost [127.0.0.1]) by smtp2-g21.free.fr (Postfix) with ESMTP id 0CA6C4B01A4 for ; Tue, 22 Dec 2009 12:42:44 +0100 (CET) Received: from laptop (vaf26-2-82-244-111-82.fbx.proxad.net [82.244.111.82]) by smtp2-g21.free.fr (Postfix) with ESMTP id 0EBBC4B0165 for ; Tue, 22 Dec 2009 12:42:42 +0100 (CET) To: qemu-devel@nongnu.org X-Mailer: BeMail - Mail Daemon Replacement 3.0.0 Final From: "=?utf-8?q?Fran=C3=A7ois?= Revol" Date: Tue, 22 Dec 2009 12:40:49 +0100 CET Message-Id: <7380337160-BeMail@laptop> Mime-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH][RESEND] block/vdi: allow disk sizes not multiple of block size (fwd) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Anyone just tried it yet ? François. ------ Forwarded Message: ------ To: qemu-devel@nongnu.org From: "François Revol" Subject: [PATCH] block/vdi: allow disk sizes not multiple of block size Date: Tue, 08 Dec 2009 15:34:18 +0100 CET 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 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)) {