Skip to contentSkip to conversation

fix query-command-line-options

PATCH Superseded Amos Kong 2 participants 6 messages Mar 3, 2014 – Mar 4, 2014

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Amos Kong

author
#0 lore raw

v2 cover fix query-command-line-options

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(-)
Signature · 1 line
1.8.5.3
author
#1 lore raw

PATCH v2 1/2 qmp: rename query_option_descs() to get_param_infolist()

---
 util/qemu-config.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
util/qemu-config.c +4 -4
index 9298f55..d624d92 100644
@@ -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;
Signature · 1 line
1.8.5.3
author
#3 lore raw

PATCH v2 2/2 query-command-line-options: query all the options in qemu-options.hx

In reply to Amos Kong

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.

---
 qapi-schema.json   |  8 ++++++--
 util/qemu-config.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 52 insertions(+), 8 deletions(-)
qapi-schema.json +6 -2
index 05ced9d..0bd8e12 100644
@@ -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:
util/qemu-config.c +46 -6

79 lines not on this page · raw message

Signature · 1 line
1.8.5.3
Reviewed-by on v2 1/2
#2 lore raw

Re: [Qemu-devel] [PCTCH v2 1/2] qmp: rename query_option_descs() to get_param_infolist()

In reply to Amos Kong
Quoted 4 lines · Amos Kong
---
 util/qemu-config.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Purely mechanical.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#4 lore raw

Re: [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx

In reply to Amos Kong

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

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

Quoted 2 lines

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/

Quoted 2 lines

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

s/checkes/checks/

Quoted 7 lines

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/

Quoted 1 line

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

s/have/that have/

Quoted 18 lines

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.

---
 qapi-schema.json   |  8 ++++++--
 util/qemu-config.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 52 insertions(+), 8 deletions(-)
qapi-schema.json +0 -0
index 05ced9d..0bd8e12 100644

qapi-schema.json line 3950

Quoted 8 lines
qapi-schema.json +4 -1
@@ -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.

qapi-schema.json line 3957

Quoted 8 lines
qapi-schema.json +7 -0
+#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?

Quoted 7 lines
qapi-schema.json +2 -0
+} 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;

qapi-schema.json CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, · line 169

Quoted 10 lines
qapi-schema.json +6 -2
     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?

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#5 lore raw

Re: [Qemu-devel] [PCTCH v2 2/2] query-command-line-options: query all the options in qemu-options.hx

Quoted 22 lines · Eric Blake
Quoted 10 lines
---
 qapi-schema.json   |  8 ++++++--
 util/qemu-config.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 52 insertions(+), 8 deletions(-)
qapi-schema.json +0 -0
index 05ced9d..0bd8e12 100644

qapi-schema.json line 3950

Quoted 8 lines
qapi-schema.json +4 -1
@@ -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.

Quoted 1 line
Quoted 9 lines

qapi-schema.json

Quoted 7 lines
qapi-schema.json +7 -0
+#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.

Quoted 9 lines
Quoted 9 lines
qapi-schema.json +2 -0
+} 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;
 
Quoted 12 lines

qapi-schema.json CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, · line 169

Quoted 8 lines
qapi-schema.json +6 -2
-    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

Quoted 4 lines
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Signature · 1 line
			Amos.