05.02.2021 10:56, Markus Armbruster wrote:
Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> writes:
Add a useful counterpart for trace_handle_qmp_command for debugging
libvirt guests.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
---
monitor/qmp.c | 6 ++++++
monitor/trace-events | 1 +
2 files changed, 7 insertions(+)
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 8f91af32be..772b9e7b30 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -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
--- a/monitor/trace-events
+++ b/monitor/trace-events
@@ -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?
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.
--
Best regards,
Vladimir