All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands
@ 2017-06-05 10:42 Stefan Hajnoczi
  2017-06-05 10:42 ` [Qemu-devel] [PATCH 1/2] monitor: add handle_hmp_command trace event Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2017-06-05 10:42 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, Stefan Hajnoczi

It's nice to have HMP and QMP commands as part of a trace log.  This makes it
possible to correlate QEMU-internal events with the monitor commands that
caused them.

Stefan Hajnoczi (2):
  monitor: add handle_hmp_command trace event
  monitor: resurrect handle_qmp_command trace event

 monitor.c    | 7 +++++++
 trace-events | 2 ++
 2 files changed, 9 insertions(+)

-- 
2.9.4

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

* [Qemu-devel] [PATCH 1/2] monitor: add handle_hmp_command trace event
  2017-06-05 10:42 [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands Stefan Hajnoczi
@ 2017-06-05 10:42 ` Stefan Hajnoczi
  2017-06-05 12:29   ` Eric Blake
  2017-06-05 10:42 ` [Qemu-devel] [PATCH 2/2] monitor: resurrect handle_qmp_command " Stefan Hajnoczi
  2017-06-12 13:48 ` [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands Stefan Hajnoczi
  2 siblings, 1 reply; 6+ messages in thread
From: Stefan Hajnoczi @ 2017-06-05 10:42 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, Stefan Hajnoczi

It is often useful to correlate QEMU-internal events with monitor
commands that caused them.  Trace the full HMP command being executed.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 monitor.c    | 2 ++
 trace-events | 1 +
 2 files changed, 3 insertions(+)

diff --git a/monitor.c b/monitor.c
index baa73c9..1e78d86 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3085,6 +3085,8 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline)
     QDict *qdict;
     const mon_cmd_t *cmd;
 
+    trace_handle_hmp_command(mon, cmdline);
+
     cmd = monitor_parse_command(mon, &cmdline, mon->cmd_table);
     if (!cmd) {
         return;
diff --git a/trace-events b/trace-events
index 433865f..2de6bec 100644
--- a/trace-events
+++ b/trace-events
@@ -52,6 +52,7 @@ spice_vmc_event(int event) "spice vmc event %d"
 monitor_protocol_event_handler(uint32_t event, void *qdict) "event=%d data=%p"
 monitor_protocol_event_emit(uint32_t event, void *data) "event=%d data=%p"
 monitor_protocol_event_queue(uint32_t event, void *qdict, uint64_t rate) "event=%d data=%p rate=%" PRId64
+handle_hmp_command(void *mon, const char *cmdline) "mon %p cmdline: %s"
 
 # dma-helpers.c
 dma_blk_io(void *dbs, void *bs, int64_t offset, bool to_dev) "dbs=%p bs=%p offset=%" PRId64 " to_dev=%d"
-- 
2.9.4

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

* [Qemu-devel] [PATCH 2/2] monitor: resurrect handle_qmp_command trace event
  2017-06-05 10:42 [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands Stefan Hajnoczi
  2017-06-05 10:42 ` [Qemu-devel] [PATCH 1/2] monitor: add handle_hmp_command trace event Stefan Hajnoczi
@ 2017-06-05 10:42 ` Stefan Hajnoczi
  2017-06-05 12:28   ` Eric Blake
  2017-06-12 13:48 ` [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands Stefan Hajnoczi
  2 siblings, 1 reply; 6+ messages in thread
From: Stefan Hajnoczi @ 2017-06-05 10:42 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, Stefan Hajnoczi

Commit 104fc3027960dd2aa9d310936a6cb201c60e1088 ("qmp: Drop duplicated
QMP command object checks") removed the call to
trace_handle_qmp_command() while eliminating code duplication.

This patch brings the trace event back so QEMU-internal trace events can
be correlated with the QMP commands that caused them.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 monitor.c    | 5 +++++
 trace-events | 1 +
 2 files changed, 6 insertions(+)

diff --git a/monitor.c b/monitor.c
index 1e78d86..e1105ea 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3806,6 +3806,7 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
     QDict *qdict = NULL;
     Monitor *mon = cur_mon;
     Error *err = NULL;
+    QString *req_json;
 
     req = json_parser_parse_err(tokens, NULL, &err);
     if (!req && !err) {
@@ -3823,6 +3824,10 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
         qdict_del(qdict, "id");
     } /* else will fail qmp_dispatch() */
 
+    req_json = qobject_to_json(req);
+    trace_handle_qmp_command(mon, qstring_get_str(req_json));
+    qobject_decref(QOBJECT(req_json));
+
     rsp = qmp_dispatch(cur_mon->qmp.commands, req);
 
     if (mon->qmp.commands == &qmp_cap_negotiation_commands) {
diff --git a/trace-events b/trace-events
index 2de6bec..d22e0ba 100644
--- a/trace-events
+++ b/trace-events
@@ -53,6 +53,7 @@ monitor_protocol_event_handler(uint32_t event, void *qdict) "event=%d data=%p"
 monitor_protocol_event_emit(uint32_t event, void *data) "event=%d data=%p"
 monitor_protocol_event_queue(uint32_t event, void *qdict, uint64_t rate) "event=%d data=%p rate=%" PRId64
 handle_hmp_command(void *mon, const char *cmdline) "mon %p cmdline: %s"
+handle_qmp_command(void *mon, const char *req) "mon %p req: %s"
 
 # dma-helpers.c
 dma_blk_io(void *dbs, void *bs, int64_t offset, bool to_dev) "dbs=%p bs=%p offset=%" PRId64 " to_dev=%d"
-- 
2.9.4

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

* Re: [Qemu-devel] [PATCH 2/2] monitor: resurrect handle_qmp_command trace event
  2017-06-05 10:42 ` [Qemu-devel] [PATCH 2/2] monitor: resurrect handle_qmp_command " Stefan Hajnoczi
@ 2017-06-05 12:28   ` Eric Blake
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2017-06-05 12:28 UTC (permalink / raw)
  To: Stefan Hajnoczi, Markus Armbruster; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]

On 06/05/2017 05:42 AM, Stefan Hajnoczi wrote:
> Commit 104fc3027960dd2aa9d310936a6cb201c60e1088 ("qmp: Drop duplicated
> QMP command object checks") removed the call to
> trace_handle_qmp_command() while eliminating code duplication.
> 
> This patch brings the trace event back so QEMU-internal trace events can
> be correlated with the QMP commands that caused them.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  monitor.c    | 5 +++++
>  trace-events | 1 +
>  2 files changed, 6 insertions(+)
> 

> @@ -3823,6 +3824,10 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens)
>          qdict_del(qdict, "id");
>      } /* else will fail qmp_dispatch() */
>  
> +    req_json = qobject_to_json(req);
> +    trace_handle_qmp_command(mon, qstring_get_str(req_json));
> +    qobject_decref(QOBJECT(req_json));

I should really revive my patches that create a JSON output visitor, as
it would use less memory allocation in use cases like this.  But that's
not your problem.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 1/2] monitor: add handle_hmp_command trace event
  2017-06-05 10:42 ` [Qemu-devel] [PATCH 1/2] monitor: add handle_hmp_command trace event Stefan Hajnoczi
@ 2017-06-05 12:29   ` Eric Blake
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Blake @ 2017-06-05 12:29 UTC (permalink / raw)
  To: Stefan Hajnoczi, Markus Armbruster; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

On 06/05/2017 05:42 AM, Stefan Hajnoczi wrote:
> It is often useful to correlate QEMU-internal events with monitor
> commands that caused them.  Trace the full HMP command being executed.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  monitor.c    | 2 ++
>  trace-events | 1 +
>  2 files changed, 3 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands
  2017-06-05 10:42 [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands Stefan Hajnoczi
  2017-06-05 10:42 ` [Qemu-devel] [PATCH 1/2] monitor: add handle_hmp_command trace event Stefan Hajnoczi
  2017-06-05 10:42 ` [Qemu-devel] [PATCH 2/2] monitor: resurrect handle_qmp_command " Stefan Hajnoczi
@ 2017-06-12 13:48 ` Stefan Hajnoczi
  2 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2017-06-12 13:48 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: Markus Armbruster, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

On Mon, Jun 05, 2017 at 11:42:14AM +0100, Stefan Hajnoczi wrote:
> It's nice to have HMP and QMP commands as part of a trace log.  This makes it
> possible to correlate QEMU-internal events with the monitor commands that
> caused them.
> 
> Stefan Hajnoczi (2):
>   monitor: add handle_hmp_command trace event
>   monitor: resurrect handle_qmp_command trace event
> 
>  monitor.c    | 7 +++++++
>  trace-events | 2 ++
>  2 files changed, 9 insertions(+)

Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

end of thread, other threads:[~2017-06-12 13:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 10:42 [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands Stefan Hajnoczi
2017-06-05 10:42 ` [Qemu-devel] [PATCH 1/2] monitor: add handle_hmp_command trace event Stefan Hajnoczi
2017-06-05 12:29   ` Eric Blake
2017-06-05 10:42 ` [Qemu-devel] [PATCH 2/2] monitor: resurrect handle_qmp_command " Stefan Hajnoczi
2017-06-05 12:28   ` Eric Blake
2017-06-12 13:48 ` [Qemu-devel] [PATCH 0/2] monitor: add trace events for HMP and QMP commands Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.