Skip to contentSkip to conversation

monitor: trace qmp_send_response

PATCH In review Vladimir Sementsov-Ogievskiy 2 participants 4 messages Feb 4, 2021 – Feb 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 monitor: trace qmp_send_response

Add a useful counterpart for trace_handle_qmp_command for debugging libvirt guests.

---
 monitor/qmp.c        | 6 ++++++
 monitor/trace-events | 1 +
 2 files changed, 7 insertions(+)
monitor/qmp.c +6 -0
index 8f91af32be..772b9e7b30 100644
@@ -111,6 +111,12 @@ void qmp_send_response(MonitorQMP *mon, const QDict *rsp)
     const QObject *data = QOBJECT(rsp);
     GString *json;
 
+    if (trace_event_get_state_backends(TRACE_QMP_SEND_RESPONSE)) {
+        json = qobject_to_json(data);
+        trace_qmp_send_response(mon, json->str);
+        g_string_free(json, true);
+    }
+
     json = qobject_to_json_pretty(data, mon->pretty);
     assert(json != NULL);
 
monitor/trace-events +1 -0
index 0365ac4d99..12f0576c7b 100644
@@ -13,3 +13,4 @@ monitor_suspend(void *ptr, int cnt) "mon %p: %d"
 monitor_qmp_cmd_in_band(const char *id) "%s"
 monitor_qmp_cmd_out_of_band(const char *id) "%s"
 handle_qmp_command(void *mon, const char *req) "mon %p req: %s"
+qmp_send_response(void *mon, const char *req) "mon %p req: %s"
Signature · 1 line
2.29.2
#1 lore raw
Quoted 31 lines · Vladimir Sementsov-Ogievskiy

Add a useful counterpart for trace_handle_qmp_command for debugging libvirt guests.

---
 monitor/qmp.c        | 6 ++++++
 monitor/trace-events | 1 +
 2 files changed, 7 insertions(+)
monitor/qmp.c +6 -0
index 8f91af32be..772b9e7b30 100644
@@ -111,6 +111,12 @@ void qmp_send_response(MonitorQMP *mon, const QDict *rsp)
     const QObject *data = QOBJECT(rsp);
     GString *json;
 
+    if (trace_event_get_state_backends(TRACE_QMP_SEND_RESPONSE)) {
+        json = qobject_to_json(data);
+        trace_qmp_send_response(mon, json->str);
+        g_string_free(json, true);
+    }
+
     json = qobject_to_json_pretty(data, mon->pretty);
     assert(json != NULL);
 
monitor/trace-events +0 -0
index 0365ac4d99..12f0576c7b 100644

monitor/trace-events monitor_suspend(void *ptr, int cnt) "mon %p: %d" · line 16

Quoted 4 lines
monitor/trace-events +1 -0
@@ -13,3 +13,4 @@ monitor_suspend(void *ptr, int cnt) "mon %p: %d"
 monitor_qmp_cmd_in_band(const char *id) "%s"
 monitor_qmp_cmd_out_of_band(const char *id) "%s"
 handle_qmp_command(void *mon, const char *req) "mon %p req: %s"
+qmp_send_response(void *mon, const char *req) "mon %p req: %s"

A slightly lazier version of this just landed in commit f680405f45 "qmp:
Add more tracepoints". The difference is yours ignores mon->pretty for tracing.

Thoughts?

#2 lore raw
Quoted 42 lines · Markus Armbruster
Quoted 31 lines · Vladimir Sementsov-Ogievskiy

Add a useful counterpart for trace_handle_qmp_command for debugging libvirt guests.

---
  monitor/qmp.c        | 6 ++++++
  monitor/trace-events | 1 +
  2 files changed, 7 insertions(+)
monitor/qmp.c +6 -0
index 8f91af32be..772b9e7b30 100644
@@ -111,6 +111,12 @@ void qmp_send_response(MonitorQMP *mon, const QDict *rsp)
      const QObject *data = QOBJECT(rsp);
      GString *json;
 
+    if (trace_event_get_state_backends(TRACE_QMP_SEND_RESPONSE)) {
+        json = qobject_to_json(data);
+        trace_qmp_send_response(mon, json->str);
+        g_string_free(json, true);
+    }
+
      json = qobject_to_json_pretty(data, mon->pretty);
      assert(json != NULL);
 
monitor/trace-events +0 -0
index 0365ac4d99..12f0576c7b 100644

monitor/trace-events monitor_suspend(void *ptr, int cnt) "mon %p: %d" · line 16

Quoted 4 lines
monitor/trace-events +1 -0
@@ -13,3 +13,4 @@ monitor_suspend(void *ptr, int cnt) "mon %p: %d"
  monitor_qmp_cmd_in_band(const char *id) "%s"
  monitor_qmp_cmd_out_of_band(const char *id) "%s"
  handle_qmp_command(void *mon, const char *req) "mon %p req: %s"
+qmp_send_response(void *mon, const char *req) "mon %p req: %s"

A slightly lazier version of this just landed in commit f680405f45 "qmp:
Add more tracepoints". The difference is yours ignores mon->pretty for tracing.

Quoted 2 lines

Thoughts?

Ah, missed this, great. Then, nothing to do.

In our environment (I'm not sure who do it libvirt, or other our tool) different query- commands are called periodically and their output is big enough, so I decided to trace json in oneline.. Still better is developing a way to not trace some qmp commands and their output.

Signature · 2 lines
Best regards,
Vladimir
#3 lore raw
Quoted 44 lines · Vladimir Sementsov-Ogievskiy
Quoted 33 lines · Markus Armbruster
Quoted 31 lines · Vladimir Sementsov-Ogievskiy

Add a useful counterpart for trace_handle_qmp_command for debugging libvirt guests.

---
  monitor/qmp.c        | 6 ++++++
  monitor/trace-events | 1 +
  2 files changed, 7 insertions(+)
monitor/qmp.c +5 -0
index 8f91af32be..772b9e7b30 100644
@@ -111,6 +111,12 @@ void qmp_send_response(MonitorQMP *mon, const QDict *rsp)
      const QObject *data = QOBJECT(rsp);
      GString *json;
  +    if (trace_event_get_state_backends(TRACE_QMP_SEND_RESPONSE))
 {
+        json = qobject_to_json(data);
+        trace_qmp_send_response(mon, json->str);
+        g_string_free(json, true);
+    }
+
      json = qobject_to_json_pretty(data, mon->pretty);
      assert(json != NULL);
  diff --git a/monitor/trace-events b/monitor/trace-events

index 0365ac4d99..12f0576c7b 100644

monitor/trace-events +0 -0
@@ -13,3 +13,4 @@ monitor_suspend(void *ptr, int cnt) "mon %p: %d"
  monitor_qmp_cmd_in_band(const char *id) "%s"
Quoted 9 lines

monitor/trace-events monitor_suspend(void *ptr, int cnt) "mon %p: %d" · line 16

Quoted 3 lines
monitor/trace-events +1 -0
  monitor_qmp_cmd_out_of_band(const char *id) "%s"
  handle_qmp_command(void *mon, const char *req) "mon %p req: %s"
+qmp_send_response(void *mon, const char *req) "mon %p req: %s"

A slightly lazier version of this just landed in commit f680405f45 "qmp:
Add more tracepoints". The difference is yours ignores mon->pretty for tracing.
Thoughts?

Quoted 3 lines

Ah, missed this, great. Then, nothing to do.

In our environment (I'm not sure who do it libvirt, or other our tool) different query- commands are called periodically and their output is big enough, so I decided to trace json in oneline.. Still better is developing a way to not trace some qmp commands and their output.

Feel free to add features you find useful on top.