trace: Trace control commands
v4 cover trace: Trace control commands
Adds QAPI/QMP commands to control tracing events, and reimplements some of the related HMP commands on top.
NOTE: The "trace-event-set-state" command uses a bool 'enable' argument instead
of an enum 'state'. I'm still not sure if an enum is better than the two separate booleans.
---
Changes in v4:
* Split QAPI/QMP and HMP changes into separate patches.
* Add copyright information in QAPI file (Eric Blake).
* Replace event state booleans with an enum (Eric Blake).
* Document pattern type for argument "name" (Eric Blake).
* Other documentation improvements (Markus Armbruster).
* Change "keepgoing" to "ignore-unavailable" (Markus Armbruster).
* Add examples in QMP command definition file (Eric Blake).
* Propagate QMP errors to HMP (Markus Armbruster, Stefan Hajnoczi).
* Remove trailing newlines when using error_setg (Stefan Hajnoczi).
* Avoid multiple invocations of error_setg (Stefan Hajnoczi).
* Various cosmetic changes (Markus Armbruster).
Lluís Vilanova (2):
trace: [qmp] Add commands to query and control event tracing state
trace: [hmp] Reimplement "trace-event" and "info trace-events" using QMP
monitor.c | 27 ++++++++++-------- qapi-schema.json | 3 ++ qapi/trace.json | 65 ++++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 35 ++++++++++++++++++++++++ trace/Makefile.objs | 1 + trace/control.c | 13 --------- trace/control.h | 7 ----- trace/qmp.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 193 insertions(+), 33 deletions(-) create mode 100644 qapi/trace.json create mode 100644 trace/qmp.c
To: [email protected]
Cc: Michael Roth <[email protected]>
Cc: Markus Armbruster <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>
Cc: Luiz Capitulino <[email protected]>
PATCH v4 1/2 trace: [qmp] Add commands to query and control event tracing state
--- qapi-schema.json | 3 ++ qapi/trace.json | 65 ++++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 35 ++++++++++++++++++++++++ trace/Makefile.objs | 1 + trace/qmp.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 qapi/trace.json create mode 100644 trace/qmp.c
qapi-schema.json +3 -0
@@ -11,6 +11,9 @@ # QAPI event definitions { 'include': 'qapi/event.json' } +# Tracing commands +{ 'include': 'qapi/trace.json' } + ## # LostTickPolicy: #
qapi/trace.json new file +65 -0
65 lines not on this page · raw message
qmp-commands.hx +35 -0
@@ -3753,5 +3753,40 @@ Example: -> { "execute": "rtc-reset-reinjection" } <- { "return": {} } +EQMP + + { + .name = "trace-event-get-state", + .args_type = "name:s", + .mhandler.cmd_new = qmp_marshal_input_trace_event_get_state, + }, + +SQMP +trace-event-get-state +--------------------- + +Query the state of events. + +Example: + +-> { "execute": "trace-event-get-state", "arguments": { "name": "qemu_memalign" } } +<- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] } +EQMP + + { + .name = "trace-event-set-state", + .args_type = "name:s,enable:b,ignore-unavailable:b?", + .mhandler.cmd_new = qmp_marshal_input_trace_event_set_state, + }, +SQMP +trace-event-set-state +--------------------- + +Set the state of events. + +Example: + +-> { "execute": "trace-event-set-state", "arguments": { "name": "qemu_memalign", "enable": "true" } } +<- { "return": {} } EQMP
trace/Makefile.objs +1 -0
@@ -145,3 +145,4 @@ util-obj-$(CONFIG_TRACE_FTRACE) += ftrace.o util-obj-$(CONFIG_TRACE_UST) += generated-ust.o util-obj-y += control.o util-obj-y += generated-tracers.o +util-obj-y += qmp.o
trace/qmp.c new file +75 -0
75 lines not on this page · raw message
Re: [Qemu-devel] [PATCH v4 1/2] trace: [qmp] Add commands to query and control event tracing state
Quoted 11 lines · Lluís Vilanova
Signed-off-by Lluís Vilanova <[email protected]>--- qapi-schema.json | 3 ++ qapi/trace.json | 65 ++++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 35 ++++++++++++++++++++++++ trace/Makefile.objs | 1 + trace/qmp.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 qapi/trace.json create mode 100644 trace/qmp.c
qapi/trace.json line 60
Quoted 8 lines
qapi/trace.json new file +8
-0+## +# @trace-event-set-state: +# +# Set the dynamic tracing state of events. +# +# @name: Event name pattern (case-sensitive glob). +# @enable: Whether to enable tracing. +# @ignore-unavailable: #optional Do not match unavailable events with @name.
Would be nice to state that this bool defaults to false (at least, that's my assumption).
qmp-commands.hx Example: · line 3773
Quoted 7 lines
qmp-commands.hx +7
-0+ +Query the state of events. + +Example: + +-> { "execute": "trace-event-get-state", "arguments": { "name": "qemu_memalign" } } +<- { "return": [ { "name": "qemu_memalign", "state": "disabled" } ] }
It would be nice to use a glob in the "name" of the example, and show a multi-element array as the result.
Those changes can be done in a followup patch, since Stefan has already queued this patch.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH v4 2/2 trace: [hmp] Reimplement "trace-event" and "info trace-events" using QMP
In reply to Lluís Vilanova--- monitor.c | 27 ++++++++++++++------------- trace/control.c | 13 ------------- trace/control.h | 7 ------- 3 files changed, 14 insertions(+), 33 deletions(-)
monitor.c +14 -13
@@ -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); } }
@@ -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,
trace/control.c +0 -13
@@ -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;
trace/control.h +0 -7
@@ -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=...".
Quoted 2 lines · Lluís Vilanova
Adds QAPI/QMP commands to control tracing events, and reimplements some of the related HMP commands on top.
Ping.
Thanks,
Lluis
Quoted 44 lines
NOTE: The "trace-event-set-state" command uses a bool 'enable' argument instead
of an enum 'state'. I'm still not sure if an enum is better than the two separate booleans.Signed-off-by Lluís Vilanova <[email protected]>---
Changes in v4:
* Split QAPI/QMP and HMP changes into separate patches.
* Add copyright information in QAPI file (Eric Blake).
* Replace event state booleans with an enum (Eric Blake).
* Document pattern type for argument "name" (Eric Blake).
* Other documentation improvements (Markus Armbruster).
* Change "keepgoing" to "ignore-unavailable" (Markus Armbruster).
* Add examples in QMP command definition file (Eric Blake).
* Propagate QMP errors to HMP (Markus Armbruster, Stefan Hajnoczi).
* Remove trailing newlines when usingerror_setg(Stefan Hajnoczi).
* Avoid multiple invocations oferror_setg(Stefan Hajnoczi).
* Various cosmetic changes (Markus Armbruster).Lluís Vilanova (2):
trace: [qmp] Add commands to query and control event tracing state
trace: [hmp] Reimplement "trace-event" and "info trace-events" using QMPmonitor.c | 27 ++++++++++-------- qapi-schema.json | 3 ++ qapi/trace.json | 65 ++++++++++++++++++++++++++++++++++++++++++++ qmp-commands.hx | 35 ++++++++++++++++++++++++ trace/Makefile.objs | 1 + trace/control.c | 13 --------- trace/control.h | 7 ----- trace/qmp.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 193 insertions(+), 33 deletions(-) create mode 100644 qapi/trace.json create mode 100644 trace/qmp.cTo: [email protected]
Cc: Michael Roth <[email protected]>
Cc: Markus Armbruster <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>
Cc: Luiz Capitulino <[email protected]>
Signature · 4 lines
"And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth
Quoted 6 lines · On Mon, 08 Sep 2014 15:03:41 -0500 Lluís Vilanova <[email protected]> wrote:
Quoted 2 lines · Lluís Vilanova
Adds QAPI/QMP commands to control tracing events, and reimplements some of the related HMP commands on top.
Ping.
I need reviewers. Stefan and Eric are obvious candidates.
Stefan Hajnoczi
AppliedQuoted 12 lines · Lluís Vilanova
Adds QAPI/QMP commands to control tracing events, and reimplements some of the related HMP commands on top.
NOTE: The "trace-event-set-state" command uses a bool 'enable' argument instead
of an enum 'state'. I'm still not sure if an enum is better than the two separate booleans.Signed-off-by Lluís Vilanova <[email protected]>---
Changes in v4:
Quoted 11 lines
* Split QAPI/QMP and HMP changes into separate patches.
* Add copyright information in QAPI file (Eric Blake).
* Replace event state booleans with an enum (Eric Blake).
* Document pattern type for argument "name" (Eric Blake).
* Other documentation improvements (Markus Armbruster).
* Change "keepgoing" to "ignore-unavailable" (Markus Armbruster).
* Add examples in QMP command definition file (Eric Blake).
* Propagate QMP errors to HMP (Markus Armbruster, Stefan Hajnoczi).
* Remove trailing newlines when usingerror_setg(Stefan Hajnoczi).
* Avoid multiple invocations oferror_setg(Stefan Hajnoczi).
* Various cosmetic changes (Markus Armbruster).
Sorry for the long wait. I am merging it now.
The only thing I wonder about is adding trace/qmp.o to util-obj-y. But I've built QEMU from scratch also for Windows and the build completes successfully. I was worried that a utility like qemu-img might not have the necessary headers or objects for QMP code but it seems to work.
If there are issues we can still fix it later in the 2.2 release cycle.
Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing
Stefan