qcow2: Remove unused Error variable in do_perform_cow()
[qemu/kevin.git] / trace / control.h
blob4ea53e298683b51955a7a2b2bed00b027b44d04f
1 /*
2 * Interface for configuring and controlling the state of tracing events.
4 * Copyright (C) 2011-2016 LluĂ­s Vilanova <vilanova@ac.upc.edu>
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
10 #ifndef TRACE__CONTROL_H
11 #define TRACE__CONTROL_H
13 #include "qemu-common.h"
14 #include "event-internal.h"
16 typedef struct TraceEventIter {
17 size_t event;
18 size_t group;
19 const char *pattern;
20 } TraceEventIter;
23 /**
24 * trace_event_iter_init:
25 * @iter: the event iterator struct
26 * @pattern: optional pattern to filter events on name
28 * Initialize the event iterator struct @iter,
29 * optionally using @pattern to filter out events
30 * with non-matching names.
32 void trace_event_iter_init(TraceEventIter *iter, const char *pattern);
34 /**
35 * trace_event_iter_next:
36 * @iter: the event iterator struct
38 * Get the next event, if any. When this returns NULL,
39 * the iterator should no longer be used.
41 * Returns: the next event, or NULL if no more events exist
43 TraceEvent *trace_event_iter_next(TraceEventIter *iter);
46 /**
47 * trace_event_name:
48 * @id: Event name.
50 * Search an event by its name.
52 * Returns: pointer to #TraceEvent or NULL if not found.
54 TraceEvent *trace_event_name(const char *name);
56 /**
57 * trace_event_is_pattern:
59 * Whether the given string is an event name pattern.
61 static bool trace_event_is_pattern(const char *str);
64 /**
65 * trace_event_get_id:
67 * Get the identifier of an event.
69 static uint32_t trace_event_get_id(TraceEvent *ev);
71 /**
72 * trace_event_get_vcpu_id:
74 * Get the per-vCPU identifier of an event.
76 * Special value #TRACE_VCPU_EVENT_NONE means the event is not vCPU-specific
77 * (does not have the "vcpu" property).
79 static uint32_t trace_event_get_vcpu_id(TraceEvent *ev);
81 /**
82 * trace_event_is_vcpu:
84 * Whether this is a per-vCPU event.
86 static bool trace_event_is_vcpu(TraceEvent *ev);
88 /**
89 * trace_event_get_name:
91 * Get the name of an event.
93 static const char * trace_event_get_name(TraceEvent *ev);
95 /**
96 * trace_event_get_state:
97 * @id: Event identifier name.
99 * Get the tracing state of an event (both static and dynamic).
101 * If the event has the disabled property, the check will have no performance
102 * impact.
104 #define trace_event_get_state(id) \
105 ((id ##_ENABLED) && trace_event_get_state_dynamic_by_id(id))
108 * trace_event_get_vcpu_state:
109 * @vcpu: Target vCPU.
110 * @id: Event identifier name.
112 * Get the tracing state of an event (both static and dynamic) for the given
113 * vCPU.
115 * If the event has the disabled property, the check will have no performance
116 * impact.
118 #define trace_event_get_vcpu_state(vcpu, id) \
119 ((id ##_ENABLED) && \
120 trace_event_get_vcpu_state_dynamic_by_vcpu_id( \
121 vcpu, _ ## id ## _EVENT.vcpu_id))
124 * trace_event_get_state_static:
125 * @id: Event identifier.
127 * Get the static tracing state of an event.
129 * Use the define 'TRACE_${EVENT_NAME}_ENABLED' for compile-time checks (it will
130 * be set to 1 or 0 according to the presence of the disabled property).
132 static bool trace_event_get_state_static(TraceEvent *ev);
135 * trace_event_get_state_dynamic:
137 * Get the dynamic tracing state of an event.
139 * If the event has the 'vcpu' property, gets the OR'ed state of all vCPUs.
141 static bool trace_event_get_state_dynamic(TraceEvent *ev);
144 * trace_event_get_vcpu_state_dynamic:
146 * Get the dynamic tracing state of an event for the given vCPU.
148 static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev);
152 * trace_event_set_state_dynamic:
154 * Set the dynamic tracing state of an event.
156 * If the event has the 'vcpu' property, sets the state on all vCPUs.
158 * Pre-condition: trace_event_get_state_static(ev) == true
160 void trace_event_set_state_dynamic(TraceEvent *ev, bool state);
163 * trace_event_set_vcpu_state_dynamic:
165 * Set the dynamic tracing state of an event for the given vCPU.
167 * Pre-condition: trace_event_get_vcpu_state_static(ev) == true
169 void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
170 TraceEvent *ev, bool state);
175 * trace_init_backends:
176 * @file: Name of trace output file; may be NULL.
177 * Corresponds to commandline option "-trace file=...".
179 * Initialize the tracing backend.
181 * Returns: Whether the backends could be successfully initialized.
183 bool trace_init_backends(void);
186 * trace_init_file:
187 * @file: Name of trace output file; may be NULL.
188 * Corresponds to commandline option "-trace file=...".
190 * Record the name of the output file for the tracing backend.
191 * Exits if no selected backend does not support specifying the
192 * output file, and a non-NULL file was passed.
194 void trace_init_file(const char *file);
197 * trace_init_vcpu:
198 * @vcpu: Added vCPU.
200 * Set initial dynamic event state for a hot-plugged vCPU.
202 void trace_init_vcpu(CPUState *vcpu);
205 * trace_fini_vcpu:
206 * @vcpu: Removed vCPU.
208 * Disable dynamic event state for a hot-unplugged vCPU.
210 void trace_fini_vcpu(CPUState *vcpu);
213 * trace_list_events:
215 * List all available events.
217 void trace_list_events(void);
220 * trace_enable_events:
221 * @line_buf: A string with a glob pattern of events to be enabled or,
222 * if the string starts with '-', disabled.
224 * Enable or disable matching events.
226 void trace_enable_events(const char *line_buf);
229 * Definition of QEMU options describing trace subsystem configuration
231 extern QemuOptsList qemu_trace_opts;
234 * trace_opt_parse:
235 * @optarg: A string argument of --trace command line argument
237 * Initialize tracing subsystem.
239 * Returns the filename to save trace to. It must be freed with g_free().
241 char *trace_opt_parse(const char *optarg);
244 * trace_get_vcpu_event_count:
246 * Return the number of known vcpu-specific events
248 uint32_t trace_get_vcpu_event_count(void);
251 #include "trace/control-internal.h"
253 #endif /* TRACE__CONTROL_H */