Skip to content

Commit

Permalink
trace: [hmp] Reimplement "trace-event" and "info trace-events" using QMP
Browse files Browse the repository at this point in the history
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Message-id: 20140825112002.31112.60143.stgit@fimbulvetr.bsc.es
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
Lluís Vilanova authored and stefanhaRH committed Sep 26, 2014
1 parent 1dde0f4 commit 14101d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 33 deletions.
27 changes: 14 additions & 13 deletions monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,19 +886,12 @@ static void do_trace_event_set_state(Monitor *mon, const QDict *qdict)
{
const char *tp_name = qdict_get_str(qdict, "name");
bool new_state = qdict_get_bool(qdict, "option");
Error *local_err = NULL;

bool found = false;
TraceEvent *ev = NULL;
while ((ev = trace_event_pattern(tp_name, ev)) != NULL) {
found = true;
if (!trace_event_get_state_static(ev)) {
monitor_printf(mon, "event \"%s\" is not traceable\n", tp_name);
} else {
trace_event_set_state_dynamic(ev, new_state);
}
}
if (!trace_event_is_pattern(tp_name) && !found) {
monitor_printf(mon, "unknown event name \"%s\"\n", tp_name);
qmp_trace_event_set_state(tp_name, new_state, true, true, &local_err);
if (local_err) {
qerror_report_err(local_err);
error_free(local_err);
}
}

Expand Down Expand Up @@ -1079,7 +1072,15 @@ static void do_info_cpu_stats(Monitor *mon, const QDict *qdict)

static void do_trace_print_events(Monitor *mon, const QDict *qdict)
{
trace_print_events((FILE *)mon, &monitor_fprintf);
TraceEventInfoList *events = qmp_trace_event_get_state("*", NULL);
TraceEventInfoList *elem;

for (elem = events; elem != NULL; elem = elem->next) {
monitor_printf(mon, "%s : state %u\n",
elem->value->name,
elem->value->state == TRACE_EVENT_STATE_ENABLED ? 1 : 0);
}
qapi_free_TraceEventInfoList(events);
}

static int client_migrate_info(Monitor *mon, const QDict *qdict,
Expand Down
13 changes: 0 additions & 13 deletions trace/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,6 @@ TraceEvent *trace_event_pattern(const char *pat, TraceEvent *ev)
return NULL;
}

void trace_print_events(FILE *stream, fprintf_function stream_printf)
{
TraceEventID i;

for (i = 0; i < trace_event_count(); i++) {
TraceEvent *ev = trace_event_id(i);
stream_printf(stream, "%s [Event ID %u] : state %u\n",
trace_event_get_name(ev), i,
trace_event_get_state_static(ev) &&
trace_event_get_state_dynamic(ev));
}
}

static void trace_init_events(const char *fname)
{
Location loc;
Expand Down
7 changes: 0 additions & 7 deletions trace/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,6 @@ static void trace_event_set_state_dynamic(TraceEvent *ev, bool state);



/**
* trace_print_events:
*
* Print the state of all events.
*/
void trace_print_events(FILE *stream, fprintf_function stream_printf);

/**
* trace_init_backends:
* @events: Name of file with events to be enabled at startup; may be NULL.
Expand Down

0 comments on commit 14101d0

Please sign in to comment.