From patchwork Mon Oct 26 09:10:26 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: 535763 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 E8E78140E31 for ; Mon, 26 Oct 2015 20:14:58 +1100 (AEDT) Received: from localhost ([::1]:51328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqdrk-00052V-Qa for incoming@patchwork.ozlabs.org; Mon, 26 Oct 2015 05:14:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqdnl-0006hD-Uu for qemu-devel@nongnu.org; Mon, 26 Oct 2015 05:10:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zqdnj-0001f5-Aa for qemu-devel@nongnu.org; Mon, 26 Oct 2015 05:10:49 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:8642 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqdni-0001eo-SX for qemu-devel@nongnu.org; Mon, 26 Oct 2015 05:10:47 -0400 Received: from irbis.sw.ru ([10.30.2.139]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id t9Q9AQU1014460; Mon, 26 Oct 2015 12:10:43 +0300 (MSK) From: "Denis V. Lunev" To: Date: Mon, 26 Oct 2015 12:10:26 +0300 Message-Id: <1445850626-29407-10-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445850626-29407-1-git-send-email-den@openvz.org> References: <1445850626-29407-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@linaro.org, qemu-devel@nongnu.org, armbru@redhat.com, stefanha@redhat.com, "Denis V. Lunev" , pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 09/11] trace: convert stderr backend to log 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: Paolo Bonzini Signed-off-by: Paolo Bonzini Signed-off-by: Denis V. Lunev Reviewed-by: Christian Borntraeger --- configure | 4 ++-- include/qemu/log.h | 1 + scripts/tracetool/backend/{stderr.py => log.py} | 9 +++++---- trace/control.c | 10 ++++++++++ util/log.c | 3 +++ vl.c | 2 ++ 6 files changed, 23 insertions(+), 6 deletions(-) rename scripts/tracetool/backend/{stderr.py => log.py} (78%) diff --git a/configure b/configure index 2a129bb..d803e67 100755 --- a/configure +++ b/configure @@ -5299,8 +5299,8 @@ if have_backend "simple"; then # Set the appropriate trace file. trace_file="\"$trace_file-\" FMT_pid" fi -if have_backend "stderr"; then - echo "CONFIG_TRACE_STDERR=y" >> $config_host_mak +if have_backend "log"; then + echo "CONFIG_TRACE_LOG=y" >> $config_host_mak fi if have_backend "ust"; then echo "CONFIG_TRACE_UST=y" >> $config_host_mak diff --git a/include/qemu/log.h b/include/qemu/log.h index ed57a3d..5a0fbe3 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -38,6 +38,7 @@ static inline bool qemu_log_enabled(void) #define LOG_GUEST_ERROR (1 << 11) #define CPU_LOG_MMU (1 << 12) #define CPU_LOG_TB_NOCHAIN (1 << 13) +#define LOG_TRACE (1 << 14) /* Returns true if a bit is set in the current loglevel mask */ diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/log.py similarity index 78% rename from scripts/tracetool/backend/stderr.py rename to scripts/tracetool/backend/log.py index ca58054..a62c310 100644 --- a/scripts/tracetool/backend/stderr.py +++ b/scripts/tracetool/backend/log.py @@ -25,6 +25,7 @@ def generate_h_begin(events): '#include ', '#include ', '#include "trace/control.h"', + '#include "qemu/log.h"', '') @@ -36,10 +37,10 @@ def generate_h(event): out(' if (trace_event_get_state(%(event_id)s)) {', ' struct timeval _now;', ' gettimeofday(&_now, NULL);', - ' fprintf(stderr, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', - ' getpid(),', - ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', - ' %(argnames)s);', + ' qemu_log_mask(LOG_TRACE, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', + ' getpid(),', + ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', + ' %(argnames)s);', ' }', event_id="TRACE_" + event.name.upper(), name=event.name, diff --git a/trace/control.c b/trace/control.c index 7c84795..9a1e381 100644 --- a/trace/control.c +++ b/trace/control.c @@ -14,6 +14,9 @@ #ifdef CONFIG_TRACE_FTRACE #include "trace/ftrace.h" #endif +#ifdef CONFIG_TRACE_LOG +#include "qemu/log.h" +#endif #include "qemu/error-report.h" TraceEvent *trace_event_name(const char *name) @@ -171,6 +174,13 @@ void trace_init_file(const char *file) { #ifdef CONFIG_TRACE_SIMPLE st_set_trace_file(file); +#elif defined CONFIG_TRACE_LOG + /* If both the simple and the log backends are enabled, "-trace file" + * only applies to the simple backend; use "-D" for the log backend. + */ + if (file) { + qemu_set_log_filename(file); + } #else if (file) { fprintf(stderr, "error: -trace file=...: " diff --git a/util/log.c b/util/log.c index efd07c8..5c641a0 100644 --- a/util/log.c +++ b/util/log.c @@ -51,6 +51,9 @@ void qemu_log_mask(int mask, const char *fmt, ...) void do_qemu_set_log(int log_flags, bool use_own_buffers) { qemu_loglevel = log_flags; +#ifdef CONFIG_TRACE_LOG + qemu_loglevel |= LOG_TRACE; +#endif if (qemu_loglevel && !qemu_logfile) { if (logfilename) { qemu_logfile = fopen(logfilename, log_append ? "a" : "w"); diff --git a/vl.c b/vl.c index 2b05023..88b4ccb 100644 --- a/vl.c +++ b/vl.c @@ -4088,6 +4088,8 @@ int main(int argc, char **argv, char **envp) exit(1); } qemu_set_log(mask); + } else { + qemu_set_log(0); } if (!trace_init_backends()) {