Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M3XVc-0003tD-3c for qemu-devel@nongnu.org; Mon, 11 May 2009 11:33:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M3XVX-0003rF-L4 for qemu-devel@nongnu.org; Mon, 11 May 2009 11:33:39 -0400 Received: from [199.232.76.173] (port=52601 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3XVX-0003rA-Cg for qemu-devel@nongnu.org; Mon, 11 May 2009 11:33:35 -0400 Received: from kassel160.server4you.de ([62.75.246.160]:43922 helo=csgraf.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M3XVW-00070Y-Vp for qemu-devel@nongnu.org; Mon, 11 May 2009 11:33:35 -0400 From: alex@csgraf.de Date: Mon, 11 May 2009 17:33:32 +0200 Message-Id: <1242056012-20382-1-git-send-email-alex@csgraf.de> Subject: [Qemu-devel] [PATCH] Allow custom file sizes for backed files List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexander Graf From: Alexander Graf Currently when creating an image with a backing file enabled, the size of the file is the same as the size of the backing file. I don't see any reason why it has to be that way. Qcow2 even contains code to handle the case where the backing file doesn't contain the data we want to read from it, so we're fine here. This patch allows to specify a size option even when using a backing file. I tested that it works with a raw backed qcow2 file. Signed-off-by: Alexander Graf --- qemu-img.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 29149a2..01fa059 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -271,9 +271,10 @@ static int img_create(int argc, char **argv) bdrv_get_geometry(bs, &size); size *= 512; bdrv_delete(bs); - } else { - if (optind >= argc) - help(); + } else if (optind >= argc) { + help(); + } + if (optind < argc) { p = argv[optind]; sizef = strtod(p, (char **)&p); if (*p == 'M') { -- 1.6.0.2