Skip to contentSkip to conversation

QMP Query interfaces for tracing

PATCH In review Prerna Saxena 3 participants 9 messages Oct 19, 2010 – Oct 21, 2010

lore
Share & tools
lore
#0 lore raw

v4 cover QMP Query interfaces for tracing

This patch set introduces three QMP query interfaces for tracing :

* query-trace : to list current contents of trace-buffer
* query-trace-events : to list all available trace-events with their state.
* query-trace-file : to list currently set trace-file with its status.

Changelog :
-----------
Changes v3 -> v4 :
- Add 'query-trace-file' interface to query currently active trace-file.
- Cleanup.

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.

Signature · 5 lines
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
#1 lore raw

PATCH v4 1/2 Introduce QMP interfaces

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

---
 monitor.c     |   53 ++++++++++++++++++++++++++++++++++++++++---
 simpletrace.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 simpletrace.h |    5 ++++
 3 files changed, 123 insertions(+), 4 deletions(-)
monitor.c +49 -4
index 260cc02..c7e1f53 100644
@@ -578,6 +578,11 @@ static void do_trace_file(Monitor *mon, const QDict *qdict)
         help_cmd(mon, "trace-file");
     }
 }
+
+static void do_info_trace_file_to_qmp(Monitor *mon, QObject **ret_data)
+{
+    *ret_data = st_print_file_to_qobject();
+}
 #endif
 
 static void user_monitor_complete(void *opaque, QObject *ret_data)
@@ -945,15 +950,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, const QObject *data)
 {
     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
 
 /**
@@ -2610,14 +2627,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
     {
@@ -2752,6 +2771,32 @@ 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,
+    },
+    {
+        .name       = "trace-file",
+        .args_type  = "",
+        .params     = "",
+        .help       = "show currently active trace output file and its status",
+        .user_print = monitor_user_noop,
+        .mhandler.info_new = do_info_trace_file_to_qmp,
+    },
+#endif
     { /* NULL */ },
 };
 
simpletrace.c +69 -0

81 lines not on this page · raw message

simpletrace.h +5 -0
index 72614ec..76104b0 100644
@@ -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,8 @@ 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(void);
+QList* st_print_trace_events_to_qlist(void);
+QObject* st_print_file_to_qobject(void);
 
 #endif /* SIMPLETRACE_H */
Signature · 10 lines
1.7.2.2



-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
#3 lore raw

PATCH v4 2/2 Add documentation for QMP interfaces

In reply to Prerna Saxena

[PATCH 2/2] Add documentation for QMP commands:
- query-trace
- query-trace-events
- query-trace-file.

---
 qmp-commands.hx |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 94 insertions(+), 0 deletions(-)
qmp-commands.hx +94 -0
index 793cf1c..bc79b55 100644
@@ -1539,3 +1539,97 @@ 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
+
+SQMP
+query-trace-file
+----------------
+
+Display currently set trace file name and its status.
+
+Returns a set of json-objects containing the following data:
+
+- "trace-file": Name of Trace-file (json-string)
+- "status": State of trace-event [ '0': disabled; '1':enabled  ] (json-int)
+
+Example:
+
+-> { "execute": "query-trace-file" }
+<- {
+      "return":{
+         "trace-file": "trace-26609",
+         "status": 1
+      }
+   }
+
+EQMP
Signature · 10 lines
1.7.2.2



-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
Acked-by on v4 1/2
#2 lore raw

[Qemu-devel] Re: [Tracing][v4 PATCH 1/2] Introduce QMP interfaces

In reply to Prerna Saxena
Quoted 6 lines · Prerna Saxena

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

Quoted 6 lines
---
 monitor.c     |   53 ++++++++++++++++++++++++++++++++++++++++---
 simpletrace.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 simpletrace.h |    5 ++++
 3 files changed, 123 insertions(+), 4 deletions(-)
Acked-by on v4 2/2
#4 lore raw

[Qemu-devel] Re: [Tracing][v4 PATCH 2/2] Add documentation for QMP interfaces

In reply to Prerna Saxena
Quoted 10 lines · Prerna Saxena

[PATCH 2/2] Add documentation for QMP commands:
- query-trace
- query-trace-events
- query-trace-file.

---
 qmp-commands.hx |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 94 insertions(+), 0 deletions(-)
#5 lore raw

Re: [Qemu-devel] [Tracing][v4 PATCH 2/2] Add documentation for QMP interfaces

In reply to Prerna Saxena
Quoted 6 lines · Prerna Saxena

[PATCH 2/2] Add documentation for QMP commands:
- query-trace
- query-trace-events
- query-trace-file.

I've been trying ways to avoid building this documentation for other trace backends ( since these commands are only available with the 'simple' backend ). However, looks like hxtool blindly copies text between SQMP and EQMP. I can only think of making hxtool a wee bit intelligent to be able to parse CONFIG_* options and build documentation accordingly. Is there a workaround I'm missing ?

Signature · 5 lines
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
#6 lore raw

[Qemu-devel] Re: [Tracing][v4 PATCH 2/2] Add documentation for QMP interfaces

In reply to Prerna Saxena
Quoted 4 lines · On Tue, 19 Oct 2010 11:57:50 +0530 Prerna Saxena <[email protected]>…

[PATCH 2/2] Add documentation for QMP commands:
- query-trace
- query-trace-events
- query-trace-file.

Please, split this. Each command should be in a separate patch.

Quoted 12 lines
---
 qmp-commands.hx |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 94 insertions(+), 0 deletions(-)
qmp-commands.hx +0 -0
index 793cf1c..bc79b55 100644

qmp-commands.hx Example: · line 1544

Quoted 6 lines
qmp-commands.hx +3 -0
@@ -1539,3 +1539,97 @@ Example:
 
 EQMP
 
+SQMP
+query-trace
+-------------

It's recommended to first send documentation patches when adding new QMP commands, it can be catastrophic to do both at the same time.

So, I'll ignore the code for now and discuss the interface only.

My main question is: What are the expected use cases for this interface in the perspective of a QMP client?

I can think of two:

1. Enabling/Disabling trace points (eg. from a GUI)
2. Get trace data to generate trace output or do some kind of analysis

If we're only interested in 1, then we don't need query-trace and if we do need query-trace then we'll have to rethink some things as it can be automatically flushed.

qmp-commands.hx Example: · line 1548

Quoted 4 lines
qmp-commands.hx +4 -0
+
+Show contents of trace buffer.
+
+Returns a set of json-objects containing the following data:

Looks like you return a json-array of json-objects, is that correct?

qmp-commands.hx Example: · line 1550

Quoted 2 lines
qmp-commands.hx +2 -0
+
+- "event": Event ID for the trace-event(json-int)

Maybe this should be called event_id or just id.

qmp-commands.hx Example: · line 1551

Quoted 1 line
qmp-commands.hx +1 -0
+- "timestamp": trace timestamp (json-int)

Unit?

qmp-commands.hx Example: · line 1552

Quoted 1 line
qmp-commands.hx +1 -0
+- "arg1 .. arg6": Arguments logged by the trace-event (json-int)

Are they positional or named arguments?

If they are positional, you should use a json-array, if we have the argument name, then we could be nicer and have a json-object of arguments.

Quoted 17 lines
qmp-commands.hx +17 -0
+
+Example:
+
+-> { "execute": "query-trace" }
+<- {
+      "return":{
+         "event": 22,
+         "timestamp": 129456235912365,
+         "arg1": 886
+         "arg2": 80,
+         "arg3": 0,
+         "arg4": 0,
+         "arg5": 0,
+         "arg6": 0,
+       },
+       {
+         "event": 22,

qmp-commands.hx Example: · line 1579

Quoted 10 lines
qmp-commands.hx +10 -0
+         "timestamp": 129456235973407,
+         "arg1": 886,
+         "arg2": 80,
+         "arg3": 0,
+         "arg4": 0,
+         "arg5": 0,
+         "arg6": 0
+       },
+       ...
+   }

The example above is invalid json.

qmp-commands.hx Example: · line 1589

Quoted 10 lines
qmp-commands.hx +10 -0
+
+EQMP
+
+SQMP
+query-trace-events
+------------------
+
+Show all available trace-events & their state.
+
+Returns a set of json-objects containing the following data:

Again, I believe you want to return a json-array of json-objects.

qmp-commands.hx Example: · line 1592

Quoted 3 lines
qmp-commands.hx +3 -0
+
+- "name": Name of Trace-event (json-string)
+- "event-id": Event ID of Trace-event (json-int)

query-trace's key is called event, we should use either event_id or just id (I think I prefer the former).

qmp-commands.hx Example: · line 1593

Quoted 1 line
qmp-commands.hx +1 -0
+- "state": State of trace-event [ '0': inactive; '1':active  ] (json-int)

This should be a json-bool.

Quoted 7 lines
qmp-commands.hx +7 -0
+
+Example:
+
+-> { "execute": "query-trace-events" }
+<- {
+      "return":{
+         "name": "qemu_malloc",

qmp-commands.hx Example: · line 1610

Quoted 10 lines
qmp-commands.hx +10 -0
+         "event-id": 0
+         "state": 0,
+      },
+      {
+         "name": "qemu_realloc",
+         "event-id": 1,
+         "state": 0
+      },
+      ...
+   }

This also invalid json.

qmp-commands.hx Example: · line 1620

Quoted 10 lines
qmp-commands.hx +10 -0
+
+EQMP
+
+SQMP
+query-trace-file
+----------------
+
+Display currently set trace file name and its status.
+
+Returns a set of json-objects containing the following data:

This is actually just one json-object.

qmp-commands.hx Example: · line 1622

Quoted 2 lines
qmp-commands.hx +2 -0
+
+- "trace-file": Name of Trace-file (json-string)

Name or path?

qmp-commands.hx Example: · line 1623

Quoted 1 line
qmp-commands.hx +1 -0
+- "status": State of trace-event [ '0': disabled; '1':enabled  ] (json-int)

This should be a json bool called 'enabled' or 'disabled', but what happens when a file is not defined?

Quoted 12 lines
qmp-commands.hx +12 -0
+
+Example:
+
+-> { "execute": "query-trace-file" }
+<- {
+      "return":{
+         "trace-file": "trace-26609",
+         "status": 1
+      }
+   }
+
+EQMP
#7 lore raw

[Qemu-devel] Re: [Tracing][v4 PATCH 2/2] Add documentation for QMP interfaces

Hi Luiz,
Thanks for your feedback.

Quoted 23 lines · Luiz Capitulino
Quoted 4 lines · On Tue, 19 Oct 2010 11:57:50 +0530 Prerna Saxena<[email protected]>…

[PATCH 2/2] Add documentation for QMP commands:
- query-trace
- query-trace-events
- query-trace-file.

Please, split this. Each command should be in a separate patch.

Quoted 13 lines
---
  qmp-commands.hx |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 94 insertions(+), 0 deletions(-)
qmp-commands.hx +0 -0
index 793cf1c..bc79b55 100644
@@ -1539,3 +1539,97 @@ Example:
 
Quoted 9 lines

qmp-commands.hx Example: · line 1544

Quoted 5 lines
qmp-commands.hx +3 -0
  EQMP
 
+SQMP
+query-trace
+-------------

It's recommended to first send documentation patches when adding new QMP commands, it can be catastrophic to do both at the same time.

Right. I'm posting a set of separate set of documentation patches, where we can discuss the interfaces individually.

Quoted 5 lines

So, I'll ignore the code for now and discuss the interface only.

My main question is: What are the expected use cases for this interface in the perspective of a QMP client?

Quoted 9 lines

I can think of two:

1. Enabling/Disabling trace points (eg. from a GUI)
2. Get trace data to generate trace output or do some kind of analysis

If we're only interested in 1, then we don't need query-trace and if we do need query-trace then we'll have to rethink some things as it can be automatically flushed.

At present, qemu has all trace-events disabled at build-time, by default. The trace-events of interest are dynamically enabled using the human monitor at run time. '1' is useful to have, so that a QMP client can do the same.

The 'query-trace' interface simply displays the current contents of trace-buffer before they are flushed to disk.(equivalent to the 'info trace' HMP command )

To enabled logged traces to be forcibly flushed, HMP has a command : (qemu)trace-file flush
I'm still working on the QMP interface for the same. ( I'll cover the proposed QMP interface in my documentation patchset that I'll be sending out shortly.)

Quoted 7 lines

qmp-commands.hx Example: · line 1548

Quoted 4 lines
qmp-commands.hx +4 -0
+
+Show contents of trace buffer.
+
+Returns a set of json-objects containing the following data:

Looks like you return a json-array of json-objects, is that correct?

Yes.

Quoted 5 lines

qmp-commands.hx Example: · line 1550

Quoted 2 lines
qmp-commands.hx +2 -0
+
+- "event": Event ID for the trace-event(json-int)

Maybe this should be called event_id or just id.

I've renamed it to event_id for next patch.

Quoted 3 lines

qmp-commands.hx Example: · line 1551

Quoted 1 line
qmp-commands.hx +1 -0
+- "timestamp": trace timestamp (json-int)

Unit?

ns. I've corrected the description for the upcoming patchset.

Quoted 8 lines

qmp-commands.hx Example: · line 1552

Quoted 2 lines
qmp-commands.hx +1 -0
+- "arg1 .. arg6": Arguments logged by the trace-event (json-int)

Are they positional or named arguments?

If they are positional, you should use a json-array, if we have the argument name, then we could be nicer and have a json-object of arguments.

These are keyword arguments. I have changed the definition to have these enclosed in a QMP object for the next patchset version.

Quoted 21 lines
Quoted 21 lines
qmp-commands.hx +21 -0
+
+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,
Quoted 8 lines

qmp-commands.hx Example: · line 1579

Quoted 6 lines
qmp-commands.hx +6 -0
+         "arg4": 0,
+         "arg5": 0,
+         "arg6": 0
+       },
+       ...
+   }

The example above is invalid json.

I'm guessing this is invalid because it could be denoted as an array of objects ? Corrected in upcoming patchset.

Quoted 13 lines

qmp-commands.hx Example: · line 1589

Quoted 11 lines
qmp-commands.hx +10 -0
+
+EQMP
+
+SQMP
+query-trace-events
+------------------
+
+Show all available trace-events&  their state.
+
+Returns a set of json-objects containing the following data:

Again, I believe you want to return a json-array of json-objects.

Agree, corrected this for the documentation patchset.

Quoted 8 lines

qmp-commands.hx Example: · line 1592

Quoted 4 lines
qmp-commands.hx +3 -0
+
+- "name": Name of Trace-event (json-string)
+- "event-id": Event ID of Trace-event (json-int)

query-trace's key is called event, we should use either event_id or just id (I think I prefer the former).

Renamed to event_id.

Quoted 4 lines

qmp-commands.hx Example: · line 1593

Quoted 1 line
qmp-commands.hx +1 -0
+- "state": State of trace-event [ '0': inactive; '1':active  ] (json-int)

This should be a json-bool.

Done.

Quoted 11 lines
Quoted 11 lines
qmp-commands.hx +11 -0
+
+Example:
+
+->  { "execute": "query-trace-events" }
+<- {
+      "return":{
+         "name": "qemu_malloc",
+         "event-id": 0
+         "state": 0,
+      },
+      {
Quoted 9 lines

qmp-commands.hx Example: · line 1610

Quoted 6 lines
qmp-commands.hx +6 -0
+         "name": "qemu_realloc",
+         "event-id": 1,
+         "state": 0
+      },
+      ...
+   }

This also invalid json.

Again, I'm guessing the reason it is invalid that it ought to be an array. Changed for next patches.

Quoted 4 lines
Quoted 4 lines
qmp-commands.hx +4 -0
+
+EQMP
+
+SQMP
Quoted 9 lines

qmp-commands.hx Example: · line 1620

Quoted 6 lines
qmp-commands.hx +6 -0
+query-trace-file
+----------------
+
+Display currently set trace file name and its status.
+
+Returns a set of json-objects containing the following data:

This is actually just one json-object.

Oops, typo. Changed !

Quoted 5 lines

qmp-commands.hx Example: · line 1622

Quoted 2 lines
qmp-commands.hx +2 -0
+
+- "trace-file": Name of Trace-file (json-string)

Name or path?

This ought to display full path -- changed for next patch set.

Quoted 5 lines

qmp-commands.hx Example: · line 1623

Quoted 1 line
qmp-commands.hx +1 -0
+- "status": State of trace-event [ '0': disabled; '1':enabled  ] (json-int)

This should be a json bool called 'enabled' or 'disabled', but what happens when a file is not defined?

Changed type to json bool.
The trace infrastructure sets the trace-output file to trace-<PID> ( created in current dir) if no explicit trace-file is specified at startup. (Users can also change the default trace-file at runtime using the hmp command 'trace-file set FILE' I'll be covering QMP interface for the same in the upcoming patchset. )

Quoted 13 lines
Quoted 12 lines
qmp-commands.hx +12 -0
+
+Example:
+
+->  { "execute": "query-trace-file" }
+<- {
+      "return":{
+         "trace-file": "trace-26609",
+         "status": 1
+      }
+   }
+
+EQMP
Signature · 5 lines
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
#8 lore raw

[Qemu-devel] Re: [Tracing][v4 PATCH 2/2] Add documentation for QMP interfaces

Quoted 55 lines · On Thu, 21 Oct 2010 12:21:46 +0530 Prerna Saxena <[email protected]>…

Hi Luiz,
Thanks for your feedback.

Quoted 23 lines · Luiz Capitulino
Quoted 4 lines · On Tue, 19 Oct 2010 11:57:50 +0530 Prerna Saxena<[email protected]>…

[PATCH 2/2] Add documentation for QMP commands:
- query-trace
- query-trace-events
- query-trace-file.

Please, split this. Each command should be in a separate patch.

Quoted 13 lines
---
  qmp-commands.hx |   94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 94 insertions(+), 0 deletions(-)
qmp-commands.hx +0 -0
index 793cf1c..bc79b55 100644
@@ -1539,3 +1539,97 @@ Example:
 
Quoted 9 lines

qmp-commands.hx Example: · line 1544

Quoted 5 lines
qmp-commands.hx +3 -0
  EQMP
 
+SQMP
+query-trace
+-------------

It's recommended to first send documentation patches when adding new QMP commands, it can be catastrophic to do both at the same time.

Right. I'm posting a set of separate set of documentation patches, where we can discuss the interfaces individually.

Quoted 5 lines

So, I'll ignore the code for now and discuss the interface only.

My main question is: What are the expected use cases for this interface in the perspective of a QMP client?

Quoted 9 lines

I can think of two:

1. Enabling/Disabling trace points (eg. from a GUI)
2. Get trace data to generate trace output or do some kind of analysis

If we're only interested in 1, then we don't need query-trace and if we do need query-trace then we'll have to rethink some things as it can be automatically flushed.

Quoted 8 lines

At present, qemu has all trace-events disabled at build-time, by default. The trace-events of interest are dynamically enabled using the human monitor at run time. '1' is useful to have, so that a QMP client can do the same.

The 'query-trace' interface simply displays the current contents of trace-buffer before they are flushed to disk.(equivalent to the 'info trace' HMP command )

This equivalence is not always desirable, HMP interfaces are designed for humans. We have to think what's the best machine interface.

Quoted 5 lines

To enabled logged traces to be forcibly flushed, HMP has a command :
(qemu)trace-file flush
I'm still working on the QMP interface for the same. ( I'll cover the proposed QMP interface in my documentation patchset that I'll be sending out shortly.)

Ok.

Quoted 67 lines
Quoted 8 lines

qmp-commands.hx Example: · line 1548

Quoted 5 lines
qmp-commands.hx +4 -0
+
+Show contents of trace buffer.
+
+Returns a set of json-objects containing the following data:

Looks like you return a json-array of json-objects, is that correct?

Yes.

Quoted 5 lines

qmp-commands.hx Example: · line 1550

Quoted 2 lines
qmp-commands.hx +2 -0
+
+- "event": Event ID for the trace-event(json-int)

Maybe this should be called event_id or just id.

I've renamed it to event_id for next patch.

Quoted 3 lines

qmp-commands.hx Example: · line 1551

Quoted 1 line
qmp-commands.hx +1 -0
+- "timestamp": trace timestamp (json-int)

Unit?

ns. I've corrected the description for the upcoming patchset.

Quoted 8 lines

qmp-commands.hx Example: · line 1552

Quoted 2 lines
qmp-commands.hx +1 -0
+- "arg1 .. arg6": Arguments logged by the trace-event (json-int)

Are they positional or named arguments?

If they are positional, you should use a json-array, if we have the argument name, then we could be nicer and have a json-object of arguments.

These are keyword arguments. I have changed the definition to have these enclosed in a QMP object for the next patchset version.

Quoted 21 lines
Quoted 21 lines
qmp-commands.hx +21 -0
+
+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,
Quoted 8 lines

qmp-commands.hx Example: · line 1579

Quoted 6 lines
qmp-commands.hx +6 -0
+         "arg4": 0,
+         "arg5": 0,
+         "arg6": 0
+       },
+       ...
+   }

The example above is invalid json.

Quoted 2 lines

I'm guessing this is invalid because it could be denoted as an array of objects ?

Yes.

Quoted 113 lines

Corrected in upcoming patchset.

Quoted 13 lines

qmp-commands.hx Example: · line 1589

Quoted 11 lines
qmp-commands.hx +10 -0
+
+EQMP
+
+SQMP
+query-trace-events
+------------------
+
+Show all available trace-events&  their state.
+
+Returns a set of json-objects containing the following data:

Again, I believe you want to return a json-array of json-objects.

Agree, corrected this for the documentation patchset.

Quoted 8 lines

qmp-commands.hx Example: · line 1592

Quoted 4 lines
qmp-commands.hx +3 -0
+
+- "name": Name of Trace-event (json-string)
+- "event-id": Event ID of Trace-event (json-int)

query-trace's key is called event, we should use either event_id or just id (I think I prefer the former).

Renamed to event_id.

Quoted 4 lines

qmp-commands.hx Example: · line 1593

Quoted 1 line
qmp-commands.hx +1 -0
+- "state": State of trace-event [ '0': inactive; '1':active  ] (json-int)

This should be a json-bool.

Done.

Quoted 11 lines
Quoted 11 lines
qmp-commands.hx +11 -0
+
+Example:
+
+->  { "execute": "query-trace-events" }
+<- {
+      "return":{
+         "name": "qemu_malloc",
+         "event-id": 0
+         "state": 0,
+      },
+      {
Quoted 9 lines

qmp-commands.hx Example: · line 1610

Quoted 6 lines
qmp-commands.hx +6 -0
+         "name": "qemu_realloc",
+         "event-id": 1,
+         "state": 0
+      },
+      ...
+   }

This also invalid json.

Again, I'm guessing the reason it is invalid that it ought to be an array. Changed for next patches.

Quoted 4 lines
Quoted 4 lines
qmp-commands.hx +4 -0
+
+EQMP
+
+SQMP
Quoted 9 lines

qmp-commands.hx Example: · line 1620

Quoted 6 lines
qmp-commands.hx +6 -0
+query-trace-file
+----------------
+
+Display currently set trace file name and its status.
+
+Returns a set of json-objects containing the following data:

This is actually just one json-object.

Oops, typo. Changed !

Quoted 5 lines

qmp-commands.hx Example: · line 1622

Quoted 2 lines
qmp-commands.hx +2 -0
+
+- "trace-file": Name of Trace-file (json-string)

Name or path?

This ought to display full path -- changed for next patch set.

Quoted 5 lines

qmp-commands.hx Example: · line 1623

Quoted 1 line
qmp-commands.hx +1 -0
+- "status": State of trace-event [ '0': disabled; '1':enabled  ] (json-int)

This should be a json bool called 'enabled' or 'disabled', but what happens when a file is not defined?

Changed type to json bool.
The trace infrastructure sets the trace-output file to trace-<PID> ( created in current dir) if no explicit trace-file is specified at startup. (Users can also change the default trace-file at runtime using the hmp command 'trace-file set FILE' I'll be covering QMP interface for the same in the upcoming patchset. )

Quoted 13 lines
Quoted 12 lines
qmp-commands.hx +12 -0
+
+Example:
+
+->  { "execute": "query-trace-file" }
+<- {
+      "return":{
+         "trace-file": "trace-26609",
+         "status": 1
+      }
+   }
+
+EQMP