qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Denis V. Lunev" <den@openvz.org>,
	Peter Maydell <peter.maydell@linaro.org>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 11/13] trace: convert stderr backend to log
Date: Wed,  3 Feb 2016 15:47:43 +0000	[thread overview]
Message-ID: <1454514465-11856-12-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1454514465-11856-1-git-send-email-stefanha@redhat.com>

From: Paolo Bonzini <pbonzini@redhat.com>

[Also update .travis.yml --enable-trace-backends=stderr
--Stefan]

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-id: 1452174932-28657-10-git-send-email-den@openvz.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 .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=i386-softmmu,x86_64-softmmu
-           EXTRA_CONFIG="--enable-trace-backends=stderr"
+           EXTRA_CONFIG="--enable-trace-backends=log"
       compiler: gcc
     - env: TARGETS=i386-softmmu,x86_64-softmmu
            EXTRA_CONFIG="--enable-trace-backends=simple"
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="\"$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 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)
 
 /* 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__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
+__license__    = "GPL version 2 or (at your option) any later version"
+
+__maintainer__ = "Stefan Hajnoczi"
+__email__      = "stefanha@linux.vnet.ibm.com"
+
+
+from tracetool import out
+
+
+PUBLIC = True
+
+
+def generate_h_begin(events):
+    out('#include <stdio.h>',
+        '#include <sys/time.h>',
+        '#include <sys/types.h>',
+        '#include <unistd.h>',
+        '#include "trace/control.h"',
+        '#include "qemu/log.h"',
+        '')
+
+
+def generate_h(event):
+    argnames = ", ".join(event.args.names())
+    if len(event.args) > 0:
+        argnames = ", " + 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="TRACE_" + event.name.upper(),
+        name=event.name,
+        fmt=event.fmt.rstrip("\n"),
+        argnames=argnames)
diff --git a/scripts/tracetool/backend/stderr.py b/scripts/tracetool/backend/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__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
-__license__    = "GPL version 2 or (at your option) any later version"
-
-__maintainer__ = "Stefan Hajnoczi"
-__email__      = "stefanha@linux.vnet.ibm.com"
-
-
-from tracetool import out
-
-
-PUBLIC = True
-
-
-def generate_h_begin(events):
-    out('#include <stdio.h>',
-        '#include <sys/time.h>',
-        '#include <sys/types.h>',
-        '#include <unistd.h>',
-        '#include "trace/control.h"',
-        '')
-
-
-def generate_h(event):
-    argnames = ", ".join(event.args.names())
-    if len(event.args) > 0:
-        argnames = ", " + 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_usec',
-        '                        %(argnames)s);',
-        '    }',
-        event_id="TRACE_" + event.name.upper(),
-        name=event.name,
-        fmt=event.fmt.rstrip("\n"),
-        argnames=argnames)
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"
 
 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=...: "
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 = 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 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);
     }
 
     if (!trace_init_backends()) {
-- 
2.5.0

  parent reply	other threads:[~2016-02-03 15:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03 15:47 [Qemu-devel] [PULL 00/13] Tracing patches Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 01/13] trace: count number of enabled events Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 02/13] trace: track enabled events in a separate array Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 03/13] trace: fix documentation Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 04/13] trace: split trace_init_events out of trace_init_backends Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 05/13] trace: split trace_init_file " Stefan Hajnoczi
2016-02-08 18:43   ` Alex Bennée
2016-02-09 11:17     ` Denis V. Lunev
2016-02-09 12:28       ` Alex Bennée
2016-02-09 19:19         ` Denis V. Lunev
2016-02-03 15:47 ` [Qemu-devel] [PULL 06/13] trace: no need to call trace_backend_init in different branches now Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 07/13] trace: add "-trace enable=..." Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 08/13] trace: add "-trace help" Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 09/13] log: do not unnecessarily include qom/cpu.h Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 10/13] log: move qemu-log.c into util/ directory Stefan Hajnoczi
2016-02-03 16:03   ` Daniel P. Berrange
2016-02-03 16:15     ` Denis V. Lunev
2016-02-03 16:36     ` Eric Blake
2016-02-03 17:38   ` Dimitris Aragiorgis
2016-02-03 18:46     ` Paolo Bonzini
2016-02-03 15:47 ` Stefan Hajnoczi [this message]
2016-02-03 15:47 ` [Qemu-devel] [PULL 12/13] trace: switch default backend to "log" Stefan Hajnoczi
2016-02-03 15:47 ` [Qemu-devel] [PULL 13/13] log: add "-d trace:PATTERN" Stefan Hajnoczi
2016-02-03 17:55 ` [Qemu-devel] [PULL 00/13] Tracing patches Peter Maydell
2016-02-03 18:49   ` Paolo Bonzini
2016-02-04 11:05     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454514465-11856-12-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=den@openvz.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).