diff mbox

[14/36] monitor: remove usage of generated marshal functions

Message ID 1443189844-20341-15-git-send-email-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Sept. 25, 2015, 2:03 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

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

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 monitor.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index 7e8ad0c..410c3a5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -76,6 +76,7 @@ 
 #include "qapi-event.h"
 #include "qmp-introspect.h"
 #include "sysemu/block-backend.h"
+#include "qapi/qmp/dispatch.h"
 
 /* for hmp_info_irq/pic */
 #if defined(TARGET_SPARC)
@@ -3536,21 +3537,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 gchar *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;
@@ -3841,7 +3842,7 @@  static void handle_qmp_command(JSONMessageParser *parser, QList *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;
     }
 
@@ -3926,9 +3927,13 @@  void monitor_resume(Monitor *mon)
 
 static QObject *get_qmp_greeting(void)
 {
+    QmpCommand *cmd;
     QObject *ver = NULL;
 
-    qmp_marshal_query_version(NULL, &ver, NULL);
+    cmd = qmp_find_command("query-version");
+    assert(cmd && cmd->fn);
+    cmd->fn(NULL, &ver, NULL);
+
     return qobject_from_jsonf("{'QMP':{'version': %p,'capabilities': []}}",ver);
 }