From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGrxs-0006PV-3N for qemu-devel@nongnu.org; Fri, 21 Feb 2014 10:24:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGrxm-0001TU-5n for qemu-devel@nongnu.org; Fri, 21 Feb 2014 10:24:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGrxl-0001TI-Sr for qemu-devel@nongnu.org; Fri, 21 Feb 2014 10:24:30 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1LFOTE5003832 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Feb 2014 10:24:29 -0500 From: Kevin Wolf Date: Fri, 21 Feb 2014 16:24:06 +0100 Message-Id: <1392996248-26781-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1392996248-26781-1-git-send-email-kwolf@redhat.com> References: <1392996248-26781-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v3 4/6] qemu-img amend: Support multiple -o options List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, stefanha@redhat.com Instead of ignoring all option values but the last one, multiple -o options now have the same meaning as having a single option with all settings in the order of their respective -o options. Signed-off-by: Kevin Wolf --- qemu-img.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 3fd2168..6ceaeb2 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2667,7 +2667,18 @@ static int img_amend(int argc, char **argv) help(); break; case 'o': - options = optarg; + if (!is_valid_option_list(optarg)) { + error_report("Invalid option list: %s", optarg); + ret = -1; + goto out; + } + if (!options) { + options = g_strdup(optarg); + } else { + char *old_options = options; + options = g_strdup_printf("%s,%s", options, optarg); + g_free(old_options); + } break; case 'f': fmt = optarg; @@ -2697,7 +2708,7 @@ static int img_amend(int argc, char **argv) fmt = bs->drv->format_name; - if (is_help_option(options)) { + if (has_help_option(options)) { ret = print_block_option_help(filename, fmt); goto out; } @@ -2724,6 +2735,8 @@ out: } free_option_parameters(create_options); free_option_parameters(options_param); + g_free(options); + if (ret) { return 1; } -- 1.8.1.4