From: Pavel Butsykin <pbutsy...@virtuozzo.com> 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 <pbutsy...@virtuozzo.com> Signed-off-by: Denis V. Lunev <d...@openvz.org> CC: Stefan Hajnoczi <stefa...@redhat.com> CC: Paolo Bonzini <pbonz...@redhat.com> CC: Luiz Capitulino <lcapitul...@redhat.com> CC: Markus Armbruster <arm...@redhat.com> CC: Eric Blake <ebl...@redhat.com> --- 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