From patchwork Mon Mar 19 15:09:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 147555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 276B2B6FBE for ; Tue, 20 Mar 2012 02:36:07 +1100 (EST) Received: from localhost ([::1]:46561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9eE2-0004dP-PU for incoming@patchwork.ozlabs.org; Mon, 19 Mar 2012 11:10:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9eDd-0003nU-Oj for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:10:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9eDF-0000K4-Oh for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:09:57 -0400 Received: from cpe-70-123-132-139.austin.res.rr.com ([70.123.132.139]:47545 helo=localhost6.localdomain6) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9eDF-0000Ju-H1 for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:09:33 -0400 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu2) with ESMTP id q2JF9WCY030950; Mon, 19 Mar 2012 10:09:32 -0500 Received: (from anthony@localhost) by localhost6.localdomain6 (8.14.4/8.14.4/Submit) id q2JF9VrW030949; Mon, 19 Mar 2012 10:09:31 -0500 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 19 Mar 2012 10:09:21 -0500 Message-Id: <1332169763-30665-8-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1332169763-30665-1-git-send-email-aliguori@us.ibm.com> References: <1332169763-30665-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 70.123.132.139 Cc: Anthony Liguori , Eric Blake , Eduardo Habkost , Gerd Hoffman Subject: [Qemu-devel] [PATCH 7/9] qmp: expose a command to query capabilities of config parser X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Anthony Liguori --- qapi-schema.json | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-config.c | 51 +++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 5 ++++ 3 files changed, 122 insertions(+), 0 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 04fa84f..2a80ef6 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1663,3 +1663,69 @@ { 'command': 'qom-list-types', 'data': { '*implements': 'str', '*abstract': 'bool' }, 'returns': [ 'ObjectTypeInfo' ] } + +## +# @ConfigOptionType +# +# An enumeration describing the type of a configuration file entry. +# +# @string: a UTF-8 string +# +# @bool: either 'on' or 'off' +# +# @number: an integer +# +# @size: an integer followed by either 'K', 'M', 'G', or 'T'. +# +# Since: 1.1 +## +{ 'enum': 'ConfigOptionType' + 'data': [ 'string', 'bool', 'number', 'size' ] } + +## +# @ConfigOption +# +# An option within a configuration section. +# +# @name: the name of the configuration option +# +# @type: the type of the configuration option +# +# @help: an optional help description. This should not be parsed or relied upon +# in any way. Its content's may change in future versions of QEMU. +# +# Since: 1.1 +## +{ 'type': 'ConfigOption', + 'data': { 'name': 'str', + 'type': 'ConfigOptionType', + '*help': 'str' } } + +## +# @ConfigSection +# +# A section within a configuration file. +# +# @name: the section name +# +# @parameters: a list of supported parameters +# +# Since: 1.1 +## +{ 'type': 'ConfigSection', + 'data': { 'name': 'str', + 'parameters': [ 'ConfigOption' ] } } + +## +# @query-config-capabilities +# +# Returns the current set of capabilities supported by the various QEMU commands +# that work with configuration files. +# +# Returns: a list of @ConfigSections describe the currently supported +# configuration sections. +# +# Since: 1.1 +## +{ 'command': 'query-config-capabilities', + 'returns': [ 'ConfigSection' ] } diff --git a/qemu-config.c b/qemu-config.c index 5856e5a..447aad6 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -2,6 +2,7 @@ #include "qemu-error.h" #include "qemu-option.h" #include "qemu-config.h" +#include "qmp-commands.h" #include "hw/qdev.h" #include "gdbstub.h" #include "net.h" @@ -866,3 +867,53 @@ int qemu_read_config_file(const char *filename) { return qemu_config_parse(vm_config_groups, filename); } + +ConfigSectionList *qmp_query_config_capabilities(Error **errp) +{ + ConfigSectionList *lst = NULL; + int i; + + for (i = 0; vm_config_groups[i]; i++) { + QemuOptsList *olist = vm_config_groups[i]; + ConfigSection *s = g_malloc0(sizeof(*s)); + ConfigSectionList *e = g_malloc0(sizeof(*e)); + QemuOptDesc *desc; + + s->name = g_strdup(olist->name); + for (desc = olist->desc; desc->name; desc++) { + ConfigOption *o = g_malloc0(sizeof(*o)); + ConfigOptionList *oe = g_malloc0(sizeof(*oe)); + + o->name = g_strdup(desc->name); + switch (desc->type) { + case QEMU_OPT_STRING: + o->type = CONFIG_OPTION_TYPE_STRING; + break; + case QEMU_OPT_BOOL: + o->type = CONFIG_OPTION_TYPE_BOOL; + break; + case QEMU_OPT_NUMBER: + o->type = CONFIG_OPTION_TYPE_NUMBER; + break; + case QEMU_OPT_SIZE: + o->type = CONFIG_OPTION_TYPE_SIZE; + break; + } + + if (desc->help) { + o->has_help = true; + o->help = g_strdup(desc->help); + } + + oe->value = o; + oe->next = s->parameters; + s->parameters = oe; + } + + e->value = s; + e->next = lst; + lst = e; + } + + return lst; +} diff --git a/qmp-commands.hx b/qmp-commands.hx index dfe8a5b..8024995 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2125,3 +2125,8 @@ EQMP .args_type = "implements:s?,abstract:b?", .mhandler.cmd_new = qmp_marshal_input_qom_list_types, }, + { + .name = "query-config-capabilities", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_config_capabilities, + },