diff options
Diffstat (limited to 'trace')
-rw-r--r-- | trace/control-target.c | 37 | ||||
-rw-r--r-- | trace/control.c | 19 | ||||
-rw-r--r-- | trace/control.h | 19 |
3 files changed, 45 insertions, 30 deletions
diff --git a/trace/control-target.c b/trace/control-target.c index 72081e2a34..3b7d99b44c 100644 --- a/trace/control-target.c +++ b/trace/control-target.c @@ -81,3 +81,40 @@ 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); + } + } + } +} diff --git a/trace/control.c b/trace/control.c index 05d85accbd..10b3e9baba 100644 --- a/trace/control.c +++ b/trace/control.c @@ -269,22 +269,3 @@ char *trace_opt_parse(const char *optarg) return trace_file; } - -void trace_init_vcpu_events(void) -{ - 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); - /* 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_state_dynamic(ev, true); - } - } -} diff --git a/trace/control.h b/trace/control.h index 27a16fc955..a22d11242e 100644 --- a/trace/control.h +++ b/trace/control.h @@ -239,6 +239,14 @@ bool trace_init_backends(void); void trace_init_file(const char *file); /** + * trace_init_vcpu: + * @vcpu: Added vCPU. + * + * Set initial dynamic event state for a hot-plugged vCPU. + */ +void trace_init_vcpu(CPUState *vcpu); + +/** * trace_list_events: * * List all available events. @@ -269,17 +277,6 @@ extern QemuOptsList qemu_trace_opts; */ char *trace_opt_parse(const char *optarg); -/** - * trace_init_vcpu_events: - * - * Re-synchronize initial event state with vCPUs (which can be created after - * trace_init_events()). - * - * Precondition: event states won't be changed between trace_enable_events() and - * trace_init_vcpu_events() (e.g., through QMP). - */ -void trace_init_vcpu_events(void); - #include "trace/control-internal.h" |