From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N35u5-0001x0-Jt for qemu-devel@nongnu.org; Wed, 28 Oct 2009 06:37:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N35u0-0001w8-PK for qemu-devel@nongnu.org; Wed, 28 Oct 2009 06:37:20 -0400 Received: from [199.232.76.173] (port=47516 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N35u0-0001w4-IE for qemu-devel@nongnu.org; Wed, 28 Oct 2009 06:37:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8612) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N35u0-0002Jg-3T for qemu-devel@nongnu.org; Wed, 28 Oct 2009 06:37:16 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9SAbEkF018245 for ; Wed, 28 Oct 2009 06:37:14 -0400 From: Kevin Wolf Date: Wed, 28 Oct 2009 11:36:07 +0100 Message-Id: <1256726167-11134-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] qemu-img: Allow creating zero sized images List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf A size of 0 should be valid and cannot be treated as "missing value". Use -1 for this purpose instead. Signed-off-by: Kevin Wolf --- qemu-img.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 204f618..00fcade 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -297,13 +297,16 @@ static int img_create(int argc, char **argv) return 0; } + /* Create parameter list with default values */ + param = parse_option_parameters("", drv->create_options, param); + set_option_parameter_int(param, BLOCK_OPT_SIZE, -1); + + /* Parse -o options */ if (options) { param = parse_option_parameters(options, drv->create_options, param); if (param == NULL) { error("Invalid options for file format '%s'.", fmt); } - } else { - param = parse_option_parameters("", drv->create_options, param); } /* Get the filename */ @@ -321,7 +324,7 @@ static int img_create(int argc, char **argv) // The size for the image must always be specified, with one exception: // If we are using a backing file, we can obtain the size from there - if (get_option_parameter(param, BLOCK_OPT_SIZE)->value.n == 0) { + if (get_option_parameter(param, BLOCK_OPT_SIZE)->value.n == -1) { QEMUOptionParameter *backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE); -- 1.6.2.5