From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw92C-0000FV-74 for qemu-devel@nongnu.org; Tue, 10 Nov 2015 08:32:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zw926-0000wi-5Y for qemu-devel@nongnu.org; Tue, 10 Nov 2015 08:32:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw925-0000wd-UW for qemu-devel@nongnu.org; Tue, 10 Nov 2015 08:32:22 -0500 From: Stefan Hajnoczi Date: Tue, 10 Nov 2015 13:31:46 +0000 Message-Id: <1447162308-8517-14-git-send-email-stefanha@redhat.com> In-Reply-To: <1447162308-8517-1-git-send-email-stefanha@redhat.com> References: <1447162308-8517-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 13/15] trace: convert stderr backend to log List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Denis V. Lunev" , Peter Maydell , Stefan Hajnoczi , Paolo Bonzini From: Paolo Bonzini Signed-off-by: Paolo Bonzini Signed-off-by: Denis V. Lunev Acked-by: Christian Borntraeger Message-id: 1446151457-21157-10-git-send-email-den@openvz.org Signed-off-by: Stefan Hajnoczi --- configure | 4 ++-- include/qemu/log.h | 1 + scripts/tracetool/backend/stderr.py | 47 -------------------------------= ------ trace/control.c | 10 ++++++++ util/log.c | 3 +++ vl.c | 2 ++ 6 files changed, 18 insertions(+), 49 deletions(-) delete mode 100644 scripts/tracetool/backend/stderr.py diff --git a/configure b/configure index 46fd8bd..6bd4edf 100755 --- a/configure +++ b/configure @@ -5309,8 +5309,8 @@ if have_backend "simple"; then # Set the appropriate trace file. trace_file=3D"\"$trace_file-\" FMT_pid" fi -if have_backend "stderr"; then - echo "CONFIG_TRACE_STDERR=3Dy" >> $config_host_mak +if have_backend "log"; then + echo "CONFIG_TRACE_LOG=3Dy" >> $config_host_mak fi if have_backend "ust"; then echo "CONFIG_TRACE_UST=3Dy" >> $config_host_mak diff --git a/include/qemu/log.h b/include/qemu/log.h index 0fcdba9..fdcfab0 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -37,6 +37,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) =20 /* Returns true if a bit is set in the current loglevel mask */ diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/back= end/stderr.py deleted file mode 100644 index ca58054..0000000 --- a/scripts/tracetool/backend/stderr.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -Stderr built-in backend. -""" - -__author__ =3D "Llu=C3=ADs Vilanova " -__copyright__ =3D "Copyright 2012-2014, Llu=C3=ADs Vilanova " -__license__ =3D "GPL version 2 or (at your option) any later version" - -__maintainer__ =3D "Stefan Hajnoczi" -__email__ =3D "stefanha@linux.vnet.ibm.com" - - -from tracetool import out - - -PUBLIC =3D True - - -def generate_h_begin(events): - out('#include ', - '#include ', - '#include ', - '#include ', - '#include "trace/control.h"', - '') - - -def generate_h(event): - argnames =3D ", ".join(event.args.names()) - if len(event.args) > 0: - argnames =3D ", " + argnames - - 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_us= ec', - ' %(argnames)s);', - ' }', - event_id=3D"TRACE_" + event.name.upper(), - name=3Devent.name, - fmt=3Devent.fmt.rstrip("\n"), - argnames=3Dargnames) diff --git a/trace/control.c b/trace/control.c index bef7884..84ea840 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" =20 int trace_events_enabled_count; @@ -174,6 +177,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=3D...: " diff --git a/util/log.c b/util/log.c index 7cb01a8..5cc71eb 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 =3D log_flags; +#ifdef CONFIG_TRACE_LOG + qemu_loglevel |=3D LOG_TRACE; +#endif if (qemu_loglevel && !qemu_logfile) { if (logfilename) { qemu_logfile =3D fopen(logfilename, log_append ? "a" : "w"); diff --git a/vl.c b/vl.c index e391e1d..8b602ea 100644 --- a/vl.c +++ b/vl.c @@ -4118,6 +4118,8 @@ int main(int argc, char **argv, char **envp) exit(1); } qemu_set_log(mask); + } else { + qemu_set_log(0); } =20 if (!trace_init_backends()) { --=20 2.5.0