aboutsummaryrefslogtreecommitdiff
path: root/trace
diff options
context:
space:
mode:
Diffstat (limited to 'trace')
-rw-r--r--trace/Makefile.objs1
-rw-r--r--trace/control.c13
-rw-r--r--trace/control.h7
-rw-r--r--trace/qmp.c75
4 files changed, 76 insertions, 20 deletions
diff --git a/trace/Makefile.objs b/trace/Makefile.objs
index 46de95c1a6..32f7a32ce2 100644
--- a/trace/Makefile.objs
+++ b/trace/Makefile.objs
@@ -144,3 +144,4 @@ util-obj-$(CONFIG_TRACE_SIMPLE) += simple.o generated-tracers.o
util-obj-$(CONFIG_TRACE_FTRACE) += ftrace.o
util-obj-$(CONFIG_TRACE_UST) += generated-ust.o
util-obj-y += control.o
+util-obj-y += qmp.o
diff --git a/trace/control.c b/trace/control.c
index 9631a40eff..0d308011a2 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -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;
diff --git a/trace/control.h b/trace/control.h
index e1ec033705..da9bb6b774 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -149,13 +149,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.
* Corresponds to commandline option "-trace events=...".
diff --git a/trace/qmp.c b/trace/qmp.c
new file mode 100644
index 0000000000..0b19489528
--- /dev/null
+++ b/trace/qmp.c
@@ -0,0 +1,75 @@
+/*
+ * QMP commands for tracing events.
+ *
+ * Copyright (C) 2014 LluĂ­s Vilanova <vilanova@ac.upc.edu>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/typedefs.h"
+#include "qmp-commands.h"
+#include "trace/control.h"
+
+
+TraceEventInfoList *qmp_trace_event_get_state(const char *name, Error **errp)
+{
+ TraceEventInfoList *events = NULL;
+ bool found = false;
+ TraceEvent *ev;
+
+ ev = NULL;
+ while ((ev = trace_event_pattern(name, ev)) != NULL) {
+ TraceEventInfoList *elem = g_new(TraceEventInfoList, 1);
+ elem->value = g_new(TraceEventInfo, 1);
+ elem->value->name = g_strdup(trace_event_get_name(ev));
+ if (!trace_event_get_state_static(ev)) {
+ elem->value->state = TRACE_EVENT_STATE_UNAVAILABLE;
+ } else if (!trace_event_get_state_dynamic(ev)) {
+ elem->value->state = TRACE_EVENT_STATE_DISABLED;
+ } else {
+ elem->value->state = TRACE_EVENT_STATE_ENABLED;
+ }
+ elem->next = events;
+ events = elem;
+ found = true;
+ }
+
+ if (!found && !trace_event_is_pattern(name)) {
+ error_setg(errp, "unknown event \"%s\"", name);
+ }
+
+ return events;
+}
+
+void qmp_trace_event_set_state(const char *name, bool enable,
+ bool has_ignore_unavailable,
+ bool ignore_unavailable, Error **errp)
+{
+ bool found = false;
+ TraceEvent *ev;
+
+ /* Check all selected events are dynamic */
+ ev = NULL;
+ while ((ev = trace_event_pattern(name, ev)) != NULL) {
+ found = true;
+ if (!(has_ignore_unavailable && ignore_unavailable) &&
+ !trace_event_get_state_static(ev)) {
+ error_setg(errp, "cannot set dynamic tracing state for \"%s\"",
+ trace_event_get_name(ev));
+ return;
+ }
+ }
+ if (!found && !trace_event_is_pattern(name)) {
+ error_setg(errp, "unknown event \"%s\"", name);
+ return;
+ }
+
+ /* Apply changes */
+ ev = NULL;
+ while ((ev = trace_event_pattern(name, ev)) != NULL) {
+ if (trace_event_get_state_static(ev)) {
+ trace_event_set_state_dynamic(ev, enable);
+ }
+ }
+}