* [Qemu-devel] [Tracing] [RFC PATCH 0/2] : QMP query Interfaces for tracing
@ 2010-10-14 5:51 Prerna Saxena
2010-10-14 5:56 ` [Qemu-devel] [Tracing] [RFC PATCH 1/2] : Introduce 'query-trace' & 'query-trace-events' interfaces Prerna Saxena
2010-10-14 6:01 ` [Qemu-devel] [Tracing] [RFC PATCH 2/2] : Documentation for QMP interfaces Prerna Saxena
0 siblings, 2 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-10-14 5:51 UTC (permalink / raw)
To: qemu-devel; +Cc: Mahesh, Narayan, Stefan Hajnoczi, Ananth, Luiz Capitulino
This patch set introduces two QMP interfaces for tracing :
* query-trace : to list current contents of trace-buffer
* query-trace-events : to list all available trace-events with their state.
--
Prerna Saxena
Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [Tracing] [RFC PATCH 1/2] : Introduce 'query-trace' & 'query-trace-events' interfaces
2010-10-14 5:51 [Qemu-devel] [Tracing] [RFC PATCH 0/2] : QMP query Interfaces for tracing Prerna Saxena
@ 2010-10-14 5:56 ` Prerna Saxena
2010-10-14 10:03 ` [Qemu-devel] " Stefan Hajnoczi
2010-10-14 6:01 ` [Qemu-devel] [Tracing] [RFC PATCH 2/2] : Documentation for QMP interfaces Prerna Saxena
1 sibling, 1 reply; 5+ messages in thread
From: Prerna Saxena @ 2010-10-14 5:56 UTC (permalink / raw)
To: qemu-devel; +Cc: Mahesh, Ananth Narayan, Stefan Hajnoczi, Luiz Capitulino
[PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
---
monitor.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
simpletrace.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
simpletrace.h | 2 ++
3 files changed, 98 insertions(+), 4 deletions(-)
diff --git a/monitor.c b/monitor.c
index fbb678d..7a150ae 100644
--- a/monitor.c
+++ b/monitor.c
@@ -941,15 +941,33 @@ static void do_info_cpu_stats(Monitor *mon)
#endif
#if defined(CONFIG_SIMPLE_TRACE)
-static void do_info_trace(Monitor *mon)
+static void do_info_trace_print(Monitor *mon)
{
st_print_trace((FILE *)mon, &monitor_fprintf);
}
-static void do_info_trace_events(Monitor *mon)
+static void do_info_trace(Monitor *mon, QObject **ret_data)
+{
+ QList *trace_event_list = NULL;
+
+ st_print_trace_to_qlist(&trace_event_list);
+
+ *ret_data = QOBJECT(trace_event_list);
+}
+
+static void do_info_trace_events_print(Monitor *mon, const QObject *data)
{
st_print_trace_events((FILE *)mon, &monitor_fprintf);
}
+
+static void do_info_trace_events(Monitor *mon, QObject **ret_data)
+{
+ QList *trace_event_list = NULL;
+
+ st_print_trace_events_to_qlist(&trace_event_list);
+
+ *ret_data = QOBJECT(trace_event_list);
+}
#endif
/**
@@ -2606,14 +2624,16 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show current contents of trace buffer",
- .mhandler.info = do_info_trace,
+ .user_print = do_info_trace_print,
+ .mhandler.info_new = do_info_trace,
},
{
.name = "trace-events",
.args_type = "",
.params = "",
.help = "show available trace-events & their state",
- .mhandler.info = do_info_trace_events,
+ .user_print = do_info_trace_events_print,
+ .mhandler.info_new = do_info_trace_events,
},
#endif
{
@@ -2748,6 +2768,24 @@ static const mon_cmd_t qmp_query_cmds[] = {
.mhandler.info_async = do_info_balloon,
.flags = MONITOR_CMD_ASYNC,
},
+#if defined(CONFIG_SIMPLE_TRACE)
+ {
+ .name = "trace",
+ .args_type = "",
+ .params = "",
+ .help = "show current contents of trace buffer",
+ .user_print = do_info_trace_print,
+ .mhandler.info_new = do_info_trace,
+ },
+ {
+ .name = "trace-events",
+ .args_type = "",
+ .params = "",
+ .help = "show available trace-events & their state",
+ .user_print = do_info_trace_events_print,
+ .mhandler.info_new = do_info_trace_events,
+ },
+#endif
{ /* NULL */ },
};
diff --git a/simpletrace.c b/simpletrace.c
index f849e42..d1f66b4 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -220,6 +220,39 @@ void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char
}
}
+void st_print_trace_to_qlist(QList **tlist)
+{
+ QObject *data;
+ unsigned int i;
+
+ if (!tlist || *tlist )
+ return;
+
+ /* NOTE : This assumes trace_list hasnt already been allocated with a QList.
+ * The initialization happens here.
+ */
+ *tlist = qlist_new();
+
+ for (i = 0; i < trace_idx; i++) {
+ data = qobject_from_jsonf("{"
+ " 'Event': %" PRId64 ","
+ " 'arg1': %" PRId64 ","
+ " 'arg2': %" PRId64 ","
+ " 'arg3': %" PRId64 ","
+ " 'arg4': %" PRId64 ","
+ " 'arg5': %" PRId64 ","
+ " 'arg6': %" PRId64
+ "}",
+ trace_buf[i].event, trace_buf[i].x1,
+ trace_buf[i].x2, trace_buf[i].x3,
+ trace_buf[i].x4, trace_buf[i].x5,
+ trace_buf[i].x6);
+ qlist_append_obj(*tlist, data);
+ }
+
+ return;
+}
+
void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
{
unsigned int i;
@@ -230,6 +263,27 @@ void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, cons
}
}
+void st_print_trace_events_to_qlist(QList **tlist)
+{
+ QObject *data;
+ unsigned int i;
+
+ if (!tlist || *tlist )
+ return;
+
+ /* NOTE : This assumes trace_list hasnt already been allocated with a QList.
+ * The initialization happens here.
+ */
+ *tlist = qlist_new();
+
+ for (i = 0; i < NR_TRACE_EVENTS; i++) {
+ data = qobject_from_jsonf("{ 'name': %s, 'eventID': %d, 'state': %d }", trace_list[i].tp_name, i, trace_list[i].state);
+ qlist_append_obj(*tlist, data);
+ }
+
+ return;
+}
+
static TraceEvent* find_trace_event_by_name(const char *tname)
{
unsigned int i;
diff --git a/simpletrace.h b/simpletrace.h
index cf35897..9c1f535 100644
--- a/simpletrace.h
+++ b/simpletrace.h
@@ -14,6 +14,8 @@
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
+#include "qdict.h"
+#include "qjson.h"
typedef uint64_t TraceEventID;
--
1.7.2.2
--
Prerna Saxena
Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [Tracing] [RFC PATCH 2/2] : Documentation for QMP interfaces
2010-10-14 5:51 [Qemu-devel] [Tracing] [RFC PATCH 0/2] : QMP query Interfaces for tracing Prerna Saxena
2010-10-14 5:56 ` [Qemu-devel] [Tracing] [RFC PATCH 1/2] : Introduce 'query-trace' & 'query-trace-events' interfaces Prerna Saxena
@ 2010-10-14 6:01 ` Prerna Saxena
2010-10-14 10:10 ` [Qemu-devel] " Stefan Hajnoczi
1 sibling, 1 reply; 5+ messages in thread
From: Prerna Saxena @ 2010-10-14 6:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Mahesh, Ananth Narayan, Stefan Hajnoczi, Luiz Capitulino
[PATCH 2/2] Add documentation for QMP commands: query-trace & query-trace-events.
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
---
qmp-commands.hx | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 793cf1c..9a48984 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1539,3 +1539,56 @@ Example:
EQMP
+SQMP
+query-trace
+-------------
+
+Show contents of trace buffer.
+
+Returns a set of json-objects containing the following data:
+
+- "Event": Event ID for the trace-event(json-int)
+- "arg1 .. arg6": Arguments logged by the trace-event (json-int)
+
+Example:
+
+-> { "execute": "query-trace" }
+<- {
+ "return":{
+ "Event": 22,
+ "arg6": 0,
+ "arg5": 0,
+ "arg4": 0,
+ "arg3": 0,
+ "arg2": 80,
+ "arg1": 886
+ }
+ }
+
+EQMP
+
+SQMP
+query-trace-events
+------------------
+
+Show all available trace-events & their state.
+
+Returns a set of json-objects containing the following data:
+
+- "name": Name of Trace-event (json-string)
+- "state": State of trace-event [ '0': inactive; '1':active ] (json-int)
+- "eventID": Event ID of Trace-event (json-int)
+
+Example:
+
+-> { "execute": "query-trace-events" }
+<- {
+ "return":{
+ "name": "qemu_malloc",
+ "state": 0,
+ "eventID": 0
+ }
+ }
+
+EQMP
+
--
1.7.2.2
--
Prerna Saxena
Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] Re: [Tracing] [RFC PATCH 1/2] : Introduce 'query-trace' & 'query-trace-events' interfaces
2010-10-14 5:56 ` [Qemu-devel] [Tracing] [RFC PATCH 1/2] : Introduce 'query-trace' & 'query-trace-events' interfaces Prerna Saxena
@ 2010-10-14 10:03 ` Stefan Hajnoczi
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2010-10-14 10:03 UTC (permalink / raw)
To: Prerna Saxena; +Cc: Mahesh, Ananth Narayan, qemu-devel, Luiz Capitulino
On Thu, Oct 14, 2010 at 11:26:04AM +0530, Prerna Saxena wrote:
> [PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events
>
>
> Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
> ---
> monitor.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
> simpletrace.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> simpletrace.h | 2 ++
> 3 files changed, 98 insertions(+), 4 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index fbb678d..7a150ae 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -941,15 +941,33 @@ static void do_info_cpu_stats(Monitor *mon)
> #endif
>
> #if defined(CONFIG_SIMPLE_TRACE)
> -static void do_info_trace(Monitor *mon)
> +static void do_info_trace_print(Monitor *mon)
> {
> st_print_trace((FILE *)mon, &monitor_fprintf);
> }
>
> -static void do_info_trace_events(Monitor *mon)
> +static void do_info_trace(Monitor *mon, QObject **ret_data)
> +{
> + QList *trace_event_list = NULL;
> +
> + st_print_trace_to_qlist(&trace_event_list);
> +
> + *ret_data = QOBJECT(trace_event_list);
> +}
> +
> +static void do_info_trace_events_print(Monitor *mon, const QObject *data)
> {
> st_print_trace_events((FILE *)mon, &monitor_fprintf);
> }
> +
> +static void do_info_trace_events(Monitor *mon, QObject **ret_data)
> +{
> + QList *trace_event_list = NULL;
> +
> + st_print_trace_events_to_qlist(&trace_event_list);
> +
> + *ret_data = QOBJECT(trace_event_list);
> +}
> #endif
>
> /**
> @@ -2606,14 +2624,16 @@ static const mon_cmd_t info_cmds[] = {
> .args_type = "",
> .params = "",
> .help = "show current contents of trace buffer",
> - .mhandler.info = do_info_trace,
> + .user_print = do_info_trace_print,
> + .mhandler.info_new = do_info_trace,
> },
> {
> .name = "trace-events",
> .args_type = "",
> .params = "",
> .help = "show available trace-events & their state",
> - .mhandler.info = do_info_trace_events,
> + .user_print = do_info_trace_events_print,
> + .mhandler.info_new = do_info_trace_events,
> },
> #endif
> {
> @@ -2748,6 +2768,24 @@ static const mon_cmd_t qmp_query_cmds[] = {
> .mhandler.info_async = do_info_balloon,
> .flags = MONITOR_CMD_ASYNC,
> },
> +#if defined(CONFIG_SIMPLE_TRACE)
> + {
> + .name = "trace",
> + .args_type = "",
> + .params = "",
> + .help = "show current contents of trace buffer",
> + .user_print = do_info_trace_print,
> + .mhandler.info_new = do_info_trace,
> + },
> + {
> + .name = "trace-events",
> + .args_type = "",
> + .params = "",
> + .help = "show available trace-events & their state",
> + .user_print = do_info_trace_events_print,
> + .mhandler.info_new = do_info_trace_events,
> + },
> +#endif
> { /* NULL */ },
> };
>
> diff --git a/simpletrace.c b/simpletrace.c
> index f849e42..d1f66b4 100644
> --- a/simpletrace.c
> +++ b/simpletrace.c
> @@ -220,6 +220,39 @@ void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char
> }
> }
>
> +void st_print_trace_to_qlist(QList **tlist)
> +{
> + QObject *data;
> + unsigned int i;
> +
> + if (!tlist || *tlist )
> + return;
This silences bugs. If you want to check these please use asserts.
> +
> + /* NOTE : This assumes trace_list hasnt already been allocated with a QList.
> + * The initialization happens here.
> + */
This should be in a doc comment for this function to make it clear that
tlist will be allocated a new list.
> + *tlist = qlist_new();
> +
> + for (i = 0; i < trace_idx; i++) {
> + data = qobject_from_jsonf("{"
> + " 'Event': %" PRId64 ","
> + " 'arg1': %" PRId64 ","
> + " 'arg2': %" PRId64 ","
> + " 'arg3': %" PRId64 ","
> + " 'arg4': %" PRId64 ","
> + " 'arg5': %" PRId64 ","
> + " 'arg6': %" PRId64
> + "}",
> + trace_buf[i].event, trace_buf[i].x1,
> + trace_buf[i].x2, trace_buf[i].x3,
> + trace_buf[i].x4, trace_buf[i].x5,
> + trace_buf[i].x6);
> + qlist_append_obj(*tlist, data);
> + }
> +
> + return;
Not needed for a void function and not used in QEMU coding style.
> +}
> +
> void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
> {
> unsigned int i;
> @@ -230,6 +263,27 @@ void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, cons
> }
> }
>
> +void st_print_trace_events_to_qlist(QList **tlist)
The same comments apply to this function.
> +{
> + QObject *data;
> + unsigned int i;
> +
> + if (!tlist || *tlist )
> + return;
> +
> + /* NOTE : This assumes trace_list hasnt already been allocated with a QList.
> + * The initialization happens here.
> + */
> + *tlist = qlist_new();
> +
> + for (i = 0; i < NR_TRACE_EVENTS; i++) {
> + data = qobject_from_jsonf("{ 'name': %s, 'eventID': %d, 'state': %d }", trace_list[i].tp_name, i, trace_list[i].state);
> + qlist_append_obj(*tlist, data);
> + }
> +
> + return;
> +}
> +
> static TraceEvent* find_trace_event_by_name(const char *tname)
> {
> unsigned int i;
> diff --git a/simpletrace.h b/simpletrace.h
> index cf35897..9c1f535 100644
> --- a/simpletrace.h
> +++ b/simpletrace.h
> @@ -14,6 +14,8 @@
> #include <stdint.h>
> #include <stdbool.h>
> #include <stdio.h>
> +#include "qdict.h"
> +#include "qjson.h"
Where are the prototypes for st_print_trace_to_qlist() and st_print_trace_events_to_qlist()?
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] Re: [Tracing] [RFC PATCH 2/2] : Documentation for QMP interfaces
2010-10-14 6:01 ` [Qemu-devel] [Tracing] [RFC PATCH 2/2] : Documentation for QMP interfaces Prerna Saxena
@ 2010-10-14 10:10 ` Stefan Hajnoczi
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2010-10-14 10:10 UTC (permalink / raw)
To: Prerna Saxena; +Cc: Mahesh, Ananth Narayan, qemu-devel, Luiz Capitulino
On Thu, Oct 14, 2010 at 11:31:20AM +0530, Prerna Saxena wrote:
> [PATCH 2/2] Add documentation for QMP commands: query-trace & query-trace-events.
>
>
> Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
> ---
> qmp-commands.hx | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 53 insertions(+), 0 deletions(-)
>
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 793cf1c..9a48984 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -1539,3 +1539,56 @@ Example:
>
> EQMP
>
> +SQMP
> +query-trace
> +-------------
> +
> +Show contents of trace buffer.
> +
> +Returns a set of json-objects containing the following data:
> +
> +- "Event": Event ID for the trace-event(json-int)
JSON names are lowercase like the C fields they represent, please use
"event".
> +- "arg1 .. arg6": Arguments logged by the trace-event (json-int)
What about the timestamp_ns field?
> +
> +Example:
> +
> +-> { "execute": "query-trace" }
> +<- {
> + "return":{
> + "Event": 22,
> + "arg6": 0,
> + "arg5": 0,
> + "arg4": 0,
> + "arg3": 0,
> + "arg2": 80,
> + "arg1": 886
> + }
> + }
> +
> +EQMP
> +
> +SQMP
> +query-trace-events
> +------------------
> +
> +Show all available trace-events & their state.
> +
> +Returns a set of json-objects containing the following data:
> +
> +- "name": Name of Trace-event (json-string)
> +- "state": State of trace-event [ '0': inactive; '1':active ] (json-int)
> +- "eventID": Event ID of Trace-event (json-int)
> +
> +Example:
> +
> +-> { "execute": "query-trace-events" }
> +<- {
> + "return":{
> + "name": "qemu_malloc",
> + "state": 0,
> + "eventID": 0
> + }
> + }
> +
> +EQMP
> +
> --
> 1.7.2.2
>
>
>
> --
> Prerna Saxena
>
> Linux Technology Centre,
> IBM Systems and Technology Lab,
> Bangalore, India
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-10-14 10:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-14 5:51 [Qemu-devel] [Tracing] [RFC PATCH 0/2] : QMP query Interfaces for tracing Prerna Saxena
2010-10-14 5:56 ` [Qemu-devel] [Tracing] [RFC PATCH 1/2] : Introduce 'query-trace' & 'query-trace-events' interfaces Prerna Saxena
2010-10-14 10:03 ` [Qemu-devel] " Stefan Hajnoczi
2010-10-14 6:01 ` [Qemu-devel] [Tracing] [RFC PATCH 2/2] : Documentation for QMP interfaces Prerna Saxena
2010-10-14 10:10 ` [Qemu-devel] " Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).