qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing
@ 2010-10-18  6:06 Prerna Saxena
  2010-10-18  6:14 ` [Qemu-devel] [Tracing][RFC v3 PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events Prerna Saxena
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-10-18  6:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Mahesh, Anthony Liguori, Ananth Narayan, Stefan Hajnoczi,
	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.

Changelog :
-----------
Changes v2 -> v3 :
- Change declarations of st_print_trace_to_qlist() and 
st_print_trace_events_to_qlist() to return QList*

Changes v1 -> v2 :
- Add 'timestamp' field for query-trace output.
- Misc cleanups.

-- 
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 v3 PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events
  2010-10-18  6:06 [Qemu-devel] [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing Prerna Saxena
@ 2010-10-18  6:14 ` Prerna Saxena
  2010-10-18  6:15 ` [Qemu-devel] [Tracing][RFC v3 PATCH 2/2] Add documentation for QMP commands: " Prerna Saxena
  2010-10-18 14:21 ` [Qemu-devel] Re: [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing Luiz Capitulino
  2 siblings, 0 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-10-18  6:14 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Hajnoczi, Mahesh, Stefan, Luiz Capitulino,
	Ananth Narayan

[PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
---
 monitor.c     |   40 +++++++++++++++++++++++++++++++++++---
 simpletrace.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 simpletrace.h |    4 +++
 3 files changed, 98 insertions(+), 4 deletions(-)

diff --git a/monitor.c b/monitor.c
index fbb678d..41f3477 100644
--- a/monitor.c
+++ b/monitor.c
@@ -941,15 +941,27 @@ 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 = st_print_trace_to_qlist();
+    *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 = st_print_trace_events_to_qlist();
+    *ret_data = QOBJECT(trace_event_list);
+}
 #endif
 
 /**
@@ -2606,14 +2618,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 +2762,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..9d7ec68 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -220,6 +220,43 @@ void st_print_trace(FILE *stream, int (*stream_printf)(FILE *stream, const char
     }
 }
 
+/**
+ * Add the current contents of trace-buffer as a QList.
+ *
+ */
+QList* st_print_trace_to_qlist()
+{
+    QObject *data;
+    QList *tlist;
+    unsigned int i;
+
+    tlist = qlist_new();
+
+    for (i = 0; i < trace_idx; i++) {
+          data = qobject_from_jsonf("{"
+                                    " 'timestamp': %" PRId64 ","
+                                    " 'event': %" PRId64 ","
+                                    " 'arg1': %" PRId64 ","
+                                    " 'arg2': %" PRId64 ","
+                                    " 'arg3': %" PRId64 ","
+                                    " 'arg4': %" PRId64 ","
+                                    " 'arg5': %" PRId64 ","
+                                    " 'arg6': %" PRId64
+                                    "}",
+                                    trace_buf[i].timestamp_ns,
+                                    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 tlist;
+}
+
 void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
 {
     unsigned int i;
@@ -230,6 +267,27 @@ void st_print_trace_events(FILE *stream, int (*stream_printf)(FILE *stream, cons
     }
 }
 
+/**
+ * Add current set of trace-events as a QList.
+ *
+ */
+QList* st_print_trace_events_to_qlist()
+{
+    QObject *data;
+    QList *tlist;
+    unsigned int i;
+
+    tlist = qlist_new();
+
+    for (i = 0; i < NR_TRACE_EVENTS; i++) {
+          data = qobject_from_jsonf("{ 'name': %s, 'event-id': %d, 'state': %d}                                    ", trace_list[i].tp_name, i,
+                                    trace_list[i].state);
+          qlist_append_obj(tlist, data);
+    }
+
+    return tlist;
+}
+
 static TraceEvent* find_trace_event_by_name(const char *tname)
 {
     unsigned int i;
diff --git a/simpletrace.h b/simpletrace.h
index cf35897..8727728 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;
 
@@ -36,5 +38,7 @@ void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *stream,
 void st_set_trace_file_enabled(bool enable);
 bool st_set_trace_file(const char *file);
 void st_flush_trace_buffer(void);
+QList* st_print_trace_to_qlist();
+QList* st_print_trace_events_to_qlist();
 
 #endif /* SIMPLETRACE_H */
-- 
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 v3 PATCH 2/2] Add documentation for QMP commands: query-trace & query-trace-events.
  2010-10-18  6:06 [Qemu-devel] [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing Prerna Saxena
  2010-10-18  6:14 ` [Qemu-devel] [Tracing][RFC v3 PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events Prerna Saxena
@ 2010-10-18  6:15 ` Prerna Saxena
  2010-10-18 14:21 ` [Qemu-devel] Re: [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing Luiz Capitulino
  2 siblings, 0 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-10-18  6:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Hajnoczi, Mahesh, Stefan, Luiz Capitulino,
	Ananth Narayan

[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 |   71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/qmp-commands.hx b/qmp-commands.hx
index 793cf1c..fefc93d 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1539,3 +1539,74 @@ 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)
+- "timestamp": trace timestamp (json-int)
+- "arg1 .. arg6": Arguments logged by the trace-event (json-int)
+
+Example:
+
+-> { "execute": "query-trace" }
+<- {
+      "return":{
+         "event": 22,
+         "timestamp": 129456235912365,
+         "arg1": 886
+         "arg2": 80,
+         "arg3": 0,
+         "arg4": 0,
+         "arg5": 0,
+         "arg6": 0,
+       },
+       {
+         "event": 22,
+         "timestamp": 129456235973407,
+         "arg1": 886,
+         "arg2": 80,
+         "arg3": 0,
+         "arg4": 0,
+         "arg5": 0,
+         "arg6": 0
+       },
+       ...
+   }
+
+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)
+- "event-id": Event ID of Trace-event (json-int)
+- "state": State of trace-event [ '0': inactive; '1':active  ] (json-int)
+
+Example:
+
+-> { "execute": "query-trace-events" }
+<- {
+      "return":{
+         "name": "qemu_malloc",
+         "event-id": 0
+         "state": 0,
+      },
+      {
+         "name": "qemu_realloc",
+         "event-id": 1,
+         "state": 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 v3 PATCH 0/2] QMP Query interfaces for tracing
  2010-10-18  6:06 [Qemu-devel] [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing Prerna Saxena
  2010-10-18  6:14 ` [Qemu-devel] [Tracing][RFC v3 PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events Prerna Saxena
  2010-10-18  6:15 ` [Qemu-devel] [Tracing][RFC v3 PATCH 2/2] Add documentation for QMP commands: " Prerna Saxena
@ 2010-10-18 14:21 ` Luiz Capitulino
  2010-10-19  5:16   ` Prerna Saxena
  2 siblings, 1 reply; 5+ messages in thread
From: Luiz Capitulino @ 2010-10-18 14:21 UTC (permalink / raw)
  To: Prerna Saxena
  Cc: Mahesh, Anthony Liguori, Ananth Narayan, qemu-devel,
	Stefan Hajnoczi

On Mon, 18 Oct 2010 11:36:55 +0530
Prerna Saxena <prerna@linux.vnet.ibm.com> wrote:

> 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.

This is in my to-review queue, but it's going to take a few days, because
I have to take a deeper look at the tracing feature to be able to review it.

Two initial questions:

 o This is labeled as an RFC, but you're versioning it. Should this be
   considered for inclusion?

 o Is this really useful w/o being able to set new traces?

> 
> Changelog :
> -----------
> Changes v2 -> v3 :
> - Change declarations of st_print_trace_to_qlist() and 
> st_print_trace_events_to_qlist() to return QList*
> 
> Changes v1 -> v2 :
> - Add 'timestamp' field for query-trace output.
> - Misc cleanups.
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] Re: [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing
  2010-10-18 14:21 ` [Qemu-devel] Re: [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing Luiz Capitulino
@ 2010-10-19  5:16   ` Prerna Saxena
  0 siblings, 0 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-10-19  5:16 UTC (permalink / raw)
  To: Luiz Capitulino
  Cc: Mahesh, Anthony Liguori, Ananth Narayan, qemu-devel,
	Stefan Hajnoczi

On 10/18/2010 07:51 PM, Luiz Capitulino wrote:
> On Mon, 18 Oct 2010 11:36:55 +0530
> Prerna Saxena<prerna@linux.vnet.ibm.com>  wrote:
>
>> 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.
>
> This is in my to-review queue, but it's going to take a few days, because
> I have to take a deeper look at the tracing feature to be able to review it.
>

Thanks for looking..I'd look forward to your comments :-)

> Two initial questions:
>
>   o This is labeled as an RFC, but you're versioning it. Should this be
>     considered for inclusion?

I'm sending out a new version with some enhancements shortly -- for 
inclusion.

>
>   o Is this really useful w/o being able to set new traces?
>

I'm working on that as well. The query commands are the earliest 
interfaces to be implemented. I will be adding interfaces to toggle the 
state of trace-events, set a new trace-file, etc.

>>
>> Changelog :
>> -----------
>> Changes v2 ->  v3 :
>> - Change declarations of st_print_trace_to_qlist() and
>> st_print_trace_events_to_qlist() to return QList*
>>
>> Changes v1 ->  v2 :
>> - Add 'timestamp' field for query-trace output.
>> - Misc cleanups.
>>
>

Thanks,
-- 
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-19  5:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-18  6:06 [Qemu-devel] [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing Prerna Saxena
2010-10-18  6:14 ` [Qemu-devel] [Tracing][RFC v3 PATCH 1/2] Introduce QMP interfaces : query-trace & query-trace-events Prerna Saxena
2010-10-18  6:15 ` [Qemu-devel] [Tracing][RFC v3 PATCH 2/2] Add documentation for QMP commands: " Prerna Saxena
2010-10-18 14:21 ` [Qemu-devel] Re: [Tracing][RFC v3 PATCH 0/2] QMP Query interfaces for tracing Luiz Capitulino
2010-10-19  5:16   ` Prerna Saxena

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).