Patchwork [14/21] Monitor: Convert do_info() to cmd_new_ret()

login
register
mail settings
Submitter Luiz Capitulino
Date Feb. 11, 2010, 1:50 a.m.
Message ID <1265853007-27300-15-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/45095/
State New
Headers show

Comments

Luiz Capitulino - Feb. 11, 2010, 1:50 a.m.
Note that this function only fails in QMP, in the user Monitor
it prints the help text instead.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 monitor.c       |    8 +++++---
 qemu-monitor.hx |    2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index 3470b0b..baedc34 100644
--- a/monitor.c
+++ b/monitor.c
@@ -556,7 +556,7 @@  static void user_async_info_handler(Monitor *mon, const mon_cmd_t *cmd)
     }
 }
 
-static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
+static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     const mon_cmd_t *cmd;
     const char *item = qdict_get_try_str(qdict, "item");
@@ -574,7 +574,7 @@  static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
     if (cmd->name == NULL) {
         if (monitor_ctrl_mode(mon)) {
             qemu_error_new(QERR_COMMAND_NOT_FOUND, item);
-            return;
+            return -1;
         }
         goto help;
     }
@@ -606,15 +606,17 @@  static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
         if (monitor_ctrl_mode(mon)) {
             /* handler not converted yet */
             qemu_error_new(QERR_COMMAND_NOT_FOUND, item);
+            return -1;
         } else {
             cmd->mhandler.info(mon);
         }
     }
 
-    return;
+    return 0;
 
 help:
     help_cmd(mon, "info");
+    return 0;
 }
 
 static void do_info_version_print(Monitor *mon, const QObject *data)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 5ae1969..7bfb8d0 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -43,7 +43,7 @@  ETEXI
         .params     = "[subcommand]",
         .help       = "show various information about the system state",
         .user_print = monitor_user_noop,
-        .mhandler.cmd_new = do_info,
+        .cmd_new_ret = do_info,
     },
 
 STEXI