All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: aliguori@us.ibm.com, lcapitulino@redhat.com,
	qemu-devel@nongnu.org, jyang@redhat.com,
	mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH] monitor: introduce query-config-schema
Date: Fri, 19 Apr 2013 17:21:37 +0200	[thread overview]
Message-ID: <51716101.8090705@redhat.com> (raw)
In-Reply-To: <1366365123-5412-1-git-send-email-akong@redhat.com>

Il 19/04/2013 11:52, Amos Kong ha scritto:
> Libvirt doesn't have a stable way to know option support
> detail. This patch introdued a new qmp command to query
> configuration schema information. hmp command isn't added.

Can you introspect QemuOpts instead?  All new options are added there.

Paolo

> Signed-off-by: Amos Kong <akong@redhat.com>
> CC: Osier Yang <jyang@redhat.com>
> CC: Anthony Liguori <aliguori@us.ibm.com>
> ---
> Reposted this patch: https://www.redhat.com/archives/libvir-list/2013-January/msg01656.html
> ---
>  qapi-schema.json       |   26 ++++++++++++++++++++++++++
>  qemu-options-wrapper.h |   16 ++++++++++++++++
>  qmp-commands.hx        |   32 ++++++++++++++++++++++++++++++++
>  qmp.c                  |   36 ++++++++++++++++++++++++++++++++++++
>  4 files changed, 110 insertions(+), 0 deletions(-)
> 
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 751d3c2..f781372 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -3505,3 +3505,29 @@
>      '*asl_compiler_rev':  'uint32',
>      '*file':              'str',
>      '*data':              'str' }}
> +
> +##
> +# @ConfigSchemaInfo:
> +#
> +# Configration schema information.
> +#
> +# @option: option name
> +#
> +# @config-schema: configuration schema string of one option
> +#
> +# Since 1.5
> +##
> +{ 'type': 'ConfigSchemaInfo', 'data': {'option': 'str', 'config-schema': 'str'} }
> +
> +##
> +# @query-config-schema
> +#
> +# Query configuration schema information of options
> +#
> +# @option: #optional option name
> +#
> +# Returns: @ConfigSchemaInfo list
> +#
> +# Since 1.5
> +##
> +{'command': 'query-config-schema', 'data': {'*option': 'str'}, 'returns': ['ConfigSchemaInfo']}
> diff --git a/qemu-options-wrapper.h b/qemu-options-wrapper.h
> index 13bfea0..6449268 100644
> --- a/qemu-options-wrapper.h
> +++ b/qemu-options-wrapper.h
> @@ -18,6 +18,22 @@
>  
>  #define DEFHEADING(text) ARCHHEADING(text, QEMU_ARCH_ALL)
>  
> +#elif defined(QEMU_OPTIONS_GENERATE_CONFIG)
> +
> +#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask)    \
> +    opt_help,
> +
> +#define DEFHEADING(text)
> +#define ARCHHEADING(text, arch_mask)
> +
> +#elif defined(QEMU_OPTIONS_GENERATE_NAME)
> +
> +#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask)    \
> +    option,
> +
> +#define DEFHEADING(text)
> +#define ARCHHEADING(text, arch_mask)
> +
>  #elif defined(QEMU_OPTIONS_GENERATE_OPTIONS)
>  
>  #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask)     \
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 4d65422..1bb691e 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -2414,7 +2414,39 @@ EQMP
>          .args_type  = "",
>          .mhandler.cmd_new = qmp_marshal_input_query_uuid,
>      },
> +SQMP
> +query-config-schema
> +------------
> +
> +Show configuration schema.
> +
> +Return configuration schema of one option, if no option is assigned,
> +will return configuration schema of all options.
> +
> +- "option": option name
> +- "config-schema": configuration schema string of one option
> +
> +Example:
> +-> {"execute": "query-config-schema", "arguments" : {"option": "boot"}}
> +<- {"return": [
> +     {"config-schema": "-boot [order=drives][,once=drives][,menu=on|off]\n
> +        [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n
> +	'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n
> +	'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n
> +	'sp_time': the period that splash picture last if menu=on, unit is ms\n
> +	'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
> +      "option": "boot"
> +     }
> +    ]
> +}
> +
> +EQMP
>  
> +    {
> +        .name       = "query-config-schema",
> +        .args_type  = "option:s?",
> +        .mhandler.cmd_new = qmp_marshal_input_query_config_schema,
> +    },
>  SQMP
>  query-migrate
>  -------------
> diff --git a/qmp.c b/qmp.c
> index ed6c7ef..a3f7cc9 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -24,6 +24,9 @@
>  #include "hw/qdev.h"
>  #include "sysemu/blockdev.h"
>  #include "qom/qom-qobject.h"
> +#include "qemu-options.h"
> +#include "net/net.h"
> +#include "exec/gdbstub.h"
>  
>  NameInfo *qmp_query_name(Error **errp)
>  {
> @@ -78,6 +81,39 @@ UuidInfo *qmp_query_uuid(Error **errp)
>      return info;
>  }
>  
> +ConfigSchemaInfoList *qmp_query_config_schema(bool has_option,
> +                              const char *option, Error **errp)
> +{
> +    ConfigSchemaInfoList *conf_list = NULL, *entry;
> +    ConfigSchemaInfo *info;
> +
> +    char const *optionstr[] = {
> +#define QEMU_OPTIONS_GENERATE_NAME
> +#include "qemu-options-wrapper.h"
> +    };
> +
> +    char const *configstr[] = {
> +#define QEMU_OPTIONS_GENERATE_CONFIG
> +#include "qemu-options-wrapper.h"
> +    };
> +
> +    int i;
> +    for (i = 0; i < sizeof(optionstr) / sizeof(char *); i++) {
> +        if (!has_option || !strcmp(option, optionstr[i])) {
> +            info = g_malloc0(sizeof(*info));
> +            info->option = g_strdup(option);
> +            info->config_schema = g_strdup(configstr[i]);
> +
> +            entry = g_malloc0(sizeof(*entry));
> +            entry->value = info;
> +            entry->next = conf_list;
> +            conf_list = entry;
> +        }
> +    }
> +
> +    return conf_list;
> +}
> +
>  void qmp_quit(Error **err)
>  {
>      no_shutdown = 0;
> 

  parent reply	other threads:[~2013-04-19 15:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-19  9:52 [Qemu-devel] [PATCH] monitor: introduce query-config-schema Amos Kong
2013-04-19 12:02 ` Osier Yang
2013-04-19 12:22   ` Eric Blake
2013-04-19 13:44   ` Osier Yang
2013-04-19 12:39 ` Eric Blake
2013-04-19 13:50   ` Osier Yang
2013-04-19 15:21 ` Paolo Bonzini [this message]
2013-04-22 11:48   ` Amos Kong
2013-04-22 12:07     ` Paolo Bonzini
2013-04-22 15:00       ` Eric Blake
2013-04-22 15:16         ` Paolo Bonzini
2013-04-23  2:40           ` Amos Kong
2013-04-23 13:20         ` Luiz Capitulino
2013-04-23 15:32           ` Eric Blake
2013-04-23 16:55             ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51716101.8090705@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=akong@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=jyang@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.