From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQzfE-0001Of-TQ for qemu-devel@nongnu.org; Wed, 03 Feb 2016 10:48:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQzfA-0002bi-Bo for qemu-devel@nongnu.org; Wed, 03 Feb 2016 10:48:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQzfA-0002bH-2d for qemu-devel@nongnu.org; Wed, 03 Feb 2016 10:48:12 -0500 From: Stefan Hajnoczi Date: Wed, 3 Feb 2016 15:47:43 +0000 Message-Id: <1454514465-11856-12-git-send-email-stefanha@redhat.com> In-Reply-To: <1454514465-11856-1-git-send-email-stefanha@redhat.com> References: <1454514465-11856-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 11/13] 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 [Also update .travis.yml --enable-trace-backends=3Dstderr --Stefan] Signed-off-by: Paolo Bonzini Signed-off-by: Denis V. Lunev Acked-by: Christian Borntraeger Message-id: 1452174932-28657-10-git-send-email-den@openvz.org Signed-off-by: Stefan Hajnoczi --- .travis.yml | 2 +- configure | 4 ++-- include/qemu/log.h | 1 + scripts/tracetool/backend/log.py | 48 +++++++++++++++++++++++++++++++= ++++++ scripts/tracetool/backend/stderr.py | 47 -------------------------------= ----- trace/control.c | 10 ++++++++ util/log.c | 3 +++ vl.c | 2 ++ 8 files changed, 67 insertions(+), 50 deletions(-) create mode 100644 scripts/tracetool/backend/log.py delete mode 100644 scripts/tracetool/backend/stderr.py diff --git a/.travis.yml b/.travis.yml index 6ca0260..0428aed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,7 +78,7 @@ matrix: compiler: gcc # All the trace backends (apart from dtrace) - env: TARGETS=3Di386-softmmu,x86_64-softmmu - EXTRA_CONFIG=3D"--enable-trace-backends=3Dstderr" + EXTRA_CONFIG=3D"--enable-trace-backends=3Dlog" compiler: gcc - env: TARGETS=3Di386-softmmu,x86_64-softmmu EXTRA_CONFIG=3D"--enable-trace-backends=3Dsimple" diff --git a/configure b/configure index 297bfc7..92c2616 100755 --- a/configure +++ b/configure @@ -5445,8 +5445,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 09722e3..30817f7 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void) #define CPU_LOG_MMU (1 << 12) #define CPU_LOG_TB_NOCHAIN (1 << 13) #define CPU_LOG_PAGE (1 << 14) +#define LOG_TRACE (1 << 15) =20 /* Returns true if a bit is set in the current loglevel mask */ diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend= /log.py new file mode 100644 index 0000000..a62c310 --- /dev/null +++ b/scripts/tracetool/backend/log.py @@ -0,0 +1,48 @@ +#!/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"', + '#include "qemu/log.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);', + ' 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=3D"TRACE_" + event.name.upper(), + name=3Devent.name, + fmt=3Devent.fmt.rstrip("\n"), + argnames=3Dargnames) 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 901b930..37185a5 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 58cc050..a7d7c39 100644 --- a/vl.c +++ b/vl.c @@ -4115,6 +4115,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