From patchwork Thu Oct 15 07:30:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 530539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 29FF5140180 for ; Thu, 15 Oct 2015 18:33:50 +1100 (AEDT) Received: from localhost ([::1]:46211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmd2p-0005iD-W1 for incoming@patchwork.ozlabs.org; Thu, 15 Oct 2015 03:33:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmczw-00027u-G2 for qemu-devel@nongnu.org; Thu, 15 Oct 2015 03:30:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zmczo-00033T-HK for qemu-devel@nongnu.org; Thu, 15 Oct 2015 03:30:43 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:13966 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmczo-0002z1-3i for qemu-devel@nongnu.org; Thu, 15 Oct 2015 03:30:40 -0400 Received: from irbis.sw.ru ([10.30.2.139]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id t9F7UOwp018866; Thu, 15 Oct 2015 10:30:30 +0300 (MSK) From: "Denis V. Lunev" To: Date: Thu, 15 Oct 2015 10:30:23 +0300 Message-Id: <1444894224-9542-3-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444894224-9542-1-git-send-email-den@openvz.org> References: <1444894224-9542-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Cc: Peter Maydell , Pavel Butsykin , Markus Armbruster , qemu-devel@nongnu.org, Luiz Capitulino , "Denis V. Lunev" Subject: [Qemu-devel] [PATCH 2/3] log: report hmp/qmp command and qmp event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Pavel Butsykin 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). Signed-off-by: Pavel Butsykin Signed-off-by: Denis V. Lunev CC: Markus Armbruster CC: Luiz Capitulino CC: Eric Blake CC: Peter Maydell --- include/qemu/log.h | 1 + monitor.c | 18 ++++++++++++++++++ qemu-log.c | 1 + 3 files changed, 20 insertions(+) diff --git a/include/qemu/log.h b/include/qemu/log.h index 57b8c96..ba86606 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -41,6 +41,7 @@ static inline bool qemu_log_enabled(void) #define LOG_UNIMP (1 << 10) #define LOG_GUEST_ERROR (1 << 11) #define CPU_LOG_MMU (1 << 12) +#define LOG_CMD (1 << 13) /* Returns true if a bit is set in the current loglevel mask */ diff --git a/monitor.c b/monitor.c index 4f1ba2f..71810bb 100644 --- a/monitor.c +++ b/monitor.c @@ -434,6 +434,12 @@ static void monitor_protocol_emitter(Monitor *mon, QObject *data, } monitor_json_emitter(mon, QOBJECT(qmp)); + if (qemu_loglevel_mask(LOG_CMD)) { + QString *output_json = qobject_to_json_pretty(QOBJECT(qmp)); + qemu_log("qmp response:\n%s\n", output_json->string); + QDECREF(output_json); + } + QDECREF(qmp); } @@ -474,6 +480,11 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *data, Error **errp) evstate->last, now); + if (qemu_loglevel_mask(LOG_CMD)) { + QString *output_json = qobject_to_json_pretty(QOBJECT(data)); + qemu_log("qmp event:\n%s\n", output_json->string); + QDECREF(output_json); + } /* Rate limit of 0 indicates no throttling */ qemu_mutex_lock(&monitor_lock); if (!evstate->rate) { @@ -2848,6 +2859,8 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline) QDict *qdict; const mon_cmd_t *cmd; + qemu_log_mask(LOG_CMD, "hmp request:\n%s\n", cmdline); + cmd = monitor_parse_command(mon, &cmdline, mon->cmd_table); if (!cmd) { return; @@ -3823,6 +3836,11 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) goto err_out; } + if (qemu_loglevel_mask(LOG_CMD)) { + QString *output_json = output_json = qobject_to_json_pretty(obj); + qemu_log("qmp request:\n%s\n", output_json->string); + QDECREF(output_json); + } input = qmp_check_input_obj(obj, &local_err); if (!input) { qobject_decref(obj); diff --git a/qemu-log.c b/qemu-log.c index e6d2b3f..ba7b34c 100644 --- a/qemu-log.c +++ b/qemu-log.c @@ -98,6 +98,7 @@ const QEMULogItem qemu_log_items[] = { { LOG_GUEST_ERROR, "guest_errors", "log when the guest OS does something invalid (eg accessing a\n" "non-existent register)" }, + { LOG_CMD, "cmd", "log the hmp/qmp commands execution" }, { 0, NULL, NULL }, };