[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/9] log: log QMP commands and replies
From: |
Denis V. Lunev |
Subject: |
[Qemu-devel] [PATCH 6/9] log: log QMP commands and replies |
Date: |
Mon, 14 Mar 2016 14:21:38 +0300 |
From: Pavel Butsykin <address@hidden>
This log would be very welcome for long-term diagnostics of the system
in the production. This log is at least necessary to understand what
has been happened on the system and to identify issues at higher-level
subsystems (libvirt, etc).
These messages will be quite useful to understand how things are going.
Signed-off-by: Pavel Butsykin <address@hidden>
Signed-off-by: Denis V. Lunev <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
CC: Paolo Bonzini <address@hidden>
CC: Luiz Capitulino <address@hidden>
CC: Markus Armbruster <address@hidden>
CC: Eric Blake <address@hidden>
---
include/qemu/log.h | 1 +
monitor.c | 13 +++++++++++++
util/log.c | 2 ++
3 files changed, 16 insertions(+)
diff --git a/include/qemu/log.h b/include/qemu/log.h
index a05c7dc..55bceae 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -42,6 +42,7 @@ static inline bool qemu_log_separate(void)
#define CPU_LOG_TB_NOCHAIN (1 << 13)
#define CPU_LOG_PAGE (1 << 14)
#define LOG_TRACE (1 << 15)
+#define LOG_QMP (1 << 16)
/* Returns true if a bit is set in the current loglevel mask
*/
diff --git a/monitor.c b/monitor.c
index e99ca8c..eec4e58 100644
--- a/monitor.c
+++ b/monitor.c
@@ -437,6 +437,12 @@ static void monitor_protocol_emitter(Monitor *mon, QObject
*data,
}
monitor_json_emitter(mon, QOBJECT(qmp));
+ if (qemu_loglevel_mask(LOG_QMP)) {
+ QString *output_json = qobject_to_json(QOBJECT(qmp));
+ qemu_log_mask(LOG_QMP, "QMP reply: %s\n", output_json->string);
+ QDECREF(output_json);
+ }
+
QDECREF(qmp);
}
@@ -3867,6 +3873,11 @@ static void handle_qmp_command(JSONMessageParser
*parser, GQueue *tokens)
goto err_out;
}
+ if (qemu_loglevel_mask(LOG_QMP)) {
+ QString *output_json = qobject_to_json(obj);
+ qemu_log_mask(LOG_QMP, "QMP command: %s\n", output_json->string);
+ QDECREF(output_json);
+ }
input = qmp_check_input_obj(obj, &local_err);
if (!input) {
qobject_decref(obj);
@@ -3988,12 +3999,14 @@ static void monitor_qmp_event(void *opaque, int event)
monitor_json_emitter(mon, data);
qobject_decref(data);
mon_refcount++;
+ qemu_log_mask(LOG_QMP, "QMP: new connection established\n");
break;
case CHR_EVENT_CLOSED:
json_message_parser_destroy(&mon->qmp.parser);
json_message_parser_init(&mon->qmp.parser, handle_qmp_command);
mon_refcount--;
monitor_fdsets_cleanup();
+ qemu_log_mask(LOG_QMP, "QMP: connection closed\n");
break;
}
}
diff --git a/util/log.c b/util/log.c
index 65d46e2..5fc517b 100644
--- a/util/log.c
+++ b/util/log.c
@@ -131,6 +131,8 @@ const QEMULogItem qemu_log_items[] = {
{ CPU_LOG_TB_NOCHAIN, "nochain",
"do not chain compiled TBs so that \"exec\" and \"cpu\" show\n"
"complete traces" },
+ { LOG_QMP, "qmp",
+ "log the QMP commands and events" },
{ 0, NULL, NULL },
};
--
2.5.0
- Re: [Qemu-devel] [PATCH 5/9] log: improve performance of qemu_log and qemu_log_mask if disabled, (continued)
- [Qemu-devel] [PATCH 2/9] qemu-log: fix cpu_reset log target, Denis V. Lunev, 2016/03/14
- [Qemu-devel] [PATCH 1/9] trace: do not always call exit() in trace_enable_events, Denis V. Lunev, 2016/03/14
- [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies,
Denis V. Lunev <=
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Paolo Bonzini, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Daniel P. Berrange, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Denis V. Lunev, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Daniel P. Berrange, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Denis V. Lunev, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Paolo Bonzini, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Daniel P. Berrange, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Denis V. Lunev, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Paolo Bonzini, 2016/03/14
- Re: [Qemu-devel] [PATCH 6/9] log: log QMP commands and replies, Denis V. Lunev, 2016/03/16