QMP: do_info() checks

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>
This commit is contained in:
Luiz Capitulino 2009-11-26 22:59:00 -02:00 committed by Anthony Liguori
parent 25b422eb40
commit 956f1a0d83

View File

@ -367,16 +367,23 @@ static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
const mon_cmd_t *cmd; const mon_cmd_t *cmd;
const char *item = qdict_get_try_str(qdict, "item"); const char *item = qdict_get_try_str(qdict, "item");
if (!item) if (!item) {
assert(monitor_ctrl_mode(mon) == 0);
goto help; goto help;
}
for (cmd = info_cmds; cmd->name != NULL; cmd++) { for (cmd = info_cmds; cmd->name != NULL; cmd++) {
if (compare_cmd(item, cmd->name)) if (compare_cmd(item, cmd->name))
break; 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; goto help;
}
if (monitor_handler_ported(cmd)) { if (monitor_handler_ported(cmd)) {
cmd->mhandler.info_new(mon, ret_data); cmd->mhandler.info_new(mon, ret_data);
@ -389,9 +396,14 @@ static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
if (*ret_data) if (*ret_data)
cmd->user_print(mon, *ret_data); cmd->user_print(mon, *ret_data);
} }
} else {
if (monitor_ctrl_mode(mon)) {
/* handler not converted yet */
qemu_error_new(QERR_COMMAND_NOT_FOUND, item);
} else { } else {
cmd->mhandler.info(mon); cmd->mhandler.info(mon);
} }
}
return; return;