]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
QMP: do_info() checks
authorLuiz Capitulino <lcapitulino@redhat.com>
Fri, 27 Nov 2009 00:59:00 +0000 (22:59 -0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 3 Dec 2009 15:41:23 +0000 (09:41 -0600)
This commit adds specific QMP checks to do_info(), so that
it behaves as expected in QMP mode.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
monitor.c

index 8d05164ac28076742f93f3199876b4a61d9a12ab..70665bd789be3fa2f3e99814eb75207e078052f3 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -367,16 +367,23 @@ static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
     const mon_cmd_t *cmd;
     const char *item = qdict_get_try_str(qdict, "item");
 
-    if (!item)
+    if (!item) {
+        assert(monitor_ctrl_mode(mon) == 0);
         goto help;
+    }
 
     for (cmd = info_cmds; cmd->name != NULL; cmd++) {
         if (compare_cmd(item, cmd->name))
             break;
     }
 
-    if (cmd->name == NULL)
+    if (cmd->name == NULL) {
+        if (monitor_ctrl_mode(mon)) {
+            qemu_error_new(QERR_COMMAND_NOT_FOUND, item);
+            return;
+        }
         goto help;
+    }
 
     if (monitor_handler_ported(cmd)) {
         cmd->mhandler.info_new(mon, ret_data);
@@ -390,7 +397,12 @@ static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
                 cmd->user_print(mon, *ret_data);
         }
     } else {
-        cmd->mhandler.info(mon);
+        if (monitor_ctrl_mode(mon)) {
+            /* handler not converted yet */
+            qemu_error_new(QERR_COMMAND_NOT_FOUND, item);
+        } else {
+            cmd->mhandler.info(mon);
+        }
     }
 
     return;