summaryrefslogtreecommitdiff
path: root/trace/control-target.c
diff options
context:
space:
mode:
Diffstat (limited to 'trace/control-target.c')
-rw-r--r--trace/control-target.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/trace/control-target.c b/trace/control-target.c
index 72081e2a34..52fcce5a00 100644
--- a/trace/control-target.c
+++ b/trace/control-target.c
@@ -9,6 +9,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
+#include "trace.h"
#include "trace/control.h"
#include "translate-all.h"
@@ -81,3 +82,42 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
}
}
}
+
+static bool adding_first_cpu(void)
+{
+ CPUState *cpu;
+ size_t count = 0;
+ CPU_FOREACH(cpu) {
+ count++;
+ if (count > 1) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void trace_init_vcpu(CPUState *vcpu)
+{
+ TraceEvent *ev = NULL;
+
+ while ((ev = trace_event_pattern("*", ev)) != NULL) {
+ if (trace_event_is_vcpu(ev) &&
+ trace_event_get_state_static(ev) &&
+ trace_event_get_state_dynamic(ev)) {
+ TraceEventID id = trace_event_get_id(ev);
+ if (adding_first_cpu()) {
+ /* check preconditions */
+ assert(trace_events_dstate[id] == 1);
+ /* disable early-init state ... */
+ trace_events_dstate[id] = 0;
+ trace_events_enabled_count--;
+ /* ... and properly re-enable */
+ trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
+ } else {
+ trace_event_set_vcpu_state_dynamic(vcpu, ev, true);
+ }
+ }
+ }
+
+ trace_guest_cpu_enter(vcpu);
+}