Commit 30e7d092 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging



# gpg: Signature made Mon 05 Sep 2016 20:41:04 BST
# gpg:                using RSA key 0x9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/tracing-pull-request:
  trace: Avoid implicit bool->integer conversions
  trace: Remove 'trace_events_dstate_init'
  trace: add syslog tracing backend

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 1fd66154 8eb1b9db
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -4191,6 +4191,18 @@ if compile_prog "" "" ; then
    posix_madvise=yes
fi

##########################################
# check if we have posix_syslog

posix_syslog=no
cat > $TMPC << EOF
#include <syslog.h>
int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
EOF
if compile_prog "" "" ; then
    posix_syslog=yes
fi

##########################################
# check if trace backend exists

@@ -5468,6 +5480,13 @@ if have_backend "ftrace"; then
    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
  fi
fi
if have_backend "syslog"; then
  if test "$posix_syslog" = "yes" ; then
    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
  else
    feature_not_found "syslog(trace backend)" "syslog not available"
  fi
fi
echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak

if test "$rdma" = "yes" ; then
+12 −0
Original line number Diff line number Diff line
@@ -192,6 +192,18 @@ After running qemu by root user, you can get the trace:

Restriction: "ftrace" backend is restricted to Linux only.

=== Syslog ===

The "syslog" backend sends trace events using the POSIX syslog API. The log
is opened specifying the LOG_DAEMON facility and LOG_PID option (so events
are tagged with the pid of the particular QEMU process that generated
them). All events are logged at LOG_INFO level.

NOTE: syslog may squash duplicate consecutive trace events and apply rate
      limiting.

Restriction: "syslog" backend is restricted to POSIX compliant OS.

==== Monitor commands ====

* trace-file on|off|flush|set <path>
+45 −0
Original line number Diff line number Diff line
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Syslog built-in backend.
"""

__author__     = "Paul Durrant <paul.durrant@citrix.com>"
__copyright__  = "Copyright 2016, Citrix Systems Inc."
__license__    = "GPL version 2 or (at your option) any later version"

__maintainer__ = "Stefan Hajnoczi"
__email__      = "stefanha@redhat.com"


from tracetool import out


PUBLIC = True


def generate_h_begin(events):
    out('#include <syslog.h>',
        '#include "trace/control.h"',
        '')


def generate_h(event):
    argnames = ", ".join(event.args.names())
    if len(event.args) > 0:
        argnames = ", " + argnames

    if "vcpu" in event.properties:
        # already checked on the generic format code
        cond = "true"
    else:
        cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())

    out('        if (%(cond)s) {',
        '            syslog(LOG_INFO, "%(name)s " %(fmt)s %(argnames)s);',
        '        }',
        cond=cond,
        name=event.name,
        fmt=event.fmt.rstrip("\n"),
        argnames=argnames)
+20 −2
Original line number Diff line number Diff line
@@ -11,13 +11,31 @@
#include "trace/control.h"


void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
{
    trace_event_set_state_dynamic(ev, state);
}

void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
{
    TraceEventID id;
    bool state_pre;
    assert(trace_event_get_state_static(ev));
    id = trace_event_get_id(ev);
    trace_events_enabled_count += state - trace_events_dstate[id];
    trace_events_dstate[id] = state;
    /*
     * We ignore the "vcpu" property here, since there's no target code. Then
     * dstate can only be 1 or 0.
     */
    state_pre = trace_events_dstate[id];
    if (state_pre != state) {
        if (state) {
            trace_events_enabled_count++;
            trace_events_dstate[id] = 1;
        } else {
            trace_events_enabled_count--;
            trace_events_dstate[id] = 0;
        }
    }
}

void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
+32 −2
Original line number Diff line number Diff line
@@ -13,6 +13,27 @@
#include "translate-all.h"


void trace_event_set_state_dynamic_init(TraceEvent *ev, bool state)
{
    TraceEventID id = trace_event_get_id(ev);
    bool state_pre;
    assert(trace_event_get_state_static(ev));
    /*
     * We ignore the "vcpu" property here, since no vCPUs have been created
     * yet. Then dstate can only be 1 or 0.
     */
    state_pre = trace_events_dstate[id];
    if (state_pre != state) {
        if (state) {
            trace_events_enabled_count++;
            trace_events_dstate[id] = 1;
        } else {
            trace_events_enabled_count--;
            trace_events_dstate[id] = 0;
        }
    }
}

void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
{
    CPUState *vcpu;
@@ -22,9 +43,18 @@ void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
            trace_event_set_vcpu_state_dynamic(vcpu, ev, state);
        }
    } else {
        /* Without the "vcpu" property, dstate can only be 1 or 0 */
        TraceEventID id = trace_event_get_id(ev);
        trace_events_enabled_count += state - trace_events_dstate[id];
        trace_events_dstate[id] = state;
        bool state_pre = trace_events_dstate[id];
        if (state_pre != state) {
            if (state) {
                trace_events_enabled_count++;
                trace_events_dstate[id] = 1;
            } else {
                trace_events_enabled_count--;
                trace_events_dstate[id] = 0;
            }
        }
    }
}

Loading