trace: [qmp] Add QAPI/QMP commands to query and control event tracing state
PATCH v2 1/1 trace: [qmp] Add QAPI/QMP commands to query and control event tracing state
Also removes old "trace-event", "trace-file" and "info trace-events" HMP commands.
--- hmp-commands.hx | 35 ----------------------- monitor.c | 61 ---------------------------------------- qapi-schema.json | 3 ++ qmp-commands.hx | 27 ++++++++++++++++++ trace/Makefile.objs | 1 + trace/commands.json | 44 +++++++++++++++++++++++++++++ trace/control.c | 13 --------- trace/control.h | 7 ----- trace/qmp.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ trace/simple.c | 10 +------ trace/simple.h | 3 -- 11 files changed, 154 insertions(+), 127 deletions(-) create mode 100644 trace/commands.json create mode 100644 trace/qmp.c
hmp-commands.hx +0 -35
@@ -269,36 +269,6 @@ Output logs to @var{filename}. ETEXI { - .name = "trace-event", - .args_type = "name:s,option:b", - .params = "name on|off", - .help = "changes status of a specific trace event", - .mhandler.cmd = do_trace_event_set_state, - }, - -STEXI -@item trace-event -@findex trace-event -changes status of a trace event -ETEXI - -#if defined(CONFIG_TRACE_SIMPLE) - { - .name = "trace-file", - .args_type = "op:s?,arg:F?", - .params = "on|off|flush|set [arg]", - .help = "open, close, or flush trace file, or set a new file name", - .mhandler.cmd = do_trace_file, - }, - -STEXI -@item trace-file on|off|flush -@findex trace-file -Open, close, or flush the trace file. If no argument is given, the status of the trace file is displayed. -ETEXI -#endif - - { .name = "log", .args_type = "items:s", .params = "item1[,...]",
@@ -1784,10 +1754,5 @@ show the TPM device ETEXI STEXI -@item info trace-events -show available trace events and their state -ETEXI - -STEXI @end table ETEXI
monitor.c +0 -61
85 lines not on this page · raw message
qapi-schema.json +3 -0
@@ -11,6 +11,9 @@ # QAPI event definitions { 'include': 'qapi/event.json' } +# Tracing commands +{ 'include': 'trace/commands.json' } + ## # LostTickPolicy: #
qmp-commands.hx +27 -0
@@ -3753,5 +3753,32 @@ 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. + +EQMP + + { + .name = "trace-event-set-state", + .args_type = "name:s,state:b,keepgoing:b?", + .mhandler.cmd_new = qmp_marshal_input_trace_event_set_state, + }, + +SQMP +trace-event-set-state +--------------------- + +Set the state of events. 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/commands.json new file +44 -0
44 lines not on this page · raw message
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=...".
trace/qmp.c new file +77 -0
77 lines not on this page · raw message
trace/simple.c +2 -8
@@ -277,7 +277,7 @@ void trace_record_finish(TraceBufferRecord *rec) } } -void st_set_trace_file_enabled (bool enable) +static void st_set_trace_file_enabled (bool enable) {if (enable == !!trace_fp) {return ;/* no change */
@@ -322,7 +322,7 @@ void st_set_trace_file_enabled(bool enable)* @file The trace file name or NULL for the default name-<pid> set at * config time */ -bool st_set_trace_file (const char *file) +static bool st_set_trace_file (const char *file) {st_set_trace_file_enabled (false);
@@ -338,12 +338,6 @@ bool st_set_trace_file(const char *file)return true; } -void st_print_trace_file_status (FILE *stream,int (*stream_printf)(FILE *stream,const char *fmt, ...)) -{ -stream_printf (stream,"Trace file \"%s\" %s.\n" , - trace_file_name, trace_fp ?"on" :"off" ); -} -void st_flush_trace_buffer (void ) {flush_trace_file (true);
trace/simple.h +0 -3
@@ -18,9 +18,6 @@#include "trace/generated-events.h" -void st_print_trace_file_status (FILE *stream,fprintf_function stream_printf); -void st_set_trace_file_enabled (bool enable); -bool st_set_trace_file (const char *file);bool st_init (const char *file);void st_flush_trace_buffer (void );
Quoted 2 lines · Lluís Vilanova
Also removes old "trace-event", "trace-file" and "info trace-events" HMP commands.
We gain the ability to control trace via QMP, but lose the ability to control it via HMP, correct?
Quoted 9 lines
Signed-off-by Lluís Vilanova <[email protected]>--- hmp-commands.hx | 35 ----------------------- monitor.c | 61 ---------------------------------------- qapi-schema.json | 3 ++ qmp-commands.hx | 27 ++++++++++++++++++ trace/Makefile.objs | 1 + trace/commands.json | 44 +++++++++++++++++++++++++++++
There's no precedence for keeping schema bits anywhere but in qapi/. If we decide we want to keep them with their related C parts instead, we should do so consistently, not just for trace.
Quoted 8 lines
trace/control.c | 13 --------- trace/control.h | 7 ----- trace/qmp.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ trace/simple.c | 10 +------ trace/simple.h | 3 -- 11 files changed, 154 insertions(+), 127 deletions(-) create mode 100644 trace/commands.json create mode 100644 trace/qmp.c
[...]
Quoted 6 lines · Markus Armbruster
Quoted 2 lines · Lluís Vilanova
Also removes old "trace-event", "trace-file" and "info trace-events" HMP commands.
We gain the ability to control trace via QMP, but lose the ability to control it via HMP, correct?
Right. I can keep the HMP commands, but doing so requires exposing the internal trace event identifier number in the QMP interface. Also, "trace-file" cannot be implemented on top of the current QMP commands, and is specific to the "simple" tracing backend.
Quoted 10 lines
Quoted 9 lines
Signed-off-by Lluís Vilanova <[email protected]>---
hmp-commands.hx | 35 ----------------------- monitor.c | 61 ---------------------------------------- qapi-schema.json | 3 ++ qmp-commands.hx | 27 ++++++++++++++++++ trace/Makefile.objs | 1 + trace/commands.json | 44 +++++++++++++++++++++++++++++
Quoted 3 lines
There's no precedence for keeping schema bits anywhere but in qapi/. If we decide we want to keep them with their related C parts instead, we should do so consistently, not just for trace.
Ok, I'll move it to qapi.
Thanks,
Lluis
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 · Lluís Vilanova
Quoted 3 lines · Markus Armbruster
Quoted 2 lines · Lluís Vilanova
Also removes old "trace-event", "trace-file" and "info trace-events" HMP commands.
Quoted 7 lines
Quoted 2 lines
We gain the ability to control trace via QMP, but lose the ability to control it via HMP, correct?
Right. I can keep the HMP commands, but doing so requires exposing the internal trace event identifier number in the QMP interface. Also, "trace-file" cannot be implemented on top of the current QMP commands, and is specific to the "simple" tracing backend.
Would rough feature-parity with QMP be feasible with new HMP commands on top of the QMP interfaces, completely ignoring HMP backward compatibility?
[...]
Quoted 10 lines · Markus Armbruster
Quoted 9 lines · Lluís Vilanova
Quoted 6 lines · Markus Armbruster
Quoted 2 lines · Lluís Vilanova
Also removes old "trace-event", "trace-file" and "info trace-events" HMP commands.
We gain the ability to control trace via QMP, but lose the ability to control it via HMP, correct?
Quoted 8 lines
Quoted 4 lines
Right. I can keep the HMP commands, but doing so requires exposing the internal trace event identifier number in the QMP interface. Also, "trace-file" cannot be implemented on top of the current QMP commands, and is specific to the "simple" tracing backend.
Would rough feature-parity with QMP be feasible with new HMP commands on top of the QMP interfaces, completely ignoring HMP backward compatibility?
Except for "trace-file", it would be quite easy, yes. For "trace-file", we can either keep the current HMP implementation, or add new QMP commands to support it (I'd rather devote my time to something else, though).
Thanks,
Lluis
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 20 lines · Lluís Vilanova
Quoted 17 lines · Markus Armbruster
Quoted 16 lines · Lluís Vilanova
Quoted 6 lines · Markus Armbruster
Quoted 2 lines · Lluís Vilanova
Also removes old "trace-event", "trace-file" and "info trace-events" HMP commands.
We gain the ability to control trace via QMP, but lose the ability to control it via HMP, correct?
Right. I can keep the HMP commands, but doing so requires exposing the internal
trace event identifier number in the QMP interface. Also, "trace-file" cannot be
implemented on top of the current QMP commands, and is specific to the "simple"
tracing backend.
Quoted 5 lines
Quoted 3 lines
Would rough feature-parity with QMP be feasible with new HMP commands on top of the QMP interfaces, completely ignoring HMP backward compatibility?
Except for "trace-file", it would be quite easy, yes.
Yes, please!
Quoted 3 lines
For "trace-file", we can
either keep the current HMP implementation, or add new QMP commands to support it (I'd rather devote my time to something else, though).
trace-file is only available with CONFIG_TRACE_SIMPLE. Losing it would be tolerable, I guess. But I'd keep it as is until its maintenance becomes a burden.