[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch v0] qapi/qmp: Add timestamps to qmp command responses.
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [patch v0] qapi/qmp: Add timestamps to qmp command responses. |
Date: |
Mon, 26 Sep 2022 16:06:26 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 |
On 9/26/22 12:59, Denis Plotnikov wrote:
Add "start" & "end" timestamps to qmp command responses.
It's disabled by default, but can be enabled with 'timestamp=on'
monitor's parameter, e.g.:
-chardev socket,id=mon1,path=/tmp/qmp.socket,server=on,wait=off
-mon chardev=mon1,mode=control,timestamp=on
Example of result:
./qemu/scripts/qmp/qmp-shell /tmp/qmp.socket
(QEMU) query-status
{"end": {"seconds": 1650367305, "microseconds": 831032},
"start": {"seconds": 1650367305, "microseconds": 831012},
"return": {"status": "running", "singlestep": false, "running": true}}
The responce of the qmp command contains the start & end time of
the qmp command processing.
These times may be helpful for the management layer in understanding of
the actual timeline of a qmp command processing.
Suggested-by: Andrey Ryabinin <arbn@yandex-team.ru>
Signed-off-by: Denis Plotnikov <den-plotnikov@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
include/monitor/monitor.h | 2 +-
include/qapi/qmp/dispatch.h | 2 +-
monitor/monitor-internal.h | 1 +
monitor/monitor.c | 9 ++++++++-
monitor/qmp.c | 5 +++--
qapi/control.json | 3 +++
qapi/qmp-dispatch.c | 28 +++++++++++++++++++++++++++-
[..]
QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
- bool allow_oob, Monitor *cur_mon)
+ bool allow_oob, bool timestamp, Monitor *cur_mon)
{
Error *err = NULL;
bool oob;
@@ -146,6 +162,11 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject
*request,
QObject *id;
QObject *ret = NULL;
QDict *rsp = NULL;
+ uint64_t ts_start = -1;
+
+ if (timestamp) {
+ ts_start = g_get_real_time();
+ }
Maybe, better start timing in handle_qmp_command(), to inlude waiting in the
mon->qmp_requests queue.
dict = qobject_to(QDict, request);
if (!dict) {
@@ -270,5 +291,10 @@ out:
qdict_put_obj(rsp, "id", qobject_ref(id));
}
+ if (timestamp) {
+ uint64_t ts_end = g_get_real_time();
+ add_timestamps(rsp, ts_start, ts_end);
+ }
+
return rsp;
}
--
Best regards,
Vladimir