Patchwork [03/20] monitor: Introduce monitor_call_handler()

login
register
mail settings
Submitter Luiz Capitulino
Date Nov. 27, 2009, 12:58 a.m.
Message ID <1259283550-3597-4-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/39594/
State New
Headers show

Comments

Luiz Capitulino - Nov. 27, 2009, 12:58 a.m.
This commit moves the code which calls Monitor handlers to
its own function, as it will be used by QMP code as well.

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

Patch

diff --git a/monitor.c b/monitor.c
index 4d18699..e0cc941 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3272,6 +3272,18 @@  static void monitor_print_error(Monitor *mon)
     mon->error = NULL;
 }
 
+static void monitor_call_handler(Monitor *mon, const mon_cmd_t *cmd,
+                                 const QDict *params)
+{
+    QObject *data = NULL;
+
+    cmd->mhandler.cmd_new(mon, params, &data);
+    if (data)
+        cmd->user_print(mon, data);
+
+    qobject_decref(data);
+}
+
 static void monitor_handle_command(Monitor *mon, const char *cmdline)
 {
     QDict *qdict;
@@ -3286,13 +3298,7 @@  static void monitor_handle_command(Monitor *mon, const char *cmdline)
     qemu_errors_to_mon(mon);
 
     if (monitor_handler_ported(cmd)) {
-        QObject *data = NULL;
-
-        cmd->mhandler.cmd_new(mon, qdict, &data);
-        if (data)
-            cmd->user_print(mon, data);
-
-        qobject_decref(data);
+        monitor_call_handler(mon, cmd, qdict);
     } else {
         cmd->mhandler.cmd(mon, qdict);
     }