All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PCTCH v2 0/2] fix query-command-line-options
@ 2014-03-03 17:41 Amos Kong
  2014-03-03 17:41 ` [Qemu-devel] [PCTCH v2 1/2] qmp: rename query_option_descs() to get_param_infolist() Amos Kong
  2014-03-03 17:41 ` [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx Amos Kong
  0 siblings, 2 replies; 6+ messages in thread
From: Amos Kong @ 2014-03-03 17:41 UTC (permalink / raw
  To: qemu-devel; +Cc: libvir-list, armbru, lcapitulino, jyang, pbonzini

This patchset fixed some issues of query-command-line-options:
  * some new options haven't arguments can't be queried. (eg: -enable-fips)
  * some legcy options have arguments can't be queried. (eg: -vnc display)

More discussion:
 http://marc.info/?l=qemu-devel&m=139081830416684&w=2

V2: remove duplicate option tables, update schema

Amos Kong (2):
  qmp: rename query_option_descs() to get_param_infolist()
  query-command-line-options: query all the options in qemu-options.hx

 qapi-schema.json   |  8 ++++++--
 util/qemu-config.c | 58 +++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 55 insertions(+), 11 deletions(-)

-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PCTCH v2 1/2] qmp: rename query_option_descs() to get_param_infolist()
  2014-03-03 17:41 [Qemu-devel] [PCTCH v2 0/2] fix query-command-line-options Amos Kong
@ 2014-03-03 17:41 ` Amos Kong
  2014-03-04  0:27   ` Eric Blake
  2014-03-03 17:41 ` [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx Amos Kong
  1 sibling, 1 reply; 6+ messages in thread
From: Amos Kong @ 2014-03-03 17:41 UTC (permalink / raw
  To: qemu-devel; +Cc: libvir-list, armbru, lcapitulino, jyang, pbonzini

Signed-off-by: Amos Kong <akong@redhat.com>
---
 util/qemu-config.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/util/qemu-config.c b/util/qemu-config.c
index 9298f55..d624d92 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -39,7 +39,7 @@ QemuOptsList *qemu_find_opts(const char *group)
     return ret;
 }
 
-static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
+static CommandLineParameterInfoList *get_param_infolist(const QemuOptDesc *desc)
 {
     CommandLineParameterInfoList *param_list = NULL, *entry;
     CommandLineParameterInfo *info;
@@ -120,9 +120,9 @@ static CommandLineParameterInfoList *get_drive_infolist(void)
 
     for (i = 0; drive_config_groups[i] != NULL; i++) {
         if (!head) {
-            head = query_option_descs(drive_config_groups[i]->desc);
+            head = get_param_infolist(drive_config_groups[i]->desc);
         } else {
-            cur = query_option_descs(drive_config_groups[i]->desc);
+            cur = get_param_infolist(drive_config_groups[i]->desc);
             connect_infolist(head, cur);
         }
     }
@@ -147,7 +147,7 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
                 info->parameters = get_drive_infolist();
             } else {
                 info->parameters =
-                    query_option_descs(vm_config_groups[i]->desc);
+                    get_param_infolist(vm_config_groups[i]->desc);
             }
             entry = g_malloc0(sizeof(*entry));
             entry->value = info;
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx
  2014-03-03 17:41 [Qemu-devel] [PCTCH v2 0/2] fix query-command-line-options Amos Kong
  2014-03-03 17:41 ` [Qemu-devel] [PCTCH v2 1/2] qmp: rename query_option_descs() to get_param_infolist() Amos Kong
@ 2014-03-03 17:41 ` Amos Kong
  2014-03-04  0:37   ` Eric Blake
  1 sibling, 1 reply; 6+ messages in thread
From: Amos Kong @ 2014-03-03 17:41 UTC (permalink / raw
  To: qemu-devel; +Cc: libvir-list, armbru, lcapitulino, jyang, pbonzini

vm_config_groups[] only contains part of the options which have
argument, and all options which have no argument isn't added to
vm_config_groups[]. Current query-command-line-options only
checkes options from vm_config_groups[], so some options will
be lost.

We have some macros in qemu-options.hx to generate a table that
contains all the options. This patch tries to query options from
the table.

Then we won't lost the legacy options that weren't added to
vm_config_groups[]. The options have no argument will also be
returned (eg: -enable-fips)

Some options that have argument have a NULL desc list, some
options don't have argument, and "parameters" is mandatory
in the past. So we add a new field "arguments" to present
if the option takes unspecified arguments.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 qapi-schema.json   |  8 ++++++--
 util/qemu-config.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 05ced9d..0bd8e12 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3944,12 +3944,16 @@
 #
 # @option: option name
 #
-# @parameters: an array of @CommandLineParameterInfo
+# @parameters: array of @CommandLineParameterInfo, possibly empty
+# @argument: @optional present if the @parameters array is empty. If
+#            true, then the option takes unspecified arguments, if
+#            false, then the option is merely a boolean flag (since 2.0)
 #
 # Since 1.5
 ##
 { 'type': 'CommandLineOptionInfo',
-  'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'] } }
+  'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'],
+            '*argument': 'bool' } }
 
 ##
 # @query-command-line-options:
diff --git a/util/qemu-config.c b/util/qemu-config.c
index d624d92..c9c8732 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -6,6 +6,8 @@
 #include "hw/qdev.h"
 #include "qapi/error.h"
 #include "qmp-commands.h"
+#include "sysemu/arch_init.h"
+#include "qemu-options.h"
 
 static QemuOptsList *vm_config_groups[32];
 static QemuOptsList *drive_config_groups[4];
@@ -78,6 +80,17 @@ static CommandLineParameterInfoList *get_param_infolist(const QemuOptDesc *desc)
     return param_list;
 }
 
+static int get_group_index(const char *name)
+{
+    int i;
+
+    for (i = 0; vm_config_groups[i] != NULL; i++) {
+        if (!strcmp(vm_config_groups[i]->name, name)) {
+            return i;
+        }
+    }
+    return -1;
+}
 /* remove repeated entry from the info list */
 static void cleanup_infolist(CommandLineParameterInfoList *head)
 {
@@ -131,6 +144,15 @@ static CommandLineParameterInfoList *get_drive_infolist(void)
     return head;
 }
 
+#define HAS_ARG 0x0001
+
+typedef struct QEMUOption {
+    const char *name;
+    int flags;
+    int index;
+    uint32_t arch_mask;
+} QEMUOption;
+
 CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
                                                           const char *option,
                                                           Error **errp)
@@ -139,15 +161,33 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
     CommandLineOptionInfo *info;
     int i;
 
-    for (i = 0; vm_config_groups[i] != NULL; i++) {
-        if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
+    static const QEMUOption qemu_options[] = {
+        { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
+#define QEMU_OPTIONS_GENERATE_OPTIONS
+#include "qemu-options-wrapper.h"
+        { NULL },
+    };
+
+    for (i = 0; qemu_options[i].name; i++) {
+        if (!has_option || !strcmp(option, qemu_options[i].name)) {
             info = g_malloc0(sizeof(*info));
-            info->option = g_strdup(vm_config_groups[i]->name);
-            if (!strcmp("drive", vm_config_groups[i]->name)) {
+            info->option = g_strdup(qemu_options[i].name);
+
+            int idx = get_group_index(qemu_options[i].name);
+
+            if (qemu_options[i].flags) {
+                info->argument = true;
+            }
+
+            if (!strcmp("drive", qemu_options[i].name)) {
                 info->parameters = get_drive_infolist();
-            } else {
+            } else if (idx >= 0) {
                 info->parameters =
-                    get_param_infolist(vm_config_groups[i]->desc);
+                    get_param_infolist(vm_config_groups[idx]->desc);
+            }
+
+            if (!info->parameters) {
+                info->has_argument = true;
             }
             entry = g_malloc0(sizeof(*entry));
             entry->value = info;
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PCTCH v2 1/2] qmp: rename query_option_descs() to get_param_infolist()
  2014-03-03 17:41 ` [Qemu-devel] [PCTCH v2 1/2] qmp: rename query_option_descs() to get_param_infolist() Amos Kong
@ 2014-03-04  0:27   ` Eric Blake
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2014-03-04  0:27 UTC (permalink / raw
  To: Amos Kong, qemu-devel; +Cc: libvir-list, pbonzini, armbru, jyang, lcapitulino

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

On 03/03/2014 10:41 AM, Amos Kong wrote:
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  util/qemu-config.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Purely mechanical.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx
  2014-03-03 17:41 ` [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx Amos Kong
@ 2014-03-04  0:37   ` Eric Blake
  2014-03-04  5:51     ` Amos Kong
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Blake @ 2014-03-04  0:37 UTC (permalink / raw
  To: Amos Kong, qemu-devel; +Cc: libvir-list, pbonzini, armbru, jyang, lcapitulino

[-- Attachment #1: Type: text/plain, Size: 3098 bytes --]

On 03/03/2014 10:41 AM, Amos Kong wrote:

s/PCTCH/PATCH/ in the subject, although it doesn't affect patch application.

> vm_config_groups[] only contains part of the options which have
> argument, and all options which have no argument isn't added to

s/isn't/aren't/

> vm_config_groups[]. Current query-command-line-options only
> checkes options from vm_config_groups[], so some options will

s/checkes/checks/

> be lost.
> 
> We have some macros in qemu-options.hx to generate a table that
> contains all the options. This patch tries to query options from
> the table.
> 
> Then we won't lost the legacy options that weren't added to

s/lost/lose/

> vm_config_groups[]. The options have no argument will also be

s/have/that have/

> returned (eg: -enable-fips)
> 
> Some options that have argument have a NULL desc list, some
> options don't have argument, and "parameters" is mandatory
> in the past. So we add a new field "arguments" to present
> if the option takes unspecified arguments.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  qapi-schema.json   |  8 ++++++--
>  util/qemu-config.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
>  2 files changed, 52 insertions(+), 8 deletions(-)
> 
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 05ced9d..0bd8e12 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -3944,12 +3944,16 @@
>  #
>  # @option: option name
>  #
> -# @parameters: an array of @CommandLineParameterInfo
> +# @parameters: array of @CommandLineParameterInfo, possibly empty
> +# @argument: @optional present if the @parameters array is empty. If
> +#            true, then the option takes unspecified arguments, if
> +#            false, then the option is merely a boolean flag (since 2.0)

I like it.

>  
> +#define HAS_ARG 0x0001
> +
> +typedef struct QEMUOption {
> +    const char *name;
> +    int flags;
> +    int index;
> +    uint32_t arch_mask;

Where is arch_mask used by this patch?

> +} QEMUOption;
> +
>  CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
>                                                            const char *option,
>                                                            Error **errp)
> @@ -139,15 +161,33 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
>      CommandLineOptionInfo *info;
>      int i;
>  
> -    for (i = 0; vm_config_groups[i] != NULL; i++) {
> -        if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
> +    static const QEMUOption qemu_options[] = {
> +        { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
> +#define QEMU_OPTIONS_GENERATE_OPTIONS
> +#include "qemu-options-wrapper.h"
> +        { NULL },
> +    };

This looks identical to what is already in vl.c.  Why do we need two
static tables with identical contents?  Can't you just export the
existing table and have it just once?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx
  2014-03-04  0:37   ` Eric Blake
@ 2014-03-04  5:51     ` Amos Kong
  0 siblings, 0 replies; 6+ messages in thread
From: Amos Kong @ 2014-03-04  5:51 UTC (permalink / raw
  To: Eric Blake; +Cc: libvir-list, armbru, qemu-devel, lcapitulino, jyang, pbonzini

On Mon, Mar 03, 2014 at 05:37:57PM -0700, Eric Blake wrote:

> > ---
> >  qapi-schema.json   |  8 ++++++--
> >  util/qemu-config.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
> >  2 files changed, 52 insertions(+), 8 deletions(-)
> > 
> > diff --git a/qapi-schema.json b/qapi-schema.json
> > index 05ced9d..0bd8e12 100644
> > --- a/qapi-schema.json
> > +++ b/qapi-schema.json
> > @@ -3944,12 +3944,16 @@
> >  #
> >  # @option: option name
> >  #
> > -# @parameters: an array of @CommandLineParameterInfo
> > +# @parameters: array of @CommandLineParameterInfo, possibly empty
> > +# @argument: @optional present if the @parameters array is empty. If
> > +#            true, then the option takes unspecified arguments, if
> > +#            false, then the option is merely a boolean flag (since 2.0)
> 
> I like it.
> 
> >  
> > +#define HAS_ARG 0x0001
> > +
> > +typedef struct QEMUOption {
> > +    const char *name;
> > +    int flags;
> > +    int index;
> > +    uint32_t arch_mask;
> 
> Where is arch_mask used by this patch?

We want to re-use existed Macro QEMU_OPTIONS_GENERATE_OPTIONS.
 
> > +} QEMUOption;
> > +
> >  CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
> >                                                            const char *option,
> >                                                            Error **errp)
> > @@ -139,15 +161,33 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
> >      CommandLineOptionInfo *info;
> >      int i;
> >  
> > -    for (i = 0; vm_config_groups[i] != NULL; i++) {
> > -        if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
> > +    static const QEMUOption qemu_options[] = {
> > +        { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
> > +#define QEMU_OPTIONS_GENERATE_OPTIONS
> > +#include "qemu-options-wrapper.h"
> > +        { NULL },
> > +    };
> 
> This looks identical to what is already in vl.c.  Why do we need two
> static tables with identical contents?  Can't you just export the
> existing table and have it just once?

Ok. I will export the qemu_options table to qemu-options.h
 
> -- 
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
> 



-- 
			Amos.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-04  5:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-03 17:41 [Qemu-devel] [PCTCH v2 0/2] fix query-command-line-options Amos Kong
2014-03-03 17:41 ` [Qemu-devel] [PCTCH v2 1/2] qmp: rename query_option_descs() to get_param_infolist() Amos Kong
2014-03-04  0:27   ` Eric Blake
2014-03-03 17:41 ` [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx Amos Kong
2014-03-04  0:37   ` Eric Blake
2014-03-04  5:51     ` Amos Kong

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.