Patchwork [18/18] QMP: Introduce qmp_call_cmd()

login
register
mail settings
Submitter Luiz Capitulino
Date Sept. 16, 2010, 8:21 p.m.
Message ID <1284668464-15981-19-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/65007/
State New
Headers show

Comments

Luiz Capitulino - Sept. 16, 2010, 8:21 p.m.
Calls a QObject handler and emits the QMP response, also drops
monitor_call_handler() which is now unused.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c |   39 +++++++++++++++------------------------
 1 files changed, 15 insertions(+), 24 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index c332e06..1da65ab 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3877,29 +3877,6 @@  static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
     }
 }
 
-static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
-                                 const QDict *params)
-{
-    int ret;
-    QObject *data = NULL;
-
-    mon_print_count_init(mon);
-
-    ret = cmd->mhandler.cmd_new(mon, params, &data);
-    handler_audit(mon, cmd, ret);
-
-    if (monitor_ctrl_mode(mon)) {
-        /* Monitor Protocol */
-        monitor_protocol_emitter(mon, data);
-    } else {
-        /* User Protocol */
-         if (data)
-            cmd->user_print(mon, data);
-    }
-
-    qobject_decref(data);
-}
-
 static void handle_user_command(Monitor *mon, const char *cmdline)
 {
     QDict *qdict;
@@ -4430,6 +4407,20 @@  static void qmp_call_query_cmd(Monitor *mon, const mon_cmd_t *cmd)
     }
 }
 
+static void qmp_call_cmd(Monitor *mon, const mon_cmd_t *cmd,
+                         const QDict *params)
+{
+    int ret;
+    QObject *data = NULL;
+
+    mon_print_count_init(mon);
+
+    ret = cmd->mhandler.cmd_new(mon, params, &data);
+    handler_audit(mon, cmd, ret);
+    monitor_protocol_emitter(mon, data);
+    qobject_decref(data);
+}
+
 static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
 {
     int err;
@@ -4497,7 +4488,7 @@  static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
             goto err_out;
         }
     } else {
-        monitor_call_handler(mon, cmd, args);
+        qmp_call_cmd(mon, cmd, args);
     }
 
     goto out;