virtio-serial: Wrap in vmstate
[qemu.git] / trace / control-target.c
blob74c029acccb3e5f2a2489df72e4554b4279676fc
1 /*
2 * Interface for configuring and controlling the state of tracing events.
4 * Copyright (C) 2014-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 #include "qemu/osdep.h"
11 #include "cpu.h"
12 #include "trace/control.h"
13 #include "translate-all.h"
16 void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
18 CPUState *vcpu;
19 assert(trace_event_get_state_static(ev));
20 if (trace_event_is_vcpu(ev)) {
21 CPU_FOREACH(vcpu) {
22 trace_event_set_vcpu_state_dynamic(vcpu, ev, state);
24 } else {
25 TraceEventID id = trace_event_get_id(ev);
26 trace_events_enabled_count += state - trace_events_dstate[id];
27 trace_events_dstate[id] = state;
31 void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
32 TraceEvent *ev, bool state)
34 TraceEventID id;
35 TraceEventVCPUID vcpu_id;
36 bool state_pre;
37 assert(trace_event_get_state_static(ev));
38 assert(trace_event_is_vcpu(ev));
39 id = trace_event_get_id(ev);
40 vcpu_id = trace_event_get_vcpu_id(ev);
41 state_pre = test_bit(vcpu_id, vcpu->trace_dstate);
42 if (state_pre != state) {
43 if (state) {
44 trace_events_enabled_count++;
45 set_bit(vcpu_id, vcpu->trace_dstate);
46 trace_events_dstate[id]++;
47 } else {
48 trace_events_enabled_count--;
49 clear_bit(vcpu_id, vcpu->trace_dstate);
50 trace_events_dstate[id]--;