diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2016-10-04 14:35:52 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-10-12 09:52:50 +0200 |
commit | fe4db84d49545e669806d0cce12b3aa384e04ac3 (patch) | |
tree | bb88e1c6c1f504c57c0131d9cc23b37538e1c40c /trace | |
parent | 8ed5372874377af4a84a330eeaff1d9d663ca930 (diff) | |
download | qemu-fe4db84d49545e669806d0cce12b3aa384e04ac3.zip |
trace: provide mechanism for registering trace events
Remove the notion of there being a single global array
of trace events, by introducing a method for registering
groups of events.
The module_call_init() needs to be invoked at the start
of any program that wants to make use of the trace
support. Currently this covers system emulators qemu-nbd,
qemu-img and qemu-io.
[Squashed the following fix from Daniel P. Berrange
<berrange@redhat.com>:
linux-user/bsd-user: initialize trace events subsystem
The bsd-user/linux-user programs make use of the CPU emulation
code and this now requires that the trace events subsystem
is enabled, otherwise it'll crash trying to allocate an empty
trace events bitmap for the CPU object.
--Stefan]
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: LluĂs Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1475588159-30598-14-git-send-email-berrange@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'trace')
-rw-r--r-- | trace/control-internal.h | 4 | ||||
-rw-r--r-- | trace/control.c | 25 | ||||
-rw-r--r-- | trace/control.h | 1 |
3 files changed, 27 insertions, 3 deletions
diff --git a/trace/control-internal.h b/trace/control-internal.h index 9abbc96bcb..a9d395a587 100644 --- a/trace/control-internal.h +++ b/trace/control-internal.h @@ -15,7 +15,6 @@ #include "qom/cpu.h" -extern TraceEvent *trace_events[]; extern int trace_events_enabled_count; @@ -83,4 +82,7 @@ static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id); } + +void trace_event_register_group(TraceEvent **events); + #endif /* TRACE__CONTROL_INTERNAL_H */ diff --git a/trace/control.c b/trace/control.c index 6b32511d60..a2313273d8 100644 --- a/trace/control.c +++ b/trace/control.c @@ -29,6 +29,13 @@ int trace_events_enabled_count; +typedef struct TraceEventGroup { + TraceEvent **events; +} TraceEventGroup; + +static TraceEventGroup *event_groups; +static size_t nevent_groups; + QemuOptsList qemu_trace_opts = { .name = "trace", .implied_opt_name = "enable", @@ -50,6 +57,14 @@ QemuOptsList qemu_trace_opts = { }; +void trace_event_register_group(TraceEvent **events) +{ + event_groups = g_renew(TraceEventGroup, event_groups, nevent_groups + 1); + event_groups[nevent_groups].events = events; + nevent_groups++; +} + + TraceEvent *trace_event_name(const char *name) { assert(name != NULL); @@ -100,14 +115,20 @@ static bool pattern_glob(const char *pat, const char *ev) void trace_event_iter_init(TraceEventIter *iter, const char *pattern) { iter->event = 0; + iter->group = 0; iter->pattern = pattern; } TraceEvent *trace_event_iter_next(TraceEventIter *iter) { - while (trace_events[iter->event] != NULL) { - TraceEvent *ev = trace_events[iter->event]; + while (iter->group < nevent_groups && + event_groups[iter->group].events[iter->event] != NULL) { + TraceEvent *ev = event_groups[iter->group].events[iter->event]; iter->event++; + if (event_groups[iter->group].events[iter->event] == NULL) { + iter->event = 0; + iter->group++; + } if (!iter->pattern || pattern_glob(iter->pattern, trace_event_get_name(ev))) { diff --git a/trace/control.h b/trace/control.h index cccd2a295e..3f30a0c2b7 100644 --- a/trace/control.h +++ b/trace/control.h @@ -15,6 +15,7 @@ typedef struct TraceEventIter { size_t event; + size_t group; const char *pattern; } TraceEventIter; |