From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WT4Fn-0007ST-3G for qemu-devel@nongnu.org; Thu, 27 Mar 2014 02:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WT4Fh-00038m-3A for qemu-devel@nongnu.org; Thu, 27 Mar 2014 02:57:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WT4Fg-00038i-R2 for qemu-devel@nongnu.org; Thu, 27 Mar 2014 02:57:25 -0400 From: Amos Kong Date: Thu, 27 Mar 2014 14:57:02 +0800 Message-Id: <1395903423-19975-3-git-send-email-akong@redhat.com> In-Reply-To: <1395903423-19975-1-git-send-email-akong@redhat.com> References: <1395903423-19975-1-git-send-email-akong@redhat.com> Subject: [Qemu-devel] [PATCH v6 2/3] query-command-line-options: expose implicit parameter name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: libvirt-list@redhat.com, armbru@redhat.com, anthony@codemonkey.ws, pbonzini@redhat.com, afaerber@suse.de This patch added a new field to expose implicit parameter name, we make it optional for compatibility. Suggested-by: Eric Blake Signed-off-by: Amos Kong --- qapi-schema.json | 6 +++++- util/qemu-config.c | 24 +++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 391356f..9341033 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4088,12 +4088,16 @@ # # @help: #optional human readable text string, not suitable for parsing. # +# @implied-name: #optional, if present and true, the parameter can be +# specified as '-option value' instead of the preferred +# spelling of '-option name=value' (since 2.1) +# # Since 1.5 ## { 'type': 'CommandLineParameterInfo', 'data': { 'name': 'str', 'type': 'CommandLineParameterType', - '*help': 'str' } } + '*help': 'str', '*implied-name': 'bool' } } ## # @CommandLineOptionInfo: diff --git a/util/qemu-config.c b/util/qemu-config.c index 508adbc..85bb0c8 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -39,17 +39,23 @@ QemuOptsList *qemu_find_opts(const char *group) return ret; } -static CommandLineParameterInfoList *get_param_info(const QemuOptDesc *desc) +static CommandLineParameterInfoList *get_param_info(const QemuOptsList *list) { CommandLineParameterInfoList *param_list = NULL, *entry; CommandLineParameterInfo *info; int i; - for (i = 0; desc[i].name != NULL; i++) { + for (i = 0; list->desc[i].name != NULL; i++) { info = g_malloc0(sizeof(*info)); - info->name = g_strdup(desc[i].name); + info->name = g_strdup(list->desc[i].name); - switch (desc[i].type) { + info->has_implied_name = true; + if (list->implied_opt_name && !strcmp(list->desc[i].name, + list->implied_opt_name)) { + info->implied_name = true; + } + + switch (list->desc[i].type) { case QEMU_OPT_STRING: info->type = COMMAND_LINE_PARAMETER_TYPE_STRING; break; @@ -64,9 +70,9 @@ static CommandLineParameterInfoList *get_param_info(const QemuOptDesc *desc) break; } - if (desc[i].help) { + if (list->desc[i].help) { info->has_help = true; - info->help = g_strdup(desc[i].help); + info->help = g_strdup(list->desc[i].help); } entry = g_malloc0(sizeof(*entry)); @@ -120,9 +126,9 @@ static CommandLineParameterInfoList *get_drive_infolist(void) for (i = 0; drive_config_groups[i] != NULL; i++) { if (!head) { - head = get_param_info(drive_config_groups[i]->desc); + head = get_param_info(drive_config_groups[i]); } else { - cur = get_param_info(drive_config_groups[i]->desc); + cur = get_param_info(drive_config_groups[i]); connect_infolist(head, cur); } } @@ -147,7 +153,7 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, info->parameters = get_drive_infolist(); } else { info->parameters = - get_param_info(vm_config_groups[i]->desc); + get_param_info(vm_config_groups[i]); } entry = g_malloc0(sizeof(*entry)); entry->value = info; -- 1.8.5.3