summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2010-12-17 08:23:05 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2010-12-17 08:23:05 -0600
commitfef395782d76fa497bfc89cea741173706669b2e (patch)
treec4ea4e9ec889c9261761752d3e8c99145d90346e /monitor.c
parent2e44928e3c1b9425c17d0786f7d9139871bba43f (diff)
parent3a019b6e6ad64e4df452a15dced6c954e45246c4 (diff)
downloadqemu-fef395782d76fa497bfc89cea741173706669b2e.tar.gz
Merge remote branch 'qmp/for-anthony' into staging
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c86
1 files changed, 38 insertions, 48 deletions
diff --git a/monitor.c b/monitor.c
index 0896254e0d..aae81bb8ad 100644
--- a/monitor.c
+++ b/monitor.c
@@ -351,10 +351,8 @@ static void monitor_json_emitter(Monitor *mon, const QObject *data)
{
QString *json;
- if (mon->flags & MONITOR_USE_PRETTY)
- json = qobject_to_json_pretty(data);
- else
- json = qobject_to_json(data);
+ json = mon->flags & MONITOR_USE_PRETTY ? qobject_to_json_pretty(data) :
+ qobject_to_json(data);
assert(json != NULL);
qstring_append_chr(json, '\n');
@@ -4172,49 +4170,43 @@ void monitor_set_error(Monitor *mon, QError *qerror)
static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret)
{
- if (monitor_ctrl_mode(mon)) {
- if (ret && !monitor_has_error(mon)) {
- /*
- * If it returns failure, it must have passed on error.
- *
- * Action: Report an internal error to the client if in QMP.
- */
- qerror_report(QERR_UNDEFINED_ERROR);
- MON_DEBUG("command '%s' returned failure but did not pass an error\n",
- cmd->name);
- }
+ if (ret && !monitor_has_error(mon)) {
+ /*
+ * If it returns failure, it must have passed on error.
+ *
+ * Action: Report an internal error to the client if in QMP.
+ */
+ qerror_report(QERR_UNDEFINED_ERROR);
+ MON_DEBUG("command '%s' returned failure but did not pass an error\n",
+ cmd->name);
+ }
#ifdef CONFIG_DEBUG_MONITOR
- if (!ret && monitor_has_error(mon)) {
- /*
- * If it returns success, it must not have passed an error.
- *
- * Action: Report the passed error to the client.
- */
- MON_DEBUG("command '%s' returned success but passed an error\n",
- cmd->name);
- }
-
- if (mon_print_count_get(mon) > 0 && strcmp(cmd->name, "info") != 0) {
- /*
- * Handlers should not call Monitor print functions.
- *
- * Action: Ignore them in QMP.
- *
- * (XXX: we don't check any 'info' or 'query' command here
- * because the user print function _is_ called by do_info(), hence
- * we will trigger this check. This problem will go away when we
- * make 'query' commands real and kill do_info())
- */
- MON_DEBUG("command '%s' called print functions %d time(s)\n",
- cmd->name, mon_print_count_get(mon));
- }
-#endif
- } else {
- assert(!monitor_has_error(mon));
- QDECREF(mon->error);
- mon->error = NULL;
+ if (!ret && monitor_has_error(mon)) {
+ /*
+ * If it returns success, it must not have passed an error.
+ *
+ * Action: Report the passed error to the client.
+ */
+ MON_DEBUG("command '%s' returned success but passed an error\n",
+ cmd->name);
+ }
+
+ if (mon_print_count_get(mon) > 0 && strcmp(cmd->name, "info") != 0) {
+ /*
+ * Handlers should not call Monitor print functions.
+ *
+ * Action: Ignore them in QMP.
+ *
+ * (XXX: we don't check any 'info' or 'query' command here
+ * because the user print function _is_ called by do_info(), hence
+ * we will trigger this check. This problem will go away when we
+ * make 'query' commands real and kill do_info())
+ */
+ MON_DEBUG("command '%s' called print functions %d time(s)\n",
+ cmd->name, mon_print_count_get(mon));
}
+#endif
}
static void handle_user_command(Monitor *mon, const char *cmdline)
@@ -4745,10 +4737,8 @@ static void qmp_call_query_cmd(Monitor *mon, const mon_cmd_t *cmd)
}
} else {
cmd->mhandler.info_new(mon, &ret_data);
- if (ret_data) {
- monitor_protocol_emitter(mon, ret_data);
- qobject_decref(ret_data);
- }
+ monitor_protocol_emitter(mon, ret_data);
+ qobject_decref(ret_data);
}
}