Skip to contentSkip to conversation

qapi: remove the 'middle' mode

PATCH Superseded [email protected] 6 participants 44 messages Jul 21, 2016 – Aug 9, 2016 Kbuild

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover qapi: remove the 'middle' mode

From: Marc-André Lureau <[email protected]>

Hi,

Although some QMP commands are still not fully qapi'fied, it is possible to use more qapi common and generated code by dropping the 'middle' mode.

v2:
- rebased on master
- add Since: 0.13 to qmp_capabilities and device_add documentation
- fix device_add doc
- add missing spaces after ',' in get_qmp_greeting()
- fix some grammar in monitor.c while touching it

Marc-André Lureau (12):
qapi-schema: use generated marshaller for 'qmp_capabilities'
qapi-schema: add 'device_add'
monitor: register gen:false commands manually
monitor: remove usage of generated marshal functions
monitor: register the qapi generated commands
monitor: remove mhandler.cmd_new
monitor: implement 'qmp_query_commands' without qmp_cmds
build-sys: remove qmp-commands-old.h
qapi: remove the "middle" mode
monitor: use qmp_dispatch()
qmp: update qmp_query_spice fallback
Drop qmp-commands.hx

 monitor.c                           |  408 +++---------
 .gitignore                          |    1 -
 MAINTAINERS                         |    2 +-
 Makefile                            |    5 +-
 Makefile.target                     |    7 +-
 docs/qapi-code-gen.txt              |    6 +-
 docs/writing-qmp-commands.txt       |   46 +-
 hmp-commands-info.hx                |  118 ++--
 hmp-commands.hx                     |  208 +++---
 qapi-schema.json                    |   50 ++
 qmp-commands.hx => qmp-commands.txt | 1256 +----------------------------------
 qmp.c                               |   16 -
 scripts/qapi-commands.py            |   29 +-
 trace-events                        |    1 -
 vl.c                                |    1 +
 15 files changed, 323 insertions(+), 1831 deletions(-)
 rename qmp-commands.hx => qmp-commands.txt (82%)
Signature · 1 line
2.9.0
#1 lore raw

PATCH v2 1/12 qapi-schema: use generated marshaller for 'qmp_capabilities'

From: Marc-André Lureau <[email protected]>

qapi'fy the 'qmp_capabilities' command.

---
 monitor.c        |  4 ++--
 qapi-schema.json | 21 +++++++++++++++++++++
 qmp-commands.hx  |  2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)
monitor.c +2 -2
index 5d68a5d..cb1a0c7 100644
@@ -617,7 +617,7 @@ static void monitor_qapi_event_init(void)
     qmp_event_set_func_emit(monitor_qapi_event_queue);
 }
 
-static void qmp_capabilities(QDict *params, QObject **ret_data, Error **errp)
+void qmp_qmp_capabilities(Error **errp)
 {
     cur_mon->qmp.in_command_mode = true;
 }
@@ -3649,7 +3649,7 @@ static int monitor_can_read(void *opaque)
 static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
                              Error **errp)
 {
-    bool is_cap = cmd->mhandler.cmd_new == qmp_capabilities;
+    bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;
 
     if (is_cap && mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
qapi-schema.json +21 -0
index 5658723..03c15d8 100644
@@ -20,6 +20,27 @@
 # QAPI introspection
 { 'include': 'qapi/introspect.json' }
 
+##
+# @qmp_capabilities:
+#
+# Enable QMP capabilities.
+#
+# Arguments: None.
+#
+# Example:
+#
+# -> { "execute": "qmp_capabilities" }
+# <- { "return": {} }
+#
+# Notes: This command is valid exactly when first connecting: it must be
+# issued before any other command will be accepted, and will fail once the
+# monitor is accepting other commands.
+#
+# Since: 0.13
+#
+##
+{ 'command': 'qmp_capabilities' }
+
 ##
 # @LostTickPolicy:
 #
qmp-commands.hx +1 -1
index c8d360a..13707ac 100644
@@ -2209,7 +2209,7 @@ EQMP
         .args_type  = "",
         .params     = "",
         .help       = "enable QMP capabilities",
-        .mhandler.cmd_new = qmp_capabilities,
+        .mhandler.cmd_new = qmp_marshal_qmp_capabilities,
     },
 
 SQMP
Signature · 1 line
2.9.0
Reviewed-by on v2 1/12
#2 lore raw

Re: [Qemu-devel] [PATCH v2 01/12] qapi-schema: use generated marshaller for 'qmp_capabilities'

Quoted 47 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

qapi'fy the 'qmp_capabilities' command.

---
 monitor.c        |  4 ++--
 qapi-schema.json | 21 +++++++++++++++++++++
 qmp-commands.hx  |  2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)
monitor.c +2 -2
index 5d68a5d..cb1a0c7 100644
@@ -617,7 +617,7 @@ static void monitor_qapi_event_init(void)
     qmp_event_set_func_emit(monitor_qapi_event_queue);
 }
 
-static void qmp_capabilities(QDict *params, QObject **ret_data, Error **errp)
+void qmp_qmp_capabilities(Error **errp)
 {
     cur_mon->qmp.in_command_mode = true;
 }
@@ -3649,7 +3649,7 @@ static int monitor_can_read(void *opaque)
 static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
                              Error **errp)
 {
-    bool is_cap = cmd->mhandler.cmd_new == qmp_capabilities;
+    bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;
 
     if (is_cap && mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
qapi-schema.json +5 -0
index 5658723..03c15d8 100644
@@ -20,6 +20,27 @@
 # QAPI introspection
 { 'include': 'qapi/introspect.json' }
 
+##
+# @qmp_capabilities:
+#
+# Enable QMP capabilities.
+#

qapi-schema.json line 37

Quoted 10 lines
qapi-schema.json +10 -0
+# Arguments: None.
+#
+# Example:
+#
+# -> { "execute": "qmp_capabilities" }
+# <- { "return": {} }
+#
+# Notes: This command is valid exactly when first connecting: it must be
+# issued before any other command will be accepted, and will fail once the
+# monitor is accepting other commands.

Pointer to docs/qmp-spec.txt wouldn't hurt.

Quoted 14 lines
qapi-schema.json +6 -0
+#
+# Since: 0.13
+#
+##
+{ 'command': 'qmp_capabilities' }
+
 ##
 # @LostTickPolicy:
 #
qmp-commands.hx +0 -0
index c8d360a..13707ac 100644

qmp-commands.hx EQMP · line 2215

Quoted 8 lines
qmp-commands.hx +1 -1
@@ -2209,7 +2209,7 @@ EQMP
         .args_type  = "",
         .params     = "",
         .help       = "enable QMP capabilities",
-        .mhandler.cmd_new = qmp_capabilities,
+        .mhandler.cmd_new = qmp_marshal_qmp_capabilities,
     },
 
 SQMP

According to docs/qmp-spec.txt section 4, the command is for negotiating capabilities:

Clients should use the qmp_capabilities command to enable capabilities advertised in the Server's greeting (section '2.2 Server Greeting') they support.

It neglects to specify how that might be done, though.

Section 2.2 specifies the greeting's member "capabilities" as json-array, without saying anything about its members.

Section 2.2.1 seems to imply the members are strings, which makes some sense.

To actually support capabilities negotiation, the command needs an argument matching the greeting's capabilities array. The argument must be optional, defaulting to the empty array. No need to add that now.

Clarifying the docs would be nice, but it's not this patch's job.

#3 lore raw

PATCH v2 2/12 qapi-schema: add 'device_add'

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Even though device_add is not fully qapi'fied, we may add it to the json schema with 'gen': false, so registration and documentation can be generated.

---
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
qapi-schema.json +29 -0
index 03c15d8..e950264 100644
@@ -2200,6 +2200,35 @@
 ##
 { 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } }
 
+##
+# @device_add:
+#
+# @driver: the name of the new device's driver
+# @bus: #optional the device's parent bus (device tree path)
+# @id: the device's ID, must be unique
+# @props: #optional a dictionary of properties to be passed to the backend
+#
+# Add a device.
+#
+# Notes:
+# 1. For detailed information about this command, please refer to the
+#    'docs/qdev-device-use.txt' file.
+#
+# 2. It's possible to list device properties by running QEMU with the
+#    "-device DEVICE,help" command-line argument, where DEVICE is the
+#    device's name
+#
+# Example:
+#
+# -> { "execute": "device_add",
+#      "arguments": { "driver": "e1000", "id": "net1" } }
+# <- { "return": {} }
+#
+# Since: 0.13
+##
+{ 'command': 'device_add',
+  'data': {'driver': 'str', 'id': 'str'}, 'gen': false }
+
 ##
 # @device_del:
 #
Signature · 1 line
2.9.0
Reviewed-by on v2 2/12
#4 lore raw

Re: [Qemu-devel] [PATCH v2 02/12] qapi-schema: add 'device_add'

Quoted 29 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Even though device_add is not fully qapi'fied, we may add it to the json schema with 'gen': false, so registration and documentation can be generated.

---
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

+++ b/qapi-schema.json

qapi-schema.json +12 -0
@@ -2200,6 +2200,35 @@
 ##
 { 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } }
 
+##
+# @device_add:
+#
+# @driver: the name of the new device's driver
+# @bus: #optional the device's parent bus (device tree path)
+# @id: the device's ID, must be unique
+# @props: #optional a dictionary of properties to be passed to the backend
+#
+# Add a device.
+#
+# Notes:
+# 1. For detailed information about this command, please refer to the

qapi-schema.json line 2224

Quoted 10 lines
qapi-schema.json +10 -0
+#    'docs/qdev-device-use.txt' file.
+#
+# 2. It's possible to list device properties by running QEMU with the
+#    "-device DEVICE,help" command-line argument, where DEVICE is the
+#    device's name
+#
+# Example:
+#
+# -> { "execute": "device_add",
+#      "arguments": { "driver": "e1000", "id": "net1" } }

Is it worth an example that includes 'bus' and/or 'props'?

qapi-schema.json line 2230

Quoted 6 lines
qapi-schema.json +6 -0
+# <- { "return": {} }
+#
+# Since: 0.13
+##
+{ 'command': 'device_add',
+  'data': {'driver': 'str', 'id': 'str'}, 'gen': false }

The documentation mentions fields not listed here, but the 'gen':false explains why. We may yet get device_add QAPIfied for 2.8, but there's nothing wrong with documenting things now.

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

Re: [Qemu-devel] [PATCH v2 02/12] qapi-schema: add 'device_add'

Hi

Quoted 34 lines · Eric Blake
Quoted 33 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Even though device_add is not fully qapi'fied, we may add it to the json schema with 'gen': false, so registration and documentation can be generated.

---
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

+++ b/qapi-schema.json

qapi-schema.json +16 -0
@@ -2200,6 +2200,35 @@
 ##
 { 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } }
 
+##
+# @device_add:
+#
+# @driver: the name of the new device's driver
+# @bus: #optional the device's parent bus (device tree path)
+# @id: the device's ID, must be unique
+# @props: #optional a dictionary of properties to be passed to the backend
+#
+# Add a device.
+#
+# Notes:
+# 1. For detailed information about this command, please refer to the
+#    'docs/qdev-device-use.txt' file.
+#
+# 2. It's possible to list device properties by running QEMU with the
+#    "-device DEVICE,help" command-line argument, where DEVICE is the
Quoted 8 lines

qapi-schema.json line 2224

Quoted 6 lines
qapi-schema.json +6 -0
+#    device's name
+#
+# Example:
+#
+# -> { "execute": "device_add",
+#      "arguments": { "driver": "e1000", "id": "net1" } }

Is it worth an example that includes 'bus' and/or 'props'?

done

Quoted 19 lines

qapi-schema.json line 2230

Quoted 7 lines
qapi-schema.json +6 -0
+# <- { "return": {} }
+#
+# Since: 0.13
+##
+{ 'command': 'device_add',
+  'data': {'driver': 'str', 'id': 'str'}, 'gen': false }

The documentation mentions fields not listed here, but the 'gen':false explains why. We may yet get device_add QAPIfied for 2.8, but there's nothing wrong with documenting things now.

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

Signature · 1 line
Marc-André Lureau
#6 lore raw

Re: [Qemu-devel] [PATCH v2 02/12] qapi-schema: add 'device_add'

In reply to [email protected]
Quoted 16 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Even though device_add is not fully qapi'fied, we may add it to the json schema with 'gen': false, so registration and documentation can be generated.

---
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
qapi-schema.json +0 -0
index 03c15d8..e950264 100644

qapi-schema.json line 2209

Quoted 10 lines
qapi-schema.json +7 -0
@@ -2200,6 +2200,35 @@
 ##
 { 'command': 'xen-set-global-dirty-log', 'data': { 'enable': 'bool' } }
 
+##
+# @device_add:
+#
+# @driver: the name of the new device's driver
+# @bus: #optional the device's parent bus (device tree path)
+# @id: the device's ID, must be unique
+# @props: #optional a dictionary of properties to be passed to the backend

I'm afraid @props is wrong. The properties are passed inline, like this:

    { "execute": "device_add",
      "arguments": { "driver": "e1000", "id": "nic1", "netdev": "netdev1" } }

*not* in a separate @props object. See also commit b8a9832 "qapi-schema: Fix up misleading specification of netdev_add".

Quoted 5 lines
qapi-schema.json +5 -0
+#
+# Add a device.
+#
+# Notes:
+# 1. For detailed information about this command, please refer to the

qapi-schema.json line 2224

Quoted 10 lines
qapi-schema.json +10 -0
+#    'docs/qdev-device-use.txt' file.
+#
+# 2. It's possible to list device properties by running QEMU with the
+#    "-device DEVICE,help" command-line argument, where DEVICE is the
+#    device's name
+#
+# Example:
+#
+# -> { "execute": "device_add",
+#      "arguments": { "driver": "e1000", "id": "net1" } }

Please include at least one property in the example.

qapi-schema.json line 2234

Quoted 10 lines
qapi-schema.json +7 -0
+# <- { "return": {} }
+#
+# Since: 0.13
+##
+{ 'command': 'device_add',
+  'data': {'driver': 'str', 'id': 'str'}, 'gen': false }
+
 ##
 # @device_del:
 #

I like the general idea to do the non-qapi device_add like the simplarly non-qapi netdev_add.

#7 lore raw

PATCH v2 3/12 monitor: register gen:false commands manually

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Since a few commands are using 'gen': false, they are not registered automatically by the generator. Register manually instead.

This is in preparation for removal of qapi 'middle' mode generation.

---
 monitor.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
monitor.c +13 -0
index cb1a0c7..c9191e5 100644
@@ -79,6 +79,7 @@
 #include "sysemu/block-backend.h"
 #include "sysemu/qtest.h"
 #include "qemu/cutils.h"
+#include "qapi/qmp/dispatch.h"
 
 /* for hmp_info_irq/pic */
 #if defined(TARGET_SPARC)
@@ -1000,6 +1001,18 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,
     *ret_data = qobject_from_json(qmp_schema_json);
 }
 
+static void qmp_init_marshal(void)
+{
+    qmp_register_command("query-qmp-schema", qmp_query_qmp_schema,
+                         QCO_NO_OPTIONS);
+    qmp_register_command("device_add", qmp_device_add,
+                         QCO_NO_OPTIONS);
+    qmp_register_command("netdev_add", qmp_netdev_add,
+                         QCO_NO_OPTIONS);
+}
+
+qapi_init(qmp_init_marshal);
+
 /* set the current CPU defined by the user */
 int monitor_set_cpu(int cpu_index)
 {
Signature · 1 line
2.9.0
#8 lore raw

Re: [Qemu-devel] [PATCH v2 03/12] monitor: register gen:false commands manually

Quoted 14 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Since a few commands are using 'gen': false, they are not registered automatically by the generator. Register manually instead.

This is in preparation for removal of qapi 'middle' mode generation.

---
 monitor.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

monitor.c static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, · line 1011

Quoted 8 lines
monitor.c +8 -0
+static void qmp_init_marshal(void)
+{
+    qmp_register_command("query-qmp-schema", qmp_query_qmp_schema,
+                         QCO_NO_OPTIONS);
+    qmp_register_command("device_add", qmp_device_add,
+                         QCO_NO_OPTIONS);
+    qmp_register_command("netdev_add", qmp_netdev_add,
+                         QCO_NO_OPTIONS);

Of course, if my netdev_add patch goes in first (currently on Markus' qapi-not-next branch, because we decided it was too risky for 2.7 hard freeze), then this last line is not needed.

R-b still stands.

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

PATCH v2 4/12 monitor: remove usage of generated marshal functions

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Once the middle mode is removed, the generated marshal functions will no longer be exported.

---
 monitor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
monitor.c +5 -5
index c9191e5..3a28b43 100644
@@ -3659,21 +3659,21 @@ static int monitor_can_read(void *opaque)
     return (mon->suspend_cnt == 0) ? 1 : 0;
 }
 
-static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
+static bool invalid_qmp_mode(const Monitor *mon, const char *cmd,
                              Error **errp)
 {
-    bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;
+    bool is_cap = !g_strcmp0(cmd, "qmp_capabilities");
 
     if (is_cap && mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "Capabilities negotiation is already complete, command "
-                  "'%s' ignored", cmd->name);
+                  "'%s' ignored", cmd);
         return true;
     }
     if (!is_cap && !mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "Expecting capabilities negotiation with "
-                  "'qmp_capabilities' before command '%s'", cmd->name);
+                  "'qmp_capabilities' before command '%s'", cmd);
         return true;
     }
     return false;
@@ -3964,7 +3964,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
                   "The command %s has not been found", cmd_name);
         goto err_out;
     }
-    if (invalid_qmp_mode(mon, cmd, &local_err)) {
+    if (invalid_qmp_mode(mon, cmd_name, &local_err)) {
         goto err_out;
     }
 
Signature · 1 line
2.9.0
#10 lore raw

Re: [Qemu-devel] [PATCH v2 04/12] monitor: remove usage of generated marshal functions

Quoted 16 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Once the middle mode is removed, the generated marshal functions will no longer be exported.

---
 monitor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
monitor.c +0 -0
index c9191e5..3a28b43 100644

monitor.c static int monitor_can_read(void *opaque) · line 3665

Quoted 9 lines
monitor.c +2 -2
@@ -3659,21 +3659,21 @@ static int monitor_can_read(void *opaque)
     return (mon->suspend_cnt == 0) ? 1 : 0;
 }
 
-static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
+static bool invalid_qmp_mode(const Monitor *mon, const char *cmd,
                              Error **errp)
 {
-    bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;
+    bool is_cap = !g_strcmp0(cmd, "qmp_capabilities");

What's wrong with strcmp()?

Quoted 24 lines
monitor.c +3 -3
     if (is_cap && mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "Capabilities negotiation is already complete, command "
-                  "'%s' ignored", cmd->name);
+                  "'%s' ignored", cmd);
         return true;
     }
     if (!is_cap && !mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "Expecting capabilities negotiation with "
-                  "'qmp_capabilities' before command '%s'", cmd->name);
+                  "'qmp_capabilities' before command '%s'", cmd);
         return true;
     }
     return false;
@@ -3964,7 +3964,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
                   "The command %s has not been found", cmd_name);
         goto err_out;
     }
-    if (invalid_qmp_mode(mon, cmd, &local_err)) {
+    if (invalid_qmp_mode(mon, cmd_name, &local_err)) {
         goto err_out;
     }
#11 lore raw

Re: [Qemu-devel] [PATCH v2 04/12] monitor: remove usage of generated marshal functions

Hi

----- Original Message -----

Quoted 21 lines
Quoted 19 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Once the middle mode is removed, the generated marshal functions will no longer be exported.

---
 monitor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
monitor.c +0 -0
index c9191e5..3a28b43 100644
@@ -3659,21 +3659,21 @@ static int monitor_can_read(void *opaque)
     return (mon->suspend_cnt == 0) ? 1 : 0;
 }
 
Quoted 9 lines

monitor.c static int monitor_can_read(void *opaque) · line 3665

Quoted 6 lines
monitor.c +2 -2
-static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
+static bool invalid_qmp_mode(const Monitor *mon, const char *cmd,
                              Error **errp)
 {
-    bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;
+    bool is_cap = !g_strcmp0(cmd, "qmp_capabilities");

What's wrong with strcmp()?

g_strcmp0() is a slightly safer version, it's just an habit, I guess it doesn't matter here, would you like to change it?

Quoted 26 lines
Quoted 25 lines
monitor.c +3 -3
     if (is_cap && mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "Capabilities negotiation is already complete, command "
-                  "'%s' ignored", cmd->name);
+                  "'%s' ignored", cmd);
         return true;
     }
     if (!is_cap && !mon->qmp.in_command_mode) {
         error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "Expecting capabilities negotiation with "
-                  "'qmp_capabilities' before command '%s'", cmd->name);
+                  "'qmp_capabilities' before command '%s'", cmd);
         return true;
     }
     return false;
@@ -3964,7 +3964,7 @@ static void handle_qmp_command(JSONMessageParser
 *parser, GQueue *tokens)
                   "The command %s has not been found", cmd_name);
         goto err_out;
     }
-    if (invalid_qmp_mode(mon, cmd, &local_err)) {
+    if (invalid_qmp_mode(mon, cmd_name, &local_err)) {
         goto err_out;
     }
#12 lore raw

Re: [Qemu-devel] [PATCH v2 04/12] monitor: remove usage of generated marshal functions

Quoted 34 lines · Marc-André Lureau

Hi

----- Original Message -----

Quoted 21 lines
Quoted 19 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Once the middle mode is removed, the generated marshal functions will no longer be exported.

---
 monitor.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
monitor.c +0 -0
index c9191e5..3a28b43 100644
@@ -3659,21 +3659,21 @@ static int monitor_can_read(void *opaque)
     return (mon->suspend_cnt == 0) ? 1 : 0;
 }
 
Quoted 9 lines

monitor.c static int monitor_can_read(void *opaque) · line 3665

Quoted 6 lines
monitor.c +2 -2
-static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd,
+static bool invalid_qmp_mode(const Monitor *mon, const char *cmd,
                              Error **errp)
 {
-    bool is_cap = cmd->mhandler.cmd_new == qmp_marshal_qmp_capabilities;
+    bool is_cap = !g_strcmp0(cmd, "qmp_capabilities");

What's wrong with strcmp()?

Quoted 1 line

g_strcmp0() is a slightly safer version, it's just an habit, I guess it doesn't matter here, would you like to change it?

Yes.

[...]

#13 lore raw

PATCH v2 5/12 monitor: register the qapi generated commands

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Stop using the so-called 'middle' mode. Instead, use qmp_find_command() from generated qapi commands registry.

Note: this commit requires a 'make clean' prior to make, since the generated files do not depend on Makefile (due to a cyclic rule introduced in 4115852bb0).

---
 monitor.c       |  15 ++++--
 Makefile        |   2 +-
 qmp-commands.hx | 143 --------------------------------------------------------
 vl.c            |   1 +
 4 files changed, 13 insertions(+), 148 deletions(-)
monitor.c +11 -4
index 3a28b43..5bbe4bb 100644
@@ -3934,6 +3934,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
     QObject *obj, *data;
     QDict *input, *args;
     const mon_cmd_t *cmd;
+    QmpCommand *qcmd;
     const char *cmd_name;
     Monitor *mon = cur_mon;
 
@@ -3959,7 +3960,8 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
     cmd_name = qdict_get_str(input, "execute");
     trace_handle_qmp_command(mon, cmd_name);
     cmd = qmp_find_cmd(cmd_name);
-    if (!cmd) {
+    qcmd = qmp_find_command(cmd_name);
+    if (!qcmd || !cmd) {
         error_set(&local_err, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "The command %s has not been found", cmd_name);
         goto err_out;
@@ -3981,7 +3983,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
         goto err_out;
     }
 
-    cmd->mhandler.cmd_new(args, &data, &local_err);
+    qcmd->fn(args, &data, &local_err);
 
 err_out:
     monitor_protocol_emitter(mon, data, local_err);
@@ -4050,10 +4052,15 @@ void monitor_resume(Monitor *mon)
 
 static QObject *get_qmp_greeting(void)
 {
+    QmpCommand *cmd;
     QObject *ver = NULL;
 
-    qmp_marshal_query_version(NULL, &ver, NULL);
-    return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
+    cmd = qmp_find_command("query-version");
+    assert(cmd && cmd->fn);
+    cmd->fn(NULL, &ver, NULL);
+
+    return qobject_from_jsonf("{'QMP':{'version': %p, 'capabilities': []}}",
+                              ver);
 }
 
 static void monitor_qmp_event(void *opaque, int event)
Makefile +1 -1
index 0d7647f..fcdc192 100644
@@ -311,7 +311,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
 qmp-commands.h qmp-marshal.c :\
 $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
-		$(gen-out-type) -o "." -m $<, \
+		$(gen-out-type) -o "." $<, \
 		"  GEN   $@")
 qmp-introspect.h qmp-introspect.c :\
 $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
qmp-commands.hx +0 -143

967 lines not on this page · raw message

vl.c +1 -0
index a455947..a819e05 100644
@@ -2971,6 +2971,7 @@ int main(int argc, char **argv, char **envp)
     qemu_init_exec_dir(argv[0]);
 
     module_call_init(MODULE_INIT_QOM);
+    module_call_init(MODULE_INIT_QAPI);
 
     qemu_add_opts(&qemu_drive_opts);
     qemu_add_drive_opts(&qemu_legacy_drive_opts);
Signature · 1 line
2.9.0
Reviewed-by on v2 5/12
#14 lore raw

Re: [Qemu-devel] [PATCH v2 05/12] monitor: register the qapi generated commands

Quoted 9 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Stop using the so-called 'middle' mode. Instead, use qmp_find_command() from generated qapi commands registry.

Note: this commit requires a 'make clean' prior to make, since the generated files do not depend on Makefile (due to a cyclic rule introduced in 4115852bb0).

Quoted 8 lines
---
 monitor.c       |  15 ++++--
 Makefile        |   2 +-
 qmp-commands.hx | 143 --------------------------------------------------------
 vl.c            |   1 +
 4 files changed, 13 insertions(+), 148 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#15 lore raw

Re: [Qemu-devel] [PATCH v2 05/12] monitor: register the qapi generated commands

In reply to [email protected]
Quoted 8 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Stop using the so-called 'middle' mode. Instead, use qmp_find_command() from generated qapi commands registry.

Note: this commit requires a 'make clean' prior to make, since the generated files do not depend on Makefile (due to a cyclic rule introduced in 4115852bb0).

We generally say "commit 4115852bb0".

Sounds like we had a cyclic dependency. Do you mean "they don't depend on Makefile, because that would be a cyclic dependency"?

Paolo, any smart ideas on how to avoid "requires a 'make clean'"?

Quoted 21 lines
---
 monitor.c       |  15 ++++--
 Makefile        |   2 +-
 qmp-commands.hx | 143 --------------------------------------------------------
 vl.c            |   1 +
 4 files changed, 13 insertions(+), 148 deletions(-)
monitor.c +1 -0
index 3a28b43..5bbe4bb 100644
@@ -3934,6 +3934,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
     QObject *obj, *data;
     QDict *input, *args;
     const mon_cmd_t *cmd;
+    QmpCommand *qcmd;
     const char *cmd_name;
     Monitor *mon = cur_mon;
 

monitor.c static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) · line 3964

Quoted 6 lines
monitor.c +2 -1
@@ -3959,7 +3960,8 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
     cmd_name = qdict_get_str(input, "execute");
     trace_handle_qmp_command(mon, cmd_name);
     cmd = qmp_find_cmd(cmd_name);
-    if (!cmd) {
+    qcmd = qmp_find_command(cmd_name);
+    if (!qcmd || !cmd) {

Looks awkward, but it's temporary. Makes sense.

Quoted 17 lines
monitor.c +2 -1
         error_set(&local_err, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "The command %s has not been found", cmd_name);
         goto err_out;
@@ -3981,7 +3983,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
         goto err_out;
     }
 
-    cmd->mhandler.cmd_new(args, &data, &local_err);
+    qcmd->fn(args, &data, &local_err);
 
 err_out:
     monitor_protocol_emitter(mon, data, local_err);
@@ -4050,10 +4052,15 @@ void monitor_resume(Monitor *mon)
 
 static QObject *get_qmp_greeting(void)
 {
+    QmpCommand *cmd;

monitor.c void monitor_resume(Monitor *mon) · line 4063

Quoted 10 lines
monitor.c +6 -2
     QObject *ver = NULL;
 
-    qmp_marshal_query_version(NULL, &ver, NULL);
-    return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
+    cmd = qmp_find_command("query-version");
+    assert(cmd && cmd->fn);
+    cmd->fn(NULL, &ver, NULL);
+
+    return qobject_from_jsonf("{'QMP':{'version': %p, 'capabilities': []}}",
+                              ver);

Meh.

The generator makes the generated qmp_marshal_FOOs() static unless middle mode. Middle mode is going away (good riddance). But replacing the linker's work by qmp_find_command() just so we can keep the qmp_marshal_FOOs() static isn't an improvement. Especially since it adds another run-time failure mode. Let's change the generator instead.

Quoted 21 lines
monitor.c +0 -0
 }
 
 static void monitor_qmp_event(void *opaque, int event)
Makefile +1 -1
index 0d7647f..fcdc192 100644
@@ -311,7 +311,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
 qmp-commands.h qmp-marshal.c :\
 $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
-		$(gen-out-type) -o "." -m $<, \
+		$(gen-out-type) -o "." $<, \
 		"  GEN   $@")
 qmp-introspect.h qmp-introspect.c :\
 $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
qmp-commands.hx +0 -0
index 13707ac..1ad8dda 100644

qmp-commands.hx EQMP · line 68

Quoted 7 lines
qmp-commands.hx +0 -1
@@ -63,7 +63,6 @@ EQMP
     {
         .name       = "quit",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_quit,
     },
 
 SQMP

[More of the same snipped...]

vl.c int main(int argc, char **argv, char **envp) · line 2977

Quoted 12 lines
vl.c +1 -0
index a455947..a819e05 100644
@@ -2971,6 +2971,7 @@ int main(int argc, char **argv, char **envp)
     qemu_init_exec_dir(argv[0]);
 
     module_call_init(MODULE_INIT_QOM);
+    module_call_init(MODULE_INIT_QAPI);
 
     qemu_add_opts(&qemu_drive_opts);
     qemu_add_drive_opts(&qemu_legacy_drive_opts);

So the code added by PATCH 03 doesn't actually run without this, right? Okay with me, but let's mention it in the commit message of PATCH 03.

#16 lore raw

Re: [Qemu-devel] [PATCH v2 05/12] monitor: register the qapi generated commands

Quoted 11 lines · Markus Armbruster
Quoted 8 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Stop using the so-called 'middle' mode. Instead, use qmp_find_command() from generated qapi commands registry.

Note: this commit requires a 'make clean' prior to make, since the generated files do not depend on Makefile (due to a cyclic rule introduced in 4115852bb0).

Quoted 6 lines

We generally say "commit 4115852bb0".

Sounds like we had a cyclic dependency. Do you mean "they don't depend on Makefile, because that would be a cyclic dependency"?

Paolo, any smart ideas on how to avoid "requires a 'make clean'"?

Nope, sorry. :( But if you squash the generator patch that makes qmp_marshal_* non-static, it should work.

The idea in that commit comes from autotools. I'm not sure how they deal with it.

Paolo

Quoted 111 lines
Quoted 21 lines
---
 monitor.c       |  15 ++++--
 Makefile        |   2 +-
 qmp-commands.hx | 143 --------------------------------------------------------
 vl.c            |   1 +
 4 files changed, 13 insertions(+), 148 deletions(-)
monitor.c +1 -0
index 3a28b43..5bbe4bb 100644
@@ -3934,6 +3934,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
     QObject *obj, *data;
     QDict *input, *args;
     const mon_cmd_t *cmd;
+    QmpCommand *qcmd;
     const char *cmd_name;
     Monitor *mon = cur_mon;
 

monitor.c static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) · line 3964

Quoted 6 lines
monitor.c +2 -1
@@ -3959,7 +3960,8 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
     cmd_name = qdict_get_str(input, "execute");
     trace_handle_qmp_command(mon, cmd_name);
     cmd = qmp_find_cmd(cmd_name);
-    if (!cmd) {
+    qcmd = qmp_find_command(cmd_name);
+    if (!qcmd || !cmd) {

Looks awkward, but it's temporary. Makes sense.

Quoted 17 lines
monitor.c +2 -1
         error_set(&local_err, ERROR_CLASS_COMMAND_NOT_FOUND,
                   "The command %s has not been found", cmd_name);
         goto err_out;
@@ -3981,7 +3983,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
         goto err_out;
     }
 
-    cmd->mhandler.cmd_new(args, &data, &local_err);
+    qcmd->fn(args, &data, &local_err);
 
 err_out:
     monitor_protocol_emitter(mon, data, local_err);
@@ -4050,10 +4052,15 @@ void monitor_resume(Monitor *mon)
 
 static QObject *get_qmp_greeting(void)
 {
+    QmpCommand *cmd;

monitor.c void monitor_resume(Monitor *mon) · line 4063

Quoted 10 lines
monitor.c +6 -2
     QObject *ver = NULL;
 
-    qmp_marshal_query_version(NULL, &ver, NULL);
-    return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
+    cmd = qmp_find_command("query-version");
+    assert(cmd && cmd->fn);
+    cmd->fn(NULL, &ver, NULL);
+
+    return qobject_from_jsonf("{'QMP':{'version': %p, 'capabilities': []}}",
+                              ver);

Meh.

The generator makes the generated qmp_marshal_FOOs() static unless middle mode. Middle mode is going away (good riddance). But replacing the linker's work by qmp_find_command() just so we can keep the qmp_marshal_FOOs() static isn't an improvement. Especially since it adds another run-time failure mode. Let's change the generator instead.

Quoted 21 lines
monitor.c +0 -0
 }
 
 static void monitor_qmp_event(void *opaque, int event)
Makefile +1 -1
index 0d7647f..fcdc192 100644
@@ -311,7 +311,7 @@ $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
 qmp-commands.h qmp-marshal.c :\
 $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
-		$(gen-out-type) -o "." -m $<, \
+		$(gen-out-type) -o "." $<, \
 		"  GEN   $@")
 qmp-introspect.h qmp-introspect.c :\
 $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
qmp-commands.hx +0 -0
index 13707ac..1ad8dda 100644

qmp-commands.hx EQMP · line 68

Quoted 7 lines
qmp-commands.hx +0 -1
@@ -63,7 +63,6 @@ EQMP
     {
         .name       = "quit",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_quit,
     },
 
 SQMP

[More of the same snipped...]

vl.c int main(int argc, char **argv, char **envp) · line 2977

Quoted 12 lines
vl.c +1 -0
index a455947..a819e05 100644
@@ -2971,6 +2971,7 @@ int main(int argc, char **argv, char **envp)
     qemu_init_exec_dir(argv[0]);
 
     module_call_init(MODULE_INIT_QOM);
+    module_call_init(MODULE_INIT_QAPI);
 
     qemu_add_opts(&qemu_drive_opts);
     qemu_add_drive_opts(&qemu_legacy_drive_opts);

So the code added by PATCH 03 doesn't actually run without this, right? Okay with me, but let's mention it in the commit message of PATCH 03.

#17 lore raw

PATCH v2 6/12 monitor: remove mhandler.cmd_new

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

This is no longer necessary, now that middle mode has been removed.

---
 monitor.c                     |  13 +--
 docs/writing-qmp-commands.txt |   8 +-
 hmp-commands-info.hx          | 118 ++++++++++++------------
 hmp-commands.hx               | 208 +++++++++++++++++++++---------------------
 4 files changed, 170 insertions(+), 177 deletions(-)
monitor.c +5 -8
index 5bbe4bb..642be2e 100644
@@ -130,13 +130,10 @@ typedef struct mon_cmd_t {
     const char *args_type;
     const char *params;
     const char *help;
-    union {
-        void (*cmd)(Monitor *mon, const QDict *qdict);
-        void (*cmd_new)(QDict *params, QObject **ret_data, Error **errp);
-    } mhandler;
-    /* @sub_table is a list of 2nd level of commands. If it do not exist,
-     * mhandler should be used. If it exist, sub_table[?].mhandler should be
-     * used, and mhandler of 1st level plays the role of help function.
+    void (*cmd)(Monitor *mon, const QDict *qdict);
+    /* @sub_table is a list of 2nd level of commands. If it does not exist,
+     * cmd should be used. If it exists, sub_table[?].cmd should be
+     * used, and cmd of 1st level plays the role of help function.
      */
     struct mon_cmd_t *sub_table;
     void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
@@ -2960,7 +2957,7 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline)
         return;
     }
 
-    cmd->mhandler.cmd(mon, qdict);
+    cmd->cmd(mon, qdict);
     QDECREF(qdict);
 }
 
docs/writing-qmp-commands.txt +2 -6
index 59aa77a..6208715 100644
@@ -127,7 +127,6 @@ following at the bottom:
     {
         .name       = "hello-world",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_hello_world,
     },
 
 You're done. Now build qemu, run it as suggested in the "Testing" section,
@@ -179,7 +178,6 @@ The last step is to update the qmp-commands.hx file:
     {
         .name       = "hello-world",
         .args_type  = "message:s?",
-        .mhandler.cmd_new = qmp_marshal_hello_world,
     },
 
 Notice that the "args_type" member got our "message" argument. The character
@@ -337,7 +335,7 @@ we should add it to the hmp-commands.hx file:
         .args_type  = "message:s?",
         .params     = "hello-world [message]",
         .help       = "Print message to the standard output",
-        .mhandler.cmd = hmp_hello_world,
+        .cmd        = hmp_hello_world,
     },
 
 STEXI
@@ -459,7 +457,6 @@ The last step is to add the correspoding entry in the qmp-commands.hx file:
     {
         .name       = "query-alarm-clock",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_query_alarm_clock,
     },
 
 Time to test the new command. Build qemu, run it as described in the "Testing"
@@ -518,7 +515,7 @@ in the monitor.c file. The entry for the "info alarmclock" follows:
         .args_type  = "",
         .params     = "",
         .help       = "show information about the alarm clock",
-        .mhandler.info = hmp_info_alarm_clock,
+        .cmd        = hmp_info_alarm_clock,
     },
 
 To test this, run qemu and type "info alarmclock" in the user monitor.
@@ -605,7 +602,6 @@ To test this you have to add the corresponding qmp-commands.hx entry:
     {
         .name       = "query-alarm-methods",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_query_alarm_methods,
     },
 
 Now Build qemu, run it as explained in the "Testing" section and try our new
hmp-commands-info.hx +59 -59

452 lines not on this page · raw message

hmp-commands.hx +104 -104

826 lines not on this page · raw message

Signature · 1 line
2.9.0
Reviewed-by on v2 6/12
#18 lore raw

Re: [Qemu-devel] [PATCH v2 06/12] monitor: remove mhandler.cmd_new

Quoted 16 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

This is no longer necessary, now that middle mode has been removed.

---
 monitor.c                     |  13 +--
 docs/writing-qmp-commands.txt |   8 +-
 hmp-commands-info.hx          | 118 ++++++++++++------------
 hmp-commands.hx               | 208 +++++++++++++++++++++---------------------
 4 files changed, 170 insertions(+), 177 deletions(-)

+++ b/docs/writing-qmp-commands.txt

Review The last step is to add the correspoding entry in the qmp-commands.hx file: · line 457

Quoted 1 line
(quoted diff) +0 -0
@@ -459,7 +457,6 @@ The last step is to add the correspoding entry in the qmp-commands.hx file:
     {

Might be worth s/correspoding/corresponding/ while touching this file.

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

Re: [Qemu-devel] [PATCH v2 06/12] monitor: remove mhandler.cmd_new

Hi

Quoted 1 line · Eric Blake

Might be worth s/correspoding/corresponding/ while touching this file.

sure, (although this block goes away with the last patch)

Signature · 1 line
Marc-André Lureau
#20 lore raw

Re: [Qemu-devel] [PATCH v2 06/12] monitor: remove mhandler.cmd_new

In reply to [email protected]
Quoted 3 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

This is no longer necessary, now that middle mode has been removed.

Well, middle mode hasn't been removed just yet, only its use. Perhaps:

This is no longer necessary now that we aren't using middle mode anymore.

Quoted 44 lines
---
 monitor.c                     |  13 +--
 docs/writing-qmp-commands.txt |   8 +-
 hmp-commands-info.hx          | 118 ++++++++++++------------
 hmp-commands.hx               | 208 +++++++++++++++++++++---------------------
 4 files changed, 170 insertions(+), 177 deletions(-)
monitor.c +5 -8
index 5bbe4bb..642be2e 100644
@@ -130,13 +130,10 @@ typedef struct mon_cmd_t {
     const char *args_type;
     const char *params;
     const char *help;
-    union {
-        void (*cmd)(Monitor *mon, const QDict *qdict);
-        void (*cmd_new)(QDict *params, QObject **ret_data, Error **errp);
-    } mhandler;
-    /* @sub_table is a list of 2nd level of commands. If it do not exist,
-     * mhandler should be used. If it exist, sub_table[?].mhandler should be
-     * used, and mhandler of 1st level plays the role of help function.
+    void (*cmd)(Monitor *mon, const QDict *qdict);
+    /* @sub_table is a list of 2nd level of commands. If it does not exist,
+     * cmd should be used. If it exists, sub_table[?].cmd should be
+     * used, and cmd of 1st level plays the role of help function.
      */
     struct mon_cmd_t *sub_table;
     void (*command_completion)(ReadLineState *rs, int nb_args, const char *str);
@@ -2960,7 +2957,7 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline)
         return;
     }
 
-    cmd->mhandler.cmd(mon, qdict);
+    cmd->cmd(mon, qdict);
     QDECREF(qdict);
 }
 
docs/writing-qmp-commands.txt +0 -0
index 59aa77a..6208715 100644

docs/writing-qmp-commands.txt following at the bottom: · line 131

Quoted 6 lines
docs/writing-qmp-commands.txt +0 -1
@@ -127,7 +127,6 @@ following at the bottom:
     {
         .name       = "hello-world",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_hello_world,
     },
 

Uh, doesn't this belong to the previous commit?

docs/writing-qmp-commands.txt The last step is to update the qmp-commands.hx file: · line 182

Quoted 8 lines
docs/writing-qmp-commands.txt +0 -1
 You're done. Now build qemu, run it as suggested in the "Testing" section,
@@ -179,7 +178,6 @@ The last step is to update the qmp-commands.hx file:
     {
         .name       = "hello-world",
         .args_type  = "message:s?",
-        .mhandler.cmd_new = qmp_marshal_hello_world,
     },
 

Likewise.

Quoted 11 lines
docs/writing-qmp-commands.txt +1 -1
 Notice that the "args_type" member got our "message" argument. The character
@@ -337,7 +335,7 @@ we should add it to the hmp-commands.hx file:
         .args_type  = "message:s?",
         .params     = "hello-world [message]",
         .help       = "Print message to the standard output",
-        .mhandler.cmd = hmp_hello_world,
+        .cmd        = hmp_hello_world,
     },
 
 STEXI

docs/writing-qmp-commands.txt The last step is to add the correspoding entry in the qmp-commands.hx file: · line 460

Quoted 5 lines
docs/writing-qmp-commands.txt +0 -1
@@ -459,7 +457,6 @@ The last step is to add the correspoding entry in the qmp-commands.hx file:
     {
         .name       = "query-alarm-clock",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_query_alarm_clock,
     },

Likewise.

Quoted 12 lines
docs/writing-qmp-commands.txt +1 -1
 Time to test the new command. Build qemu, run it as described in the "Testing"
@@ -518,7 +515,7 @@ in the monitor.c file. The entry for the "info alarmclock" follows:
         .args_type  = "",
         .params     = "",
         .help       = "show information about the alarm clock",
-        .mhandler.info = hmp_info_alarm_clock,
+        .cmd        = hmp_info_alarm_clock,
     },
 
 To test this, run qemu and type "info alarmclock" in the user monitor.

docs/writing-qmp-commands.txt To test this you have to add the corresponding qmp-commands.hx entry: · line 606

Quoted 6 lines
docs/writing-qmp-commands.txt +0 -1
@@ -605,7 +602,6 @@ To test this you have to add the corresponding qmp-commands.hx entry:
     {
         .name       = "query-alarm-methods",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_query_alarm_methods,
     },
 

Likewise.

Quoted 6 lines
docs/writing-qmp-commands.txt +0 -0
 Now Build qemu, run it as explained in the "Testing" section and try our new
hmp-commands-info.hx +0 -0
index 74446c6..19729e5 100644

hmp-commands-info.hx ETEXI · line 24

Quoted 8 lines
hmp-commands-info.hx +1 -1
@@ -18,7 +18,7 @@ ETEXI
         .args_type  = "",
         .params     = "",
         .help       = "show the version of QEMU",
-        .mhandler.cmd = hmp_info_version,
+        .cmd        = hmp_info_version,
     },
 
 STEXI

[More of the same snipped...]

#21 lore raw

Re: [Qemu-devel] [PATCH v2 06/12] monitor: remove mhandler.cmd_new

Hi

----- Original Message -----

Quoted 10 lines
Quoted 3 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

This is no longer necessary, now that middle mode has been removed.

Well, middle mode hasn't been removed just yet, only its use. Perhaps:

This is no longer necessary now that we aren't using middle mode anymore.

ok

Quoted 103 lines
Quoted 50 lines
---
 monitor.c                     |  13 +--
 docs/writing-qmp-commands.txt |   8 +-
 hmp-commands-info.hx          | 118 ++++++++++++------------
 hmp-commands.hx               | 208
 +++++++++++++++++++++---------------------
 4 files changed, 170 insertions(+), 177 deletions(-)
monitor.c +0 -6
index 5bbe4bb..642be2e 100644
@@ -130,13 +130,10 @@ typedef struct mon_cmd_t {
     const char *args_type;
     const char *params;
     const char *help;
-    union {
-        void (*cmd)(Monitor *mon, const QDict *qdict);
-        void (*cmd_new)(QDict *params, QObject **ret_data, Error **errp);
-    } mhandler;
-    /* @sub_table is a list of 2nd level of commands. If it do not exist,
-     * mhandler should be used. If it exist, sub_table[?].mhandler should

be

monitor.c +2 -1
-     * used, and mhandler of 1st level plays the role of help function.
+    void (*cmd)(Monitor *mon, const QDict *qdict);
+    /* @sub_table is a list of 2nd level of commands. If it does not

exist,

monitor.c +3 -1
+     * cmd should be used. If it exists, sub_table[?].cmd should be
+     * used, and cmd of 1st level plays the role of help function.
      */
     struct mon_cmd_t *sub_table;
     void (*command_completion)(ReadLineState *rs, int nb_args, const char
     *str);
@@ -2960,7 +2957,7 @@ static void handle_hmp_command(Monitor *mon, const
 char *cmdline)
         return;
     }
 
-    cmd->mhandler.cmd(mon, qdict);
+    cmd->cmd(mon, qdict);
     QDECREF(qdict);
 }
docs/writing-qmp-commands.txt +0 -0
index 59aa77a..6208715 100644

docs/writing-qmp-commands.txt following at the bottom: · line 131

Quoted 6 lines
docs/writing-qmp-commands.txt +0 -1
@@ -127,7 +127,6 @@ following at the bottom:
     {
         .name       = "hello-world",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_hello_world,
     },
 

Uh, doesn't this belong to the previous commit?

docs/writing-qmp-commands.txt The last step is to update the qmp-commands.hx file: · line 182

Quoted 8 lines
docs/writing-qmp-commands.txt +0 -1
 You're done. Now build qemu, run it as suggested in the "Testing" section,
@@ -179,7 +178,6 @@ The last step is to update the qmp-commands.hx file:
     {
         .name       = "hello-world",
         .args_type  = "message:s?",
-        .mhandler.cmd_new = qmp_marshal_hello_world,
     },
 

Likewise.

Quoted 13 lines
docs/writing-qmp-commands.txt +0 -0
 Notice that the "args_type" member got our "message" argument. The

character

docs/writing-qmp-commands.txt +1 -1
@@ -337,7 +335,7 @@ we should add it to the hmp-commands.hx file:
         .args_type  = "message:s?",
         .params     = "hello-world [message]",
         .help       = "Print message to the standard output",
-        .mhandler.cmd = hmp_hello_world,
+        .cmd        = hmp_hello_world,
     },
 
 STEXI
@@ -459,7 +457,6 @@ The last step is to add the correspoding entry in the

qmp-commands.hx file:

Quoted 5 lines
     {
         .name       = "query-alarm-clock",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_query_alarm_clock,
     },

Likewise.

Quoted 12 lines

Time to test the new command. Build qemu, run it as described in the "Testing"

docs/writing-qmp-commands.txt +0 -0
@@ -518,7 +515,7 @@ in the monitor.c file. The entry for the "info

alarmclock" follows:

         .args_type  = "",
         .params     = "",
         .help       = "show information about the alarm clock",
docs/writing-qmp-commands.txt +1 -1
-        .mhandler.info = hmp_info_alarm_clock,
+        .cmd        = hmp_info_alarm_clock,
     },
Quoted 11 lines
Quoted 9 lines

To test this, run qemu and type "info alarmclock" in the user monitor.

docs/writing-qmp-commands.txt +0 -0
@@ -605,7 +602,6 @@ To test this you have to add the corresponding

qmp-commands.hx entry:

     {
         .name       = "query-alarm-methods",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_query_alarm_methods,
     },

Likewise.

Ok those are from the documentation and can be moved to previous commit.

Quoted 15 lines
Quoted 15 lines

Now Build qemu, run it as explained in the "Testing" section and try our new

hmp-commands-info.hx +1 -1
index 74446c6..19729e5 100644
@@ -18,7 +18,7 @@ ETEXI
         .args_type  = "",
         .params     = "",
         .help       = "show the version of QEMU",
-        .mhandler.cmd = hmp_info_version,
+        .cmd        = hmp_info_version,
     },
 
Quoted 2 lines

hmp-commands-info.hx ETEXI · line 24

Quoted 1 line
hmp-commands-info.hx +0 -0
 STEXI

[More of the same snipped...]

However those belong with this commit (I am not sure if you meant that they should also be moved)

#22 lore raw

Re: [Qemu-devel] [PATCH v2 06/12] monitor: remove mhandler.cmd_new

Quoted 149 lines · Marc-André Lureau

Hi

----- Original Message -----

Quoted 10 lines
Quoted 3 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

This is no longer necessary, now that middle mode has been removed.

Well, middle mode hasn't been removed just yet, only its use. Perhaps:

This is no longer necessary now that we aren't using middle mode anymore.

ok

Quoted 103 lines
Quoted 50 lines
---
 monitor.c                     |  13 +--
 docs/writing-qmp-commands.txt |   8 +-
 hmp-commands-info.hx          | 118 ++++++++++++------------
 hmp-commands.hx               | 208
 +++++++++++++++++++++---------------------
 4 files changed, 170 insertions(+), 177 deletions(-)
monitor.c +0 -6
index 5bbe4bb..642be2e 100644
@@ -130,13 +130,10 @@ typedef struct mon_cmd_t {
     const char *args_type;
     const char *params;
     const char *help;
-    union {
-        void (*cmd)(Monitor *mon, const QDict *qdict);
-        void (*cmd_new)(QDict *params, QObject **ret_data, Error **errp);
-    } mhandler;
-    /* @sub_table is a list of 2nd level of commands. If it do not exist,
-     * mhandler should be used. If it exist, sub_table[?].mhandler should

be

monitor.c +2 -1
-     * used, and mhandler of 1st level plays the role of help function.
+    void (*cmd)(Monitor *mon, const QDict *qdict);
+    /* @sub_table is a list of 2nd level of commands. If it does not

exist,

monitor.c +3 -1
+     * cmd should be used. If it exists, sub_table[?].cmd should be
+     * used, and cmd of 1st level plays the role of help function.
      */
     struct mon_cmd_t *sub_table;
     void (*command_completion)(ReadLineState *rs, int nb_args, const char
     *str);
@@ -2960,7 +2957,7 @@ static void handle_hmp_command(Monitor *mon, const
 char *cmdline)
         return;
     }
 
-    cmd->mhandler.cmd(mon, qdict);
+    cmd->cmd(mon, qdict);
     QDECREF(qdict);
 }
docs/writing-qmp-commands.txt +0 -0
index 59aa77a..6208715 100644

docs/writing-qmp-commands.txt following at the bottom: · line 131

Quoted 6 lines
docs/writing-qmp-commands.txt +0 -1
@@ -127,7 +127,6 @@ following at the bottom:
     {
         .name       = "hello-world",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_hello_world,
     },
 

Uh, doesn't this belong to the previous commit?

docs/writing-qmp-commands.txt The last step is to update the qmp-commands.hx file: · line 182

Quoted 8 lines
docs/writing-qmp-commands.txt +0 -1
 You're done. Now build qemu, run it as suggested in the "Testing" section,
@@ -179,7 +178,6 @@ The last step is to update the qmp-commands.hx file:
     {
         .name       = "hello-world",
         .args_type  = "message:s?",
-        .mhandler.cmd_new = qmp_marshal_hello_world,
     },
 

Likewise.

Quoted 13 lines
docs/writing-qmp-commands.txt +0 -0
 Notice that the "args_type" member got our "message" argument. The

character

docs/writing-qmp-commands.txt +1 -1
@@ -337,7 +335,7 @@ we should add it to the hmp-commands.hx file:
         .args_type  = "message:s?",
         .params     = "hello-world [message]",
         .help       = "Print message to the standard output",
-        .mhandler.cmd = hmp_hello_world,
+        .cmd        = hmp_hello_world,
     },
 
 STEXI
@@ -459,7 +457,6 @@ The last step is to add the correspoding entry in the

qmp-commands.hx file:

Quoted 5 lines
     {
         .name       = "query-alarm-clock",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_query_alarm_clock,
     },

Likewise.

Quoted 12 lines

Time to test the new command. Build qemu, run it as described in the "Testing"

docs/writing-qmp-commands.txt +0 -0
@@ -518,7 +515,7 @@ in the monitor.c file. The entry for the "info

alarmclock" follows:

         .args_type  = "",
         .params     = "",
         .help       = "show information about the alarm clock",
docs/writing-qmp-commands.txt +1 -1
-        .mhandler.info = hmp_info_alarm_clock,
+        .cmd        = hmp_info_alarm_clock,
     },
Quoted 11 lines
Quoted 9 lines

To test this, run qemu and type "info alarmclock" in the user monitor.

docs/writing-qmp-commands.txt +0 -0
@@ -605,7 +602,6 @@ To test this you have to add the corresponding

qmp-commands.hx entry:

     {
         .name       = "query-alarm-methods",
         .args_type  = "",
-        .mhandler.cmd_new = qmp_marshal_query_alarm_methods,
     },

Likewise.

Ok those are from the documentation and can be moved to previous commit.

Quoted 15 lines
Quoted 15 lines

Now Build qemu, run it as explained in the "Testing" section and try our new

hmp-commands-info.hx +1 -1
index 74446c6..19729e5 100644
@@ -18,7 +18,7 @@ ETEXI
         .args_type  = "",
         .params     = "",
         .help       = "show the version of QEMU",
-        .mhandler.cmd = hmp_info_version,
+        .cmd        = hmp_info_version,
     },
 
Quoted 4 lines
Quoted 2 lines

hmp-commands-info.hx ETEXI · line 24

Quoted 1 line
hmp-commands-info.hx +0 -0
 STEXI

[More of the same snipped...]

However those belong with this commit (I am not sure if you meant that they should also be moved)

No, I didn't mean to suggest that. They indeed belong to this commit.

#23 lore raw

PATCH v2 7/12 monitor: implement 'qmp_query_commands' without qmp_cmds

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

So we can get rid of the static qmp_cmds table.

---
 monitor.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)
monitor.c +14 -18
index 642be2e..bd41b4b 100644
@@ -229,8 +229,6 @@ static int mon_refcount;
 static mon_cmd_t mon_cmds[];
 static mon_cmd_t info_cmds[];
 
-static const mon_cmd_t qmp_cmds[];
-
 Monitor *cur_mon;
 
 static QEMUClockType event_clock_type = QEMU_CLOCK_REALTIME;
@@ -947,21 +945,24 @@ static void hmp_info_help(Monitor *mon, const QDict *qdict)
     help_cmd(mon, "info");
 }
 
-CommandInfoList *qmp_query_commands(Error **errp)
+static void query_commands_cb(QmpCommand *cmd, void *opaque)
 {
-    CommandInfoList *info, *cmd_list = NULL;
-    const mon_cmd_t *cmd;
+    CommandInfoList *info, **list = opaque;
 
-    for (cmd = qmp_cmds; cmd->name != NULL; cmd++) {
-        info = g_malloc0(sizeof(*info));
-        info->value = g_malloc0(sizeof(*info->value));
-        info->value->name = g_strdup(cmd->name);
+    info = g_malloc0(sizeof(*info));
+    info->value = g_malloc0(sizeof(*info->value));
+    info->value->name = g_strdup(cmd->name);
+    info->next = *list;
+    *list = info;
+}
 
-        info->next = cmd_list;
-        cmd_list = info;
-    }
+CommandInfoList *qmp_query_commands(Error **errp)
+{
+    CommandInfoList *list = NULL;
 
-    return cmd_list;
+    qmp_for_each_command(query_commands_cb, &list);
+
+    return list;
 }
 
 EventInfoList *qmp_query_events(Error **errp)
@@ -2166,11 +2167,6 @@ static mon_cmd_t mon_cmds[] = {
     { NULL, NULL, },
 };
 
-static const mon_cmd_t qmp_cmds[] = {
-#include "qmp-commands-old.h"
-    { /* NULL */ },
-};
-
 /*******************************************************************/
 
 static const char *pch;
Signature · 1 line
2.9.0
Reviewed-by on v2 7/12
#24 lore raw

Re: [Qemu-devel] [PATCH v2 07/12] monitor: implement 'qmp_query_commands' without qmp_cmds

Quoted 9 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

So we can get rid of the static qmp_cmds table.

---
 monitor.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#25 lore raw

Re: [Qemu-devel] [PATCH v2 07/12] monitor: implement 'qmp_query_commands' without qmp_cmds

In reply to [email protected]
Quoted 60 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

So we can get rid of the static qmp_cmds table.

---
 monitor.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)
monitor.c +14 -13
index 642be2e..bd41b4b 100644
@@ -229,8 +229,6 @@ static int mon_refcount;
 static mon_cmd_t mon_cmds[];
 static mon_cmd_t info_cmds[];
 
-static const mon_cmd_t qmp_cmds[];
-
 Monitor *cur_mon;
 
 static QEMUClockType event_clock_type = QEMU_CLOCK_REALTIME;
@@ -947,21 +945,24 @@ static void hmp_info_help(Monitor *mon, const QDict *qdict)
     help_cmd(mon, "info");
 }
 
-CommandInfoList *qmp_query_commands(Error **errp)
+static void query_commands_cb(QmpCommand *cmd, void *opaque)
 {
-    CommandInfoList *info, *cmd_list = NULL;
-    const mon_cmd_t *cmd;
+    CommandInfoList *info, **list = opaque;
 
-    for (cmd = qmp_cmds; cmd->name != NULL; cmd++) {
-        info = g_malloc0(sizeof(*info));
-        info->value = g_malloc0(sizeof(*info->value));
-        info->value->name = g_strdup(cmd->name);
+    info = g_malloc0(sizeof(*info));
+    info->value = g_malloc0(sizeof(*info->value));
+    info->value->name = g_strdup(cmd->name);
+    info->next = *list;
+    *list = info;
+}
 
-        info->next = cmd_list;
-        cmd_list = info;
-    }
+CommandInfoList *qmp_query_commands(Error **errp)
+{
+    CommandInfoList *list = NULL;
 
-    return cmd_list;
+    qmp_for_each_command(query_commands_cb, &list);
+
+    return list;
 }
 
 EventInfoList *qmp_query_events(Error **errp)
@@ -2166,11 +2167,6 @@ static mon_cmd_t mon_cmds[] = {
     { NULL, NULL, },

monitor.c static mon_cmd_t mon_cmds[] = { · line 2172

Quoted 10 lines
monitor.c +0 -5
 };
 
-static const mon_cmd_t qmp_cmds[] = {
-#include "qmp-commands-old.h"
-    { /* NULL */ },
-};
-
 /*******************************************************************/
 
 static const char *pch;

I'm afraid you'll have to rearrange things a bit:

    x86_64-softmmu/monitor.o
/work/armbru/qemu/monitor.c: In function ‘qmp_find_cmd’:
/work/armbru/qemu/monitor.c:2522:34: error: ‘qmp_cmds’ undeclared (first use in this function)
     return search_dispatch_table(qmp_cmds, cmdname);
                                  ^

/work/armbru/qemu/monitor.c:2522:34: note: each undeclared identifier is reported only once for each function it appears in /work/armbru/qemu/monitor.c:2523:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^

#26 lore raw

PATCH v2 8/12 build-sys: remove qmp-commands-old.h

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

---
 Makefile.target | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
Makefile.target +2 -5
index a440bcb..3d8572f 100644
@@ -156,7 +156,7 @@ else
 obj-y += hw/$(TARGET_BASE_ARCH)/
 endif
 
-GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h qmp-commands-old.h
+GENERATED_HEADERS += hmp-commands.h hmp-commands-info.h
 
 endif # CONFIG_SOFTMMU
 
@@ -209,13 +209,10 @@ hmp-commands.h: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
 hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
 
-qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx $(SRC_PATH)/scripts/hxtool
-	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"  GEN   $(TARGET_DIR)$@")
-
 clean:
 	rm -f *.a *~ $(PROGS)
 	rm -f $(shell find . -name '*.[od]')
-	rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
+	rm -f hmp-commands.h gdbstub-xml.c
 ifdef CONFIG_TRACE_SYSTEMTAP
 	rm -f *.stp
 endif
Signature · 1 line
2.9.0
Reviewed-by on v2 8/12
#27 lore raw

Re: [Qemu-devel] [PATCH v2 08/12] build-sys: remove qmp-commands-old.h

Quoted 7 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

---
 Makefile.target | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#28 lore raw

PATCH v2 9/12 qapi: remove the "middle" mode

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Now that the register function is always generated, we can remove the so-called "middle" mode from the generator script.

---
 scripts/qapi-commands.py | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)
scripts/qapi-commands.py +5 -24
index a06a2c4..4754ae0 100644
@@ -84,17 +84,8 @@ static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out,
 
 
 def gen_marshal_proto(name):
-    ret = 'void qmp_marshal_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
-    if not middle_mode:
-        ret = 'static ' + ret
-    return ret
-
-
-def gen_marshal_decl(name):
-    return mcgen('''
-%(proto)s;
-''',
-                 proto=gen_marshal_proto(name))
+    return 'static void qmp_marshal_%s' % c_name(name) + \
+        '(QDict *args, QObject **ret, Error **errp)'
 
 
 def gen_marshal(name, arg_type, boxed, ret_type):
@@ -209,8 +200,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
         self._visited_ret_types = set()
 
     def visit_end(self):
-        if not middle_mode:
-            self.defn += gen_registry(self._regy)
+        self.defn += gen_registry(self._regy)
         self._regy = None
         self._visited_ret_types = None
 
@@ -222,21 +212,12 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
         if ret_type and ret_type not in self._visited_ret_types:
             self._visited_ret_types.add(ret_type)
             self.defn += gen_marshal_output(ret_type)
-        if middle_mode:
-            self.decl += gen_marshal_decl(name)
         self.defn += gen_marshal(name, arg_type, boxed, ret_type)
-        if not middle_mode:
-            self._regy += gen_register_command(name, success_response)
-
+        self._regy += gen_register_command(name, success_response)
 
-middle_mode = False
 
 (input_file, output_dir, do_c, do_h, prefix, opts) = \
-    parse_command_line("m", ["middle"])
-
-for o, a in opts:
-    if o in ("-m", "--middle"):
-        middle_mode = True
+    parse_command_line()
 
 c_comment = '''
 /*
Signature · 1 line
2.9.0
#29 lore raw

Re: [Qemu-devel] [PATCH v2 09/12] qapi: remove the "middle" mode

Quoted 21 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Now that the register function is always generated, we can remove the so-called "middle" mode from the generator script.

---
 scripts/qapi-commands.py | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)
scripts/qapi-commands.py +0 -3
index a06a2c4..4754ae0 100644
@@ -84,17 +84,8 @@ static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out,
 
 
 def gen_marshal_proto(name):
-    ret = 'void qmp_marshal_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
-    if not middle_mode:
-        ret = 'static ' + ret

scripts/qapi-commands.py static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, · line 88

Quoted 10 lines
scripts/qapi-commands.py +2 -8
-    return ret
-
-
-def gen_marshal_decl(name):
-    return mcgen('''
-%(proto)s;
-''',
-                 proto=gen_marshal_proto(name))
+    return 'static void qmp_marshal_%s' % c_name(name) + \
+        '(QDict *args, QObject **ret, Error **errp)'

I'm wondering if this should be:

return mcgen('''
static void qmp_marshal_%(c_name)s(QDict *args, QObject **ret, Error **errp) ''',

                 c_name=c_name(name))

for consistency with our other code (I'm not sure why we weren't already using mcgen(), though).

Otherwise, nice to see it go!

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

Re: [Qemu-devel] [PATCH v2 09/12] qapi: remove the "middle" mode

Hi

Quoted 35 lines · Eric Blake
Quoted 21 lines · On 07/21/2016 08:00 AM, [email protected] wrote:

From: Marc-André Lureau <[email protected]>

Now that the register function is always generated, we can remove the so-called "middle" mode from the generator script.

---
 scripts/qapi-commands.py | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)
scripts/qapi-commands.py +0 -3
index a06a2c4..4754ae0 100644
@@ -84,17 +84,8 @@ static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out,
 
 
 def gen_marshal_proto(name):
-    ret = 'void qmp_marshal_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
-    if not middle_mode:
-        ret = 'static ' + ret

scripts/qapi-commands.py static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, · line 88

Quoted 10 lines
scripts/qapi-commands.py +2 -8
-    return ret
-
-
-def gen_marshal_decl(name):
-    return mcgen('''
-%(proto)s;
-''',
-                 proto=gen_marshal_proto(name))
+    return 'static void qmp_marshal_%s' % c_name(name) + \
+        '(QDict *args, QObject **ret, Error **errp)'

I'm wondering if this should be:

Quoted 7 lines

return mcgen('''
static void qmp_marshal_%(c_name)s(QDict *args, QObject **ret, Error **errp) ''',

                 c_name=c_name(name))

for consistency with our other code (I'm not sure why we weren't already using mcgen(), though).

yes, it works fine too, and we can simplify a bit the code around.

Signature · 1 line
Marc-André Lureau
#31 lore raw

Re: [Qemu-devel] [PATCH v2 09/12] qapi: remove the "middle" mode

In reply to [email protected]
Quoted 21 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Now that the register function is always generated, we can remove the so-called "middle" mode from the generator script.

---
 scripts/qapi-commands.py | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)
scripts/qapi-commands.py +0 -3
index a06a2c4..4754ae0 100644
@@ -84,17 +84,8 @@ static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out,
 
 
 def gen_marshal_proto(name):
-    ret = 'void qmp_marshal_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)
-    if not middle_mode:
-        ret = 'static ' + ret

scripts/qapi-commands.py static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, · line 88

Quoted 10 lines
scripts/qapi-commands.py +2 -8
-    return ret
-
-
-def gen_marshal_decl(name):
-    return mcgen('''
-%(proto)s;
-''',
-                 proto=gen_marshal_proto(name))
+    return 'static void qmp_marshal_%s' % c_name(name) + \
+        '(QDict *args, QObject **ret, Error **errp)'

Eric's suggestion to use mcgen() here seconded.

Quoted 27 lines
scripts/qapi-commands.py +2 -8
 def gen_marshal(name, arg_type, boxed, ret_type):
@@ -209,8 +200,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
         self._visited_ret_types = set()
 
     def visit_end(self):
-        if not middle_mode:
-            self.defn += gen_registry(self._regy)
+        self.defn += gen_registry(self._regy)
         self._regy = None
         self._visited_ret_types = None
 
@@ -222,21 +212,12 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
         if ret_type and ret_type not in self._visited_ret_types:
             self._visited_ret_types.add(ret_type)
             self.defn += gen_marshal_output(ret_type)
-        if middle_mode:
-            self.decl += gen_marshal_decl(name)
         self.defn += gen_marshal(name, arg_type, boxed, ret_type)
-        if not middle_mode:
-            self._regy += gen_register_command(name, success_response)
-
+        self._regy += gen_register_command(name, success_response)
 
-middle_mode = False
 

scripts/qapi-commands.py class QAPISchemaGenCommandVisitor(QAPISchemaVisitor): · line 223

Quoted 10 lines
scripts/qapi-commands.py +1 -5
 (input_file, output_dir, do_c, do_h, prefix, opts) = \
-    parse_command_line("m", ["middle"])
-
-for o, a in opts:
-    if o in ("-m", "--middle"):
-        middle_mode = True
+    parse_command_line()
 
 c_comment = '''
 /*

Let's get rid of the line continuation, too:

(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()

#32 lore raw

PATCH v2 10/12 monitor: use qmp_dispatch()

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Replace the old manual dispatch and validation code by the generic one provided by qapi common code.

---
 monitor.c    | 319 +++++++----------------------------------------------------
 trace-events |   1 -
 2 files changed, 34 insertions(+), 286 deletions(-)
monitor.c +34 -285
index bd41b4b..c87089f 100644
@@ -166,7 +166,6 @@ struct MonFdset {
 };
 
 typedef struct {
-    QObject *id;
     JSONMessageParser parser;
     /*
      * When a client connects, we're in capabilities negotiation mode.
@@ -399,49 +398,6 @@ static void monitor_json_emitter(Monitor *mon, const QObject *data)
     QDECREF(json);
 }
 
-static QDict *build_qmp_error_dict(Error *err)
-{
-    QObject *obj;
-
-    obj = qobject_from_jsonf("{ 'error': { 'class': %s, 'desc': %s } }",
-                             QapiErrorClass_lookup[error_get_class(err)],
-                             error_get_pretty(err));
-
-    return qobject_to_qdict(obj);
-}
-
-static void monitor_protocol_emitter(Monitor *mon, QObject *data,
-                                     Error *err)
-{
-    QDict *qmp;
-
-    trace_monitor_protocol_emitter(mon);
-
-    if (!err) {
-        /* success response */
-        qmp = qdict_new();
-        if (data) {
-            qobject_incref(data);
-            qdict_put_obj(qmp, "return", data);
-        } else {
-            /* return an empty QDict by default */
-            qdict_put(qmp, "return", qdict_new());
-        }
-    } else {
-        /* error response */
-        qmp = build_qmp_error_dict(err);
-    }
-
-    if (mon->qmp.id) {
-        qdict_put_obj(qmp, "id", mon->qmp.id);
-        mon->qmp.id = NULL;
-    }
-
-    monitor_json_emitter(mon, QOBJECT(qmp));
-    QDECREF(qmp);
-}
-
-
 static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT__MAX] = {
     /* Limit guest-triggerable events to 1 per second */
     [QAPI_EVENT_RTC_CHANGE]        = { 1000 * SCALE_MS },
@@ -2517,11 +2473,6 @@ static const mon_cmd_t *search_dispatch_table(const mon_cmd_t *disp_table,
     return NULL;
 }
 
-static const mon_cmd_t *qmp_find_cmd(const char *cmdname)
-{
-    return search_dispatch_table(qmp_cmds, cmdname);
-}
-
 /*
  * Parse command name from @cmdp according to command table @table.
  * If blank, return NULL.
@@ -3672,199 +3623,6 @@ static bool invalid_qmp_mode(const Monitor *mon, const char *cmd,
     return false;
 }
 
-/*
- * Argument validation rules:
- *
- * 1. The argument must exist in cmd_args qdict
- * 2. The argument type must be the expected one
- *
- * Special case: If the argument doesn't exist in cmd_args and
- *               the QMP_ACCEPT_UNKNOWNS flag is set, then the
- *               checking is skipped for it.
- */
-static void check_client_args_type(const QDict *client_args,
-                                   const QDict *cmd_args, int flags,
-                                   Error **errp)
-{
-    const QDictEntry *ent;
-
-    for (ent = qdict_first(client_args); ent;ent = qdict_next(client_args,ent)){
-        QObject *obj;
-        QString *arg_type;
-        const QObject *client_arg = qdict_entry_value(ent);
-        const char *client_arg_name = qdict_entry_key(ent);
-
-        obj = qdict_get(cmd_args, client_arg_name);
-        if (!obj) {
-            if (flags & QMP_ACCEPT_UNKNOWNS) {
-                /* handler accepts unknowns */
-                continue;
-            }
-            /* client arg doesn't exist */
-            error_setg(errp, QERR_INVALID_PARAMETER, client_arg_name);
-            return;
-        }
-
-        arg_type = qobject_to_qstring(obj);
-        assert(arg_type != NULL);
-
-        /* check if argument's type is correct */
-        switch (qstring_get_str(arg_type)[0]) {
-        case 'F':
-        case 'B':
-        case 's':
-            if (qobject_type(client_arg) != QTYPE_QSTRING) {
-                error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
-                           client_arg_name, "string");
-                return;
-            }
-        break;
-        case 'i':
-        case 'l':
-        case 'M':
-        case 'o':
-            if (qobject_type(client_arg) != QTYPE_QINT) {
-                error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
-                           client_arg_name, "int");
-                return;
-            }
-            break;
-        case 'T':
-            if (qobject_type(client_arg) != QTYPE_QINT &&
-                qobject_type(client_arg) != QTYPE_QFLOAT) {
-                error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
-                           client_arg_name, "number");
-                return;
-            }
-            break;
-        case 'b':
-        case '-':
-            if (qobject_type(client_arg) != QTYPE_QBOOL) {
-                error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
-                           client_arg_name, "bool");
-                return;
-            }
-            break;
-        case 'O':
-            assert(flags & QMP_ACCEPT_UNKNOWNS);
-            break;
-        case 'q':
-            /* Any QObject can be passed.  */
-            break;
-        case '/':
-        case '.':
-            /*
-             * These types are not supported by QMP and thus are not
-             * handled here. Fall through.
-             */
-        default:
-            abort();
-        }
-    }
-}
-
-/*
- * - Check if the client has passed all mandatory args
- * - Set special flags for argument validation
- */
-static void check_mandatory_args(const QDict *cmd_args,
-                                 const QDict *client_args, int *flags,
-                                 Error **errp)
-{
-    const QDictEntry *ent;
-
-    for (ent = qdict_first(cmd_args); ent; ent = qdict_next(cmd_args, ent)) {
-        const char *cmd_arg_name = qdict_entry_key(ent);
-        QString *type = qobject_to_qstring(qdict_entry_value(ent));
-        assert(type != NULL);
-
-        if (qstring_get_str(type)[0] == 'O') {
-            assert((*flags & QMP_ACCEPT_UNKNOWNS) == 0);
-            *flags |= QMP_ACCEPT_UNKNOWNS;
-        } else if (qstring_get_str(type)[0] != '-' &&
-                   qstring_get_str(type)[1] != '?' &&
-                   !qdict_haskey(client_args, cmd_arg_name)) {
-            error_setg(errp, QERR_MISSING_PARAMETER, cmd_arg_name);
-            return;
-        }
-    }
-}
-
-static QDict *qdict_from_args_type(const char *args_type)
-{
-    int i;
-    QDict *qdict;
-    QString *key, *type, *cur_qs;
-
-    assert(args_type != NULL);
-
-    qdict = qdict_new();
-
-    if (args_type == NULL || args_type[0] == '\0') {
-        /* no args, empty qdict */
-        goto out;
-    }
-
-    key = qstring_new();
-    type = qstring_new();
-
-    cur_qs = key;
-
-    for (i = 0;; i++) {
-        switch (args_type[i]) {
-            case ',':
-            case '\0':
-                qdict_put(qdict, qstring_get_str(key), type);
-                QDECREF(key);
-                if (args_type[i] == '\0') {
-                    goto out;
-                }
-                type = qstring_new(); /* qdict has ref */
-                cur_qs = key = qstring_new();
-                break;
-            case ':':
-                cur_qs = type;
-                break;
-            default:
-                qstring_append_chr(cur_qs, args_type[i]);
-                break;
-        }
-    }
-
-out:
-    return qdict;
-}
-
-/*
- * Client argument checking rules:
- *
- * 1. Client must provide all mandatory arguments
- * 2. Each argument provided by the client must be expected
- * 3. Each argument provided by the client must have the type expected
- *    by the command
- */
-static void qmp_check_client_args(const mon_cmd_t *cmd, QDict *client_args,
-                                  Error **errp)
-{
-    Error *err = NULL;
-    int flags;
-    QDict *cmd_args;
-
-    cmd_args = qdict_from_args_type(cmd->args_type);
-
-    flags = 0;
-    check_mandatory_args(cmd_args, client_args, &flags, &err);
-    if (err) {
-        goto out;
-    }
-
-    check_client_args_type(client_args, cmd_args, flags, &err);
-
-out:
-    error_propagate(errp, err);
-    QDECREF(cmd_args);
-}
-
 /*
  * Input object checking rules
  *
@@ -3923,67 +3681,58 @@ static QDict *qmp_check_input_obj(QObject *input_obj, Error **errp)
 
 static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
 {
-    Error *local_err = NULL;
-    QObject *obj, *data;
-    QDict *input, *args;
-    const mon_cmd_t *cmd;
-    QmpCommand *qcmd;
+    QObject *req, *rsp = NULL, *id = NULL;
+    QDict *qdict = NULL;
     const char *cmd_name;
     Monitor *mon = cur_mon;
+    Error *err = NULL;
 
-    args = input = NULL;
-    data = NULL;
-
-    obj = json_parser_parse(tokens, NULL);
-    if (!obj) {
-        // FIXME: should be triggered in json_parser_parse()
-        error_setg(&local_err, QERR_JSON_PARSING);
+    req = json_parser_parse_err(tokens, NULL, &err);
+    if (err || !req || qobject_type(req) != QTYPE_QDICT) {
+        if (!err) {
+            error_setg(&err, QERR_JSON_PARSING);
+        }
         goto err_out;
     }
 
-    input = qmp_check_input_obj(obj, &local_err);
-    if (!input) {
-        qobject_decref(obj);
+    qdict = qmp_check_input_obj(req, &err);
+    if (!qdict) {
         goto err_out;
     }
 
-    mon->qmp.id = qdict_get(input, "id");
-    qobject_incref(mon->qmp.id);
+    id = qdict_get(qdict, "id");
+    qobject_incref(id);
+    qdict_del(qdict, "id");
 
-    cmd_name = qdict_get_str(input, "execute");
+    cmd_name = qdict_get_str(qdict, "execute");
     trace_handle_qmp_command(mon, cmd_name);
-    cmd = qmp_find_cmd(cmd_name);
-    qcmd = qmp_find_command(cmd_name);
-    if (!qcmd || !cmd) {
-        error_set(&local_err, ERROR_CLASS_COMMAND_NOT_FOUND,
-                  "The command %s has not been found", cmd_name);
-        goto err_out;
-    }
-    if (invalid_qmp_mode(mon, cmd_name, &local_err)) {
+
+    if (invalid_qmp_mode(mon, cmd_name, &err)) {
         goto err_out;
     }
 
-    obj = qdict_get(input, "arguments");
-    if (!obj) {
-        args = qdict_new();
-    } else {
-        args = qobject_to_qdict(obj);
-        QINCREF(args);
-    }
+    rsp = qmp_dispatch(req);
 
-    qmp_check_client_args(cmd, args, &local_err);
-    if (local_err) {
-        goto err_out;
+err_out:
+    if (err) {
+        qdict = qdict_new();
+        qdict_put_obj(qdict, "error", qmp_build_error_object(err));
+        error_free(err);
+        rsp = QOBJECT(qdict);
     }
 
-    qcmd->fn(args, &data, &local_err);
+    if (rsp) {
+        if (id) {
+            qdict_put_obj(qobject_to_qdict(rsp), "id", id);
+            id = NULL;
+        }
 
-err_out:
-    monitor_protocol_emitter(mon, data, local_err);
-    qobject_decref(data);
-    error_free(local_err);
-    QDECREF(input);
-    QDECREF(args);
+        monitor_json_emitter(mon, rsp);
+    }
+
+    qobject_decref(id);
+    qobject_decref(rsp);
+    qobject_decref(req);
 }
 
 static void monitor_qmp_read(void *opaque, const uint8_t *buf, int size)
trace-events +0 -1
index 4767059..b358e09 100644
@@ -97,7 +97,6 @@ qemu_co_mutex_unlock_return(void *mutex, void *self) "mutex %p self %p"
 
 # monitor.c
 handle_qmp_command(void *mon, const char *cmd_name) "mon %p cmd_name \"%s\""
-monitor_protocol_emitter(void *mon) "mon %p"
 monitor_protocol_event_handler(uint32_t event, void *qdict) "event=%d data=%p"
 monitor_protocol_event_emit(uint32_t event, void *data) "event=%d data=%p"
 monitor_protocol_event_queue(uint32_t event, void *qdict, uint64_t rate) "event=%d data=%p rate=%" PRId64
Signature · 1 line
2.9.0
#33 lore raw

Re: [Qemu-devel] [PATCH v2 10/12] monitor: use qmp_dispatch()

Quoted 10 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Replace the old manual dispatch and validation code by the generic one provided by qapi common code.

---
 monitor.c    | 319 +++++++----------------------------------------------------
 trace-events |   1 -
 2 files changed, 34 insertions(+), 286 deletions(-)

All right, this is where it gets interesting: you replace a whole bunch of code by other code we have anyway. Excellent. Only we need to convince ourselves the replacement is functionally equivalent. Before I dive into that, what have you done to convince yourself?

#34 lore raw

PATCH v2 11/12 qmp: update qmp_query_spice fallback

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

There are a few commands that are undef #ifdef conditions in qmp-commands.hx. Move all the qmp_query_spice fallback in the same location, return an error and update the comment.

---
 monitor.c | 14 ++++++++++++++
 qmp.c     | 16 ----------------
 2 files changed, 14 insertions(+), 16 deletions(-)
monitor.c +14 -0
index c87089f..46966d5 100644
@@ -4048,6 +4048,20 @@ QemuOptsList qemu_mon_opts = {
     },
 };
 
+/*
+ * the QAPI schema is blissfully unaware #ifdef FOO commands, and the
+ * QAPI code generator happily generates a dead qmp_marshal_foo_cmd()
+ * that calls qmp_foo_cmd().  Provide it one, or else linking fails.
+ * FIXME Educate the QAPI schema on #ifdef commands.
+ */
+#ifndef CONFIG_SPICE
+SpiceInfo *qmp_query_spice(Error **errp)
+{
+    error_setg(errp, QERR_FEATURE_DISABLED, "spice");
+    return NULL;
+};
+#endif
+
 #ifndef TARGET_I386
 void qmp_rtc_reset_reinjection(Error **errp)
 {
qmp.c +0 -16
index b6d531e..884d1ab 100644
@@ -161,22 +161,6 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
 };
 #endif
 
-#ifndef CONFIG_SPICE
-/*
- * qmp-commands.hx ensures that QMP command query-spice exists only
- * #ifdef CONFIG_SPICE.  Necessary for an accurate query-commands
- * result.  However, the QAPI schema is blissfully unaware of that,
- * and the QAPI code generator happily generates a dead
- * qmp_marshal_query_spice() that calls qmp_query_spice().  Provide it
- * one, or else linking fails.  FIXME Educate the QAPI schema on
- * CONFIG_SPICE.
- */
-SpiceInfo *qmp_query_spice(Error **errp)
-{
-    abort();
-};
-#endif
-
 void qmp_cont(Error **errp)
 {
     Error *local_err = NULL;
Signature · 1 line
2.9.0
#35 lore raw

Re: [Qemu-devel] [PATCH v2 11/12] qmp: update qmp_query_spice fallback

Quoted 3 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

There are a few commands that are undef #ifdef conditions in

under #ifdef

Quoted 18 lines

qmp-commands.hx. Move all the qmp_query_spice fallback in the same location, return an error and update the comment.

---
 monitor.c | 14 ++++++++++++++
 qmp.c     | 16 ----------------
 2 files changed, 14 insertions(+), 16 deletions(-)
monitor.c +1 -0
index c87089f..46966d5 100644
@@ -4048,6 +4048,20 @@ QemuOptsList qemu_mon_opts = {
     },
 };
 
+/*

monitor.c QemuOptsList qemu_mon_opts = { · line 4061

Quoted 10 lines
monitor.c +10 -0
+ * the QAPI schema is blissfully unaware #ifdef FOO commands, and the
+ * QAPI code generator happily generates a dead qmp_marshal_foo_cmd()
+ * that calls qmp_foo_cmd().  Provide it one, or else linking fails.
+ * FIXME Educate the QAPI schema on #ifdef commands.
+ */
+#ifndef CONFIG_SPICE
+SpiceInfo *qmp_query_spice(Error **errp)
+{
+    error_setg(errp, QERR_FEATURE_DISABLED, "spice");
+    return NULL;

Why do you change from abort() to error_setg()?

Quoted 33 lines
monitor.c +3 -0
+};
+#endif
+
 #ifndef TARGET_I386
 void qmp_rtc_reset_reinjection(Error **errp)
 {
qmp.c +0 -16
index b6d531e..884d1ab 100644
@@ -161,22 +161,6 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
 };
 #endif
 
-#ifndef CONFIG_SPICE
-/*
- * qmp-commands.hx ensures that QMP command query-spice exists only
- * #ifdef CONFIG_SPICE.  Necessary for an accurate query-commands
- * result.  However, the QAPI schema is blissfully unaware of that,
- * and the QAPI code generator happily generates a dead
- * qmp_marshal_query_spice() that calls qmp_query_spice().  Provide it
- * one, or else linking fails.  FIXME Educate the QAPI schema on
- * CONFIG_SPICE.
- */
-SpiceInfo *qmp_query_spice(Error **errp)
-{
-    abort();
-};
-#endif
-
 void qmp_cont(Error **errp)
 {
     Error *local_err = NULL;
#36 lore raw

Re: [Qemu-devel] [PATCH v2 11/12] qmp: update qmp_query_spice fallback

----- Original Message -----

Quoted 25 lines
Quoted 3 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

There are a few commands that are undef #ifdef conditions in

under #ifdef

Quoted 17 lines

qmp-commands.hx. Move all the qmp_query_spice fallback in the same location, return an error and update the comment.

---
 monitor.c | 14 ++++++++++++++
 qmp.c     | 16 ----------------
 2 files changed, 14 insertions(+), 16 deletions(-)
monitor.c +0 -0
index c87089f..46966d5 100644
@@ -4048,6 +4048,20 @@ QemuOptsList qemu_mon_opts = {
     },
 };
 
Quoted 13 lines

monitor.c QemuOptsList qemu_mon_opts = { · line 4061

Quoted 11 lines
monitor.c +11 -0
+/*
+ * the QAPI schema is blissfully unaware #ifdef FOO commands, and the
+ * QAPI code generator happily generates a dead qmp_marshal_foo_cmd()
+ * that calls qmp_foo_cmd().  Provide it one, or else linking fails.
+ * FIXME Educate the QAPI schema on #ifdef commands.
+ */
+#ifndef CONFIG_SPICE
+SpiceInfo *qmp_query_spice(Error **errp)
+{
+    error_setg(errp, QERR_FEATURE_DISABLED, "spice");
+    return NULL;

Why do you change from abort() to error_setg()?

The rest of the commands do not abort. It sounds to easy to trigger, and it's quite harmless to return an error instead.

Quoted 34 lines
Quoted 33 lines
monitor.c +3 -0
+};
+#endif
+
 #ifndef TARGET_I386
 void qmp_rtc_reset_reinjection(Error **errp)
 {
qmp.c +0 -16
index b6d531e..884d1ab 100644
@@ -161,22 +161,6 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
 };
 #endif
 
-#ifndef CONFIG_SPICE
-/*
- * qmp-commands.hx ensures that QMP command query-spice exists only
- * #ifdef CONFIG_SPICE.  Necessary for an accurate query-commands
- * result.  However, the QAPI schema is blissfully unaware of that,
- * and the QAPI code generator happily generates a dead
- * qmp_marshal_query_spice() that calls qmp_query_spice().  Provide it
- * one, or else linking fails.  FIXME Educate the QAPI schema on
- * CONFIG_SPICE.
- */
-SpiceInfo *qmp_query_spice(Error **errp)
-{
-    abort();
-};
-#endif
-
 void qmp_cont(Error **errp)
 {
     Error *local_err = NULL;
#37 lore raw

Re: [Qemu-devel] [PATCH v2 11/12] qmp: update qmp_query_spice fallback

Quoted 40 lines · Marc-André Lureau

----- Original Message -----

Quoted 25 lines
Quoted 3 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

There are a few commands that are undef #ifdef conditions in

under #ifdef

Quoted 17 lines

qmp-commands.hx. Move all the qmp_query_spice fallback in the same location, return an error and update the comment.

---
 monitor.c | 14 ++++++++++++++
 qmp.c     | 16 ----------------
 2 files changed, 14 insertions(+), 16 deletions(-)
monitor.c +0 -0
index c87089f..46966d5 100644
@@ -4048,6 +4048,20 @@ QemuOptsList qemu_mon_opts = {
     },
 };
 
Quoted 13 lines

monitor.c QemuOptsList qemu_mon_opts = { · line 4061

Quoted 11 lines
monitor.c +11 -0
+/*
+ * the QAPI schema is blissfully unaware #ifdef FOO commands, and the
+ * QAPI code generator happily generates a dead qmp_marshal_foo_cmd()
+ * that calls qmp_foo_cmd().  Provide it one, or else linking fails.
+ * FIXME Educate the QAPI schema on #ifdef commands.
+ */
+#ifndef CONFIG_SPICE
+SpiceInfo *qmp_query_spice(Error **errp)
+{
+    error_setg(errp, QERR_FEATURE_DISABLED, "spice");
+    return NULL;

Why do you change from abort() to error_setg()?

Quoted 1 line

The rest of the commands do not abort. It sounds to easy to trigger, and it's quite harmless to return an error instead.

If you can trigger it, the comment is wrong to claim "dead".

Can you trigger it before your series? If not, which commit makes it triggerable?

[...]

#38 lore raw

PATCH v2 12/12 Drop qmp-commands.hx

In reply to [email protected]

From: Marc-André Lureau <[email protected]>

Only the documentation remains useful, so strip it. (a later update will move the documentation in the respective json files and generate the text file)

---
 .gitignore                          |    1 -
 MAINTAINERS                         |    2 +-
 Makefile                            |    3 -
 docs/qapi-code-gen.txt              |    6 +-
 docs/writing-qmp-commands.txt       |   38 --
 qmp-commands.hx => qmp-commands.txt | 1113 +----------------------------------
 6 files changed, 7 insertions(+), 1156 deletions(-)
 rename qmp-commands.hx => qmp-commands.txt (87%)
.gitignore +0 -1
index 88ec249..0ab8263 100644
@@ -53,7 +53,6 @@
 /qemu-bridge-helper
 /qemu-monitor.texi
 /qemu-monitor-info.texi
-/qmp-commands.txt
 /vscclient
 /fsdev/virtfs-proxy-helper
 *.[1-9]
MAINTAINERS +1 -1
index d1439a8..ff52548 100644
@@ -1238,7 +1238,7 @@ M: Markus Armbruster <[email protected]>
 S: Supported
 F: qmp.c
 F: monitor.c
-F: qmp-commands.hx
+F: qmp-commands.txt
 F: docs/*qmp-*
 F: scripts/qmp/
 T: git git://repo.or.cz/qemu/armbru.git qapi-next
Makefile +0 -3
index fcdc192..8ec1c3e 100644
@@ -554,9 +554,6 @@ qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
 qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
 
-qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx $(SRC_PATH)/scripts/hxtool
-	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@,"  GEN   $@")
-
 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
 
docs/qapi-code-gen.txt +3 -3
index de298dc..5d4c2cd 100644
@@ -964,9 +964,9 @@ Example:
 
 Used to generate the marshaling/dispatch functions for the commands
 defined in the schema. The generated code implements
-qmp_marshal_COMMAND() (mentioned in qmp-commands.hx, and registered
-automatically), and declares qmp_COMMAND() that the user must
-implement.  The following files are generated:
+qmp_marshal_COMMAND() (registered automatically), and declares
+qmp_COMMAND() that the user must implement.  The following files are
+generated:
 
 $(prefix)qmp-marshal.c: command marshal/dispatch functions for each
                         QMP command defined in the schema. Functions
docs/writing-qmp-commands.txt +0 -38
index 6208715..cfa6fe7 100644
@@ -119,16 +119,6 @@ There are a few things to be noticed:
 5. Printing to the terminal is discouraged for QMP commands, we do it here
    because it's the easiest way to demonstrate a QMP command
 
-Now a little hack is needed. As we're still using the old QMP server we need
-to add the new command to its internal dispatch table. This step won't be
-required in the near future. Open the qmp-commands.hx file and add the
-following at the bottom:
-
-    {
-        .name       = "hello-world",
-        .args_type  = "",
-    },
-
 You're done. Now build qemu, run it as suggested in the "Testing" section,
 and then type the following QMP command:
 
@@ -173,20 +163,6 @@ There are two important details to be noticed:
 2. The C implementation signature must follow the schema's argument ordering,
    which is defined by the "data" member
 
-The last step is to update the qmp-commands.hx file:
-
-    {
-        .name       = "hello-world",
-        .args_type  = "message:s?",
-    },
-
-Notice that the "args_type" member got our "message" argument. The character
-"s" stands for "string" and "?" means it's optional. This too must be ordered
-according to the C implementation and schema file. You can look for more
-examples in the qmp-commands.hx file if you need to define more arguments.
-
-Again, this step won't be required in the future.
-
 Time to test our new version of the "hello-world" command. Build qemu, run it as
 described in the "Testing" section and then send two commands:
 
@@ -452,13 +428,6 @@ There are a number of things to be noticed:
 6. You have to include the "qmp-commands.h" header file in qemu-timer.c,
    otherwise qemu won't build
 
-The last step is to add the correspoding entry in the qmp-commands.hx file:
-
-    {
-        .name       = "query-alarm-clock",
-        .args_type  = "",
-    },
-
 Time to test the new command. Build qemu, run it as described in the "Testing"
 section and try this:
 
@@ -597,13 +566,6 @@ iteration of the loop. That's because the alarm timer method in use is the
 first element of the alarm_timers array. Also notice that QAPI lists are handled
 by hand and we return the head of the list.
 
-To test this you have to add the corresponding qmp-commands.hx entry:
-
-    {
-        .name       = "query-alarm-methods",
-        .args_type  = "",
-    },
-
 Now Build qemu, run it as explained in the "Testing" section and try our new
 command:
 
qmp-commands.txt renamed from qmp-commands.hx +3 -1110

1,859 lines not on this page · raw message

Signature · 1 line
2.9.0
#39 lore raw

Re: [Qemu-devel] [PATCH v2 12/12] Drop qmp-commands.hx

Quoted 3 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Only the documentation remains useful, so strip it.

What about:

The only remaining function of qmp-commands.hx is to let us generate qmp-commands.txt from it. Replace qmp-commands.hx by qmp-commands.txt.

Assuming that's what you do. Is it?

Quoted 3 lines

(a later update will
move the documentation in the respective json files and generate the text file)

Suggest "again generate".

Quoted 55 lines
---
 .gitignore                          |    1 -
 MAINTAINERS                         |    2 +-
 Makefile                            |    3 -
 docs/qapi-code-gen.txt              |    6 +-
 docs/writing-qmp-commands.txt       |   38 --
 qmp-commands.hx => qmp-commands.txt | 1113 +----------------------------------
 6 files changed, 7 insertions(+), 1156 deletions(-)
 rename qmp-commands.hx => qmp-commands.txt (87%)
.gitignore +0 -1
index 88ec249..0ab8263 100644
@@ -53,7 +53,6 @@
 /qemu-bridge-helper
 /qemu-monitor.texi
 /qemu-monitor-info.texi
-/qmp-commands.txt
 /vscclient
 /fsdev/virtfs-proxy-helper
 *.[1-9]
MAINTAINERS +1 -1
index d1439a8..ff52548 100644
@@ -1238,7 +1238,7 @@ M: Markus Armbruster <[email protected]>
 S: Supported
 F: qmp.c
 F: monitor.c
-F: qmp-commands.hx
+F: qmp-commands.txt
 F: docs/*qmp-*
 F: scripts/qmp/
 T: git git://repo.or.cz/qemu/armbru.git qapi-next
Makefile +0 -3
index fcdc192..8ec1c3e 100644
@@ -554,9 +554,6 @@ qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
 qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
 
-qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx $(SRC_PATH)/scripts/hxtool
-	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@,"  GEN   $@")
-
 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
 
docs/qapi-code-gen.txt +0 -0
index de298dc..5d4c2cd 100644

docs/qapi-code-gen.txt Example: · line 969

Quoted 9 lines
docs/qapi-code-gen.txt +3 -3
@@ -964,9 +964,9 @@ Example:
 
 Used to generate the marshaling/dispatch functions for the commands
 defined in the schema. The generated code implements
-qmp_marshal_COMMAND() (mentioned in qmp-commands.hx, and registered
-automatically), and declares qmp_COMMAND() that the user must
-implement.  The following files are generated:
+qmp_marshal_COMMAND() (registered automatically), and declares
+qmp_COMMAND() that the user must implement.  The following files are
+generated:

I see you're thorough :)

Quoted 8 lines
docs/qapi-code-gen.txt +0 -0
 $(prefix)qmp-marshal.c: command marshal/dispatch functions for each
                         QMP command defined in the schema. Functions
docs/writing-qmp-commands.txt +0 -0
index 6208715..cfa6fe7 100644

docs/writing-qmp-commands.txt There are a few things to be noticed: · line 124

Quoted 6 lines
docs/writing-qmp-commands.txt +0 -3
@@ -119,16 +119,6 @@ There are a few things to be noticed:
 5. Printing to the terminal is discouraged for QMP commands, we do it here
    because it's the easiest way to demonstrate a QMP command
 
-Now a little hack is needed. As we're still using the old QMP server we need
-to add the new command to its internal dispatch table. This step won't be
-required in the near future. Open the qmp-commands.hx file and add the

For a value of "near": almost five years!

qmp-commands.txt

Quoted 63 lines
docs/writing-qmp-commands.txt +0 -35
-following at the bottom:
-
-    {
-        .name       = "hello-world",
-        .args_type  = "",
-    },
-
 You're done. Now build qemu, run it as suggested in the "Testing" section,
 and then type the following QMP command:
 
@@ -173,20 +163,6 @@ There are two important details to be noticed:
 2. The C implementation signature must follow the schema's argument ordering,
    which is defined by the "data" member
 
-The last step is to update the qmp-commands.hx file:
-
-    {
-        .name       = "hello-world",
-        .args_type  = "message:s?",
-    },
-
-Notice that the "args_type" member got our "message" argument. The character
-"s" stands for "string" and "?" means it's optional. This too must be ordered
-according to the C implementation and schema file. You can look for more
-examples in the qmp-commands.hx file if you need to define more arguments.
-
-Again, this step won't be required in the future.
-
 Time to test our new version of the "hello-world" command. Build qemu, run it as
 described in the "Testing" section and then send two commands:
 
@@ -452,13 +428,6 @@ There are a number of things to be noticed:
 6. You have to include the "qmp-commands.h" header file in qemu-timer.c,
    otherwise qemu won't build
 
-The last step is to add the correspoding entry in the qmp-commands.hx file:
-
-    {
-        .name       = "query-alarm-clock",
-        .args_type  = "",
-    },
-
 Time to test the new command. Build qemu, run it as described in the "Testing"
 section and try this:
 
@@ -597,13 +566,6 @@ iteration of the loop. That's because the alarm timer method in use is the
 first element of the alarm_timers array. Also notice that QAPI lists are handled
 by hand and we return the head of the list.
 
-To test this you have to add the corresponding qmp-commands.hx entry:
-
-    {
-        .name       = "query-alarm-methods",
-        .args_type  = "",
-    },
-
 Now Build qemu, run it as explained in the "Testing" section and try our new
 command:
 
qmp-commands.txt renamed from qmp-commands.hx +0 -0
similarity index 87%
rename from qmp-commands.hx
rename to qmp-commands.txt

Shouldn't qmp-commands.txt live in docs/?

qmp-commands.txt

Quoted 4 lines

index 1ad8dda..f796342 100644

qmp-commands.txt renamed from qmp-commands.hx +0 -0
@@ -1,8 +1,3 @@

Instead of reviewing this diff, let me review how your patch changes qmp-commands.txt:

diff -u bld-x86/qmp-commands.txt qmp-commands.txt
--- bld-x86/qmp-commands.txt 2016-08-05 16:51:04.854000570 +0200
+++ qmp-commands.txt 2016-08-05 16:54:23.650093974 +0200
@@ -3381,7 +3381,7 @@

                       "child": "children.1" } }

<- { "return": {} }

-@query-named-block-nodes
+query-named-block-nodes
------------------------

Return a list of BlockDeviceInfo for all the named block driver nodes
@@ -3507,7 +3507,7 @@

        ]
      }

-@query-memory-devices
+query-memory-devices
--------------------

Return a list of memory devices.
@@ -3525,7 +3525,8 @@

                           "slot": 0},
                      "type": "dimm"
                    } ] }

-@query-acpi-ospm-status
+
+query-acpi-ospm-status
--------------------

Return list of ACPIOSTInfo for devices that support status reporting
@@ -3538,6 +3539,7 @@

                    { "slot": "2", "slot-type": "DIMM", "source": 0, "status": 0},
                    { "slot": "3", "slot-type": "DIMM", "source": 0, "status": 0}
      ]}

+
rtc-reset-reinjection
---------------------

@@ -3549,6 +3551,7 @@

-> { "execute": "rtc-reset-reinjection" }
<- { "return": {} }
+
trace-event-get-state
---------------------

@@ -3572,6 +3575,7 @@

-> { "execute": "trace-event-get-state", "arguments": { "name": "qemu_memalign" } } <- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] }
+
trace-event-set-state
---------------------

Sensible fixes only. Separate patch?

#40 lore raw

Re: [Qemu-devel] [PATCH v2 12/12] Drop qmp-commands.hx

Hi

Quoted 182 lines · Markus Armbruster
Quoted 3 lines · [email protected] writes:

From: Marc-André Lureau <[email protected]>

Only the documentation remains useful, so strip it.

What about:

The only remaining function of qmp-commands.hx is to let us generate qmp-commands.txt from it. Replace qmp-commands.hx by qmp-commands.txt.

Assuming that's what you do. Is it?

Quoted 3 lines

(a later update will
move the documentation in the respective json files and generate the text file)

Suggest "again generate".

Quoted 8 lines
---
 .gitignore                          |    1 -
 MAINTAINERS                         |    2 +-
 Makefile                            |    3 -
 docs/qapi-code-gen.txt              |    6 +-
 docs/writing-qmp-commands.txt       |   38 --
 qmp-commands.hx => qmp-commands.txt | 1113
+----------------------------------
>  6 files changed, 7 insertions(+), 1156 deletions(-)
>  rename qmp-commands.hx => qmp-commands.txt (87%)

Makefile qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx

Quoted 31 lines
.gitignore +0 -1
index 88ec249..0ab8263 100644
@@ -53,7 +53,6 @@
 /qemu-bridge-helper
 /qemu-monitor.texi
 /qemu-monitor-info.texi
-/qmp-commands.txt
 /vscclient
 /fsdev/virtfs-proxy-helper
 *.[1-9]
MAINTAINERS +1 -1
index d1439a8..ff52548 100644
@@ -1238,7 +1238,7 @@ M: Markus Armbruster <[email protected]>
 S: Supported
 F: qmp.c
 F: monitor.c
-F: qmp-commands.hx
+F: qmp-commands.txt
 F: docs/*qmp-*
 F: scripts/qmp/
 T: git git://repo.or.cz/qemu/armbru.git qapi-next
Makefile +0 -0
index fcdc192..8ec1c3e 100644
@@ -554,9 +554,6 @@ qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx

$(SRC_PATH)/scripts/hxtool

Makefile qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx · line 554

Quoted 1 line
Makefile +0 -0
 qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx

$(SRC_PATH)/scripts/hxtool

Makefile qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx · line 555

Quoted 1 line
Makefile +0 -0
      $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"

GEN $@")

Makefile qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx · line 557

Quoted 3 lines
Makefile +0 -2
-qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx $(SRC_PATH)/scripts/hxtool
-     $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -q < $< > $@,"

GEN $@")

Makefile qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx · line 556

Quoted 2 lines
Makefile +0 -1
-
 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx

$(SRC_PATH)/scripts/hxtool

Makefile qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx · line 557

Quoted 1 line
Makefile +0 -0
      $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"

GEN $@")

Quoted 6 lines
docs/qapi-code-gen.txt +0 -0
index de298dc..5d4c2cd 100644

docs/qapi-code-gen.txt Example: · line 969

Quoted 9 lines
docs/qapi-code-gen.txt +3 -3
@@ -964,9 +964,9 @@ Example:
 
 Used to generate the marshaling/dispatch functions for the commands
 defined in the schema. The generated code implements
-qmp_marshal_COMMAND() (mentioned in qmp-commands.hx, and registered
-automatically), and declares qmp_COMMAND() that the user must
-implement.  The following files are generated:
+qmp_marshal_COMMAND() (registered automatically), and declares
+qmp_COMMAND() that the user must implement.  The following files are
+generated:

I see you're thorough :)

Review

Quoted 4 lines
docs/qapi-code-gen.txt +0 -0
 $(prefix)qmp-marshal.c: command marshal/dispatch functions for each
                         QMP command defined in the schema. Functions
(quoted diff) +0 -0

b/docs/writing-qmp-commands.txt

docs/writing-qmp-commands.txt There are a few things to be noticed: · line 119

Quoted 5 lines

index 6208715..cfa6fe7 100644

docs/writing-qmp-commands.txt +0 -0
@@ -119,16 +119,6 @@ There are a few things to be noticed:
 5. Printing to the terminal is discouraged for QMP commands, we do it

here

docs/writing-qmp-commands.txt There are a few things to be noticed:

Quoted 3 lines
docs/writing-qmp-commands.txt +0 -1
    because it's the easiest way to demonstrate a QMP command
 
-Now a little hack is needed. As we're still using the old QMP server we

need

docs/writing-qmp-commands.txt There are a few things to be noticed: · line 123

Quoted 1 line
docs/writing-qmp-commands.txt +0 -1
-to add the new command to its internal dispatch table. This step won't

be

docs/writing-qmp-commands.txt There are a few things to be noticed: · line 124

Quoted 1 line
docs/writing-qmp-commands.txt +0 -1
-required in the near future. Open the qmp-commands.hx file and add the

For a value of "near": almost five years!

docs/writing-qmp-commands.txt There are a few things to be noticed:

Quoted 8 lines
docs/writing-qmp-commands.txt +0 -7
-following at the bottom:
-
-    {
-        .name       = "hello-world",
-        .args_type  = "",
-    },
-
 You're done. Now build qemu, run it as suggested in the "Testing"

section,

docs/writing-qmp-commands.txt There are two important details to be noticed: · line 163

Quoted 4 lines
docs/writing-qmp-commands.txt +0 -0
 and then type the following QMP command:
 
@@ -173,20 +163,6 @@ There are two important details to be noticed:
 2. The C implementation signature must follow the schema's argument

ordering,

docs/writing-qmp-commands.txt There are two important details to be noticed:

Quoted 10 lines
docs/writing-qmp-commands.txt +0 -8
    which is defined by the "data" member
 
-The last step is to update the qmp-commands.hx file:
-
-    {
-        .name       = "hello-world",
-        .args_type  = "message:s?",
-    },
-
-Notice that the "args_type" member got our "message" argument. The

character

docs/writing-qmp-commands.txt There are two important details to be noticed: · line 184

Quoted 1 line
docs/writing-qmp-commands.txt +0 -1
-"s" stands for "string" and "?" means it's optional. This too must be

ordered

docs/writing-qmp-commands.txt There are two important details to be noticed: · line 186

Quoted 2 lines
docs/writing-qmp-commands.txt +0 -2
-according to the C implementation and schema file. You can look for more
-examples in the qmp-commands.hx file if you need to define more

arguments.

docs/writing-qmp-commands.txt There are two important details to be noticed:

Quoted 4 lines
docs/writing-qmp-commands.txt +0 -3
-
-Again, this step won't be required in the future.
-
 Time to test our new version of the "hello-world" command. Build qemu,

run it as

docs/writing-qmp-commands.txt There are a number of things to be noticed: · line 455

Quoted 7 lines
docs/writing-qmp-commands.txt +0 -1
 described in the "Testing" section and then send two commands:
 
@@ -452,13 +428,6 @@ There are a number of things to be noticed:
 6. You have to include the "qmp-commands.h" header file in qemu-timer.c,
    otherwise qemu won't build
 
-The last step is to add the correspoding entry in the qmp-commands.hx

file:

docs/writing-qmp-commands.txt There are a number of things to be noticed:

Quoted 7 lines
docs/writing-qmp-commands.txt +0 -6
-
-    {
-        .name       = "query-alarm-clock",
-        .args_type  = "",
-    },
-
 Time to test the new command. Build qemu, run it as described in the

"Testing"

docs/writing-qmp-commands.txt iteration of the loop. That's because the alarm

Quoted 3 lines
docs/writing-qmp-commands.txt +0 -0
 section and try this:
 
@@ -597,13 +566,6 @@ iteration of the loop. That's because the alarm

timer method in use is the

docs/writing-qmp-commands.txt iteration of the loop. That's because the alarm · line 566

Quoted 1 line
docs/writing-qmp-commands.txt +0 -0
 first element of the alarm_timers array. Also notice that QAPI lists

are handled

docs/writing-qmp-commands.txt iteration of the loop. That's because the alarm timer method in use is the

Quoted 10 lines
docs/writing-qmp-commands.txt +0 -7
 by hand and we return the head of the list.
 
-To test this you have to add the corresponding qmp-commands.hx entry:
-
-    {
-        .name       = "query-alarm-methods",
-        .args_type  = "",
-    },
-
 Now Build qemu, run it as explained in the "Testing" section and try

our new

Quoted 10 lines

qmp-commands.txt

Quoted 6 lines
docs/writing-qmp-commands.txt +0 -0
 command:
 
qmp-commands.txt renamed from qmp-commands.hx +0 -0
similarity index 87%
rename from qmp-commands.hx
rename to qmp-commands.txt

Shouldn't qmp-commands.txt live in docs/?

I don't mind. The following patches will generate the file. It could also generate it under docs/. But then other documentation should also be generated there. Let's leave itfor a different time.

Quoted 59 lines

index 1ad8dda..f796342 100644

qmp-commands.txt

Quoted 3 lines
qmp-commands.txt renamed from qmp-commands.hx +0 -0
@@ -1,8 +1,3 @@

Instead of reviewing this diff, let me review how your patch changes qmp-commands.txt:

diff -u bld-x86/qmp-commands.txt qmp-commands.txt
--- bld-x86/qmp-commands.txt 2016-08-05 16:51:04.854000570 +0200 +++ qmp-commands.txt 2016-08-05 16:54:23.650093974 +0200 @@ -3381,7 +3381,7 @@

                       "child": "children.1" } }

<- { "return": {} }

-@query-named-block-nodes
+query-named-block-nodes
------------------------

Return a list of BlockDeviceInfo for all the named block driver nodes
@@ -3507,7 +3507,7 @@

        ]
      }

-@query-memory-devices
+query-memory-devices
--------------------

Return a list of memory devices.
@@ -3525,7 +3525,8 @@

                           "slot": 0},
                      "type": "dimm"
                    } ] }

-@query-acpi-ospm-status
+
+query-acpi-ospm-status
--------------------

Return list of ACPIOSTInfo for devices that support status reporting
@@ -3538,6 +3539,7 @@

                    { "slot": "2", "slot-type": "DIMM", "source": 0,
"status": 0},
                    { "slot": "3", "slot-type": "DIMM", "source": 0,
"status": 0}
      ]}

+
rtc-reset-reinjection
---------------------

@@ -3549,6 +3551,7 @@

   -> { "execute": "rtc-reset-reinjection" }
   <- { "return": {} }

+
trace-event-get-state
---------------------

@@ -3572,6 +3575,7 @@

Quoted 9 lines
   -> { "execute": "trace-event-get-state", "arguments": { "name":

"qemu_memalign" } }
<- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] }
+
trace-event-set-state
---------------------

Sensible fixes only. Separate patch?

ok

Signature · 1 line
Marc-André Lureau
#41 lore raw

Re: [Qemu-devel] [PATCH v2 12/12] Drop qmp-commands.hx

Quoted 6 lines · Marc-André Lureau

Hi

Quoted 2 lines · Markus Armbruster

[email protected] writes:

[...]

Quoted 11 lines
Quoted 8 lines

qmp-commands.txt

Quoted 4 lines
qmp-commands.txt renamed from qmp-commands.hx +0 -0
similarity index 87%
rename from qmp-commands.hx
rename to qmp-commands.txt

Shouldn't qmp-commands.txt live in docs/?

I don't mind. The following patches will generate the file. It could also generate it under docs/. But then other documentation should also be generated there. Let's leave itfor a different time.

What other documentation is generated into the root of the build tree?

[...]

#42 lore raw

Re: [Qemu-devel] [PATCH v2 12/12] Drop qmp-commands.hx

Hi

Quoted 8 lines · Markus Armbruster
Quoted 4 lines

I don't mind. The following patches will generate the file. It could also generate it under docs/. But then other documentation should also be generated there. Let's leave itfor a different time.

What other documentation is generated into the root of the build tree?

Look at the Makefile distclean rule, most of the files are generated documentation.

Signature · 1 line
Marc-André Lureau
#43 lore raw

Re: [Qemu-devel] [PATCH v2 12/12] Drop qmp-commands.hx

Quoted 9 lines · Marc-André Lureau

Hi

Quoted 5 lines · Markus Armbruster
Quoted 4 lines

I don't mind. The following patches will generate the file. It could also generate it under docs/. But then other documentation should also be generated there. Let's leave itfor a different time.

Quoted 5 lines
Quoted 3 lines

What other documentation is generated into the root of the build tree?

Look at the Makefile distclean rule, most of the files are generated documentation.

Mostly the user manual (qemu-doc.texi & friends), and the (rather moribund) qemu-tech.texi. I guess they're in the root only due to inertia.

I'd prefer to move (and later generate) qmp-commands.txt to docs/.