qapi/qmp: Add timestamps to qmp command responses.
PATCH 1/1 qapi/qmp: Add timestamps to qmp command responses.
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.
--- 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 +++++++++++++++++++++++++++- qga/main.c | 2 +- stubs/monitor-core.c | 2 +- tests/unit/test-qmp-cmds.c | 6 +++--- 10 files changed, 49 insertions(+), 11 deletions(-)
include/monitor/monitor.h +1 -1
@@ -19,7 +19,7 @@ bool monitor_cur_is_qmp(void);void monitor_init_globals (void );void monitor_init_globals_core (void ); -void monitor_init_qmp (Chardev *chr,bool pretty,Error **errp); +void monitor_init_qmp (Chardev *chr,bool pretty,bool timestamp,Error **errp);void monitor_init_hmp (Chardev *chr,bool use_readline,Error **errp);int monitor_init (MonitorOptions *opts,bool allow_hmp,Error **errp);int monitor_init_opts (QemuOpts *opts,Error **errp);
include/qapi/qmp/dispatch.h +1 -1
@@ -56,7 +56,7 @@ const char *qmp_command_name(const QmpCommand *cmd);bool qmp_has_success_response (const QmpCommand *cmd);QDict *qmp_error_response (Error *err);QDict *qmp_dispatch (const QmpCommandList *cmds,QObject *request, -bool allow_oob,Monitor *cur_mon); +bool allow_oob,bool timestamp,Monitor *cur_mon);bool qmp_is_oob (const QDict *dict);typedef void (*qmp_cmd_callback_fn )(const QmpCommand *cmd,void *opaque);
monitor/monitor-internal.h +1 -0
@@ -136,6 +136,7 @@ typedef struct {Monitor common;JSONMessageParser parser;bool pretty; +bool timestamp;/* * When a client connects, we're in capabilities negotiation mode. * @commands is &qmp_cap_negotiation_commands then. When command
monitor/monitor.c +8 -1
@@ -726,7 +726,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)switch (opts->mode) {case MONITOR_MODE_CONTROL : -monitor_init_qmp (chr, opts->pretty, &local_err); +monitor_init_qmp (chr, opts->pretty, opts->timestamp, &local_err);break ;case MONITOR_MODE_READLINE :if (!allow_hmp) {
@@ -737,6 +737,10 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)error_setg (errp,"'pretty' is not compatible with HMP monitors" );return -1 ; } +if (opts->timestamp) { +error_setg (errp,"'timestamp' is not compatible with HMP monitors" ); +return -1 ; + }monitor_init_hmp (chr, true, &local_err);break ;default :
@@ -782,6 +786,9 @@ QemuOptsList qemu_mon_opts = { },{ .name = "pretty", .type = QEMU_OPT_BOOL, + },{ + .name = "timestamp", + .type = QEMU_OPT_BOOL, }, {/* end of list */ } },
monitor/qmp.c +3 -2
@@ -142,7 +142,7 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)QDict *error; rsp =qmp_dispatch (mon->commands, req,qmp_oob_enabled (mon), - &mon->common); + mon->timestamp, &mon->common);if (mon->commands == &qmp_cap_negotiation_commands) { error =qdict_get_qdict (rsp,"error" );
@@ -495,7 +495,7 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)monitor_list_append (&mon->common); } -void monitor_init_qmp (Chardev *chr,bool pretty,Error **errp) +void monitor_init_qmp (Chardev *chr,bool pretty,bool timestamp,Error **errp) {MonitorQMP *mon =g_new0 (MonitorQMP,1 );
@@ -510,6 +510,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp) qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_GCONTEXT)); mon->pretty = pretty; + mon->timestamp = timestamp;qemu_mutex_init (&mon->qmp_queue_lock); mon->qmp_requests =g_queue_new ();
qapi/control.json +3 -0
@@ -199,6 +199,8 @@ # # @pretty: Enables pretty printing (QMP only) # +# @timestamp: Enables qmp command start and end timestamps printing (QMP only) +# # @chardev: Name of a character device to expose the monitor on # # Since: 5.0
@@ -208,5 +210,6 @@ '*id': 'str', '*mode': 'MonitorMode', '*pretty': 'bool', + '*timestamp': 'bool', 'chardev': 'str' } }
qapi/qmp-dispatch.c +27 -1
@@ -110,6 +110,22 @@ bool qmp_is_oob(const QDict *dict) && !qdict_haskey (dict,"execute" ); } +static void add_timestamps (QDict *qdict,uint64_t start_ms,uint64_t end_ms) +{ +QDict *start_dict, *end_dict; + + start_dict =qdict_new (); +qdict_put_int (start_dict,"seconds" , start_ms /G_USEC_PER_SEC ); +qdict_put_int (start_dict,"microseconds" , start_ms %G_USEC_PER_SEC ); + + end_dict =qdict_new (); +qdict_put_int (end_dict,"seconds" , end_ms /G_USEC_PER_SEC ); +qdict_put_int (end_dict,"microseconds" , end_ms %G_USEC_PER_SEC ); + +qdict_put_obj (qdict,"start" ,QOBJECT (start_dict)); +qdict_put_obj (qdict,"end" ,QOBJECT (end_dict)); +} + typedef struct QmpDispatchBH { const QmpCommand *cmd; Monitor *cur_mon;
@@ -135,7 +151,7 @@ static void do_qmp_dispatch_bh(void *opaque)* context for everything else. */ 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 (); + } 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; }
qga/main.c +1 -1
@@ -573,7 +573,7 @@ static void process_event(void *opaque, QObject *obj, Error *err) }g_debug ("processing command" ); - rsp =qmp_dispatch (&ga_commands, obj, false,NULL ); + rsp =qmp_dispatch (&ga_commands, obj, false, false,NULL ); end: ret =send_response (s, rsp);
stubs/monitor-core.c +1 -1
@@ -12,7 +12,7 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)return NULL ; } -void monitor_init_qmp (Chardev *chr,bool pretty,Error **errp) +void monitor_init_qmp (Chardev *chr,bool pretty,bool timestamp,Error **errp) { }
tests/unit/test-qmp-cmds.c +3 -3
@@ -150,7 +150,7 @@ static QObject *do_qmp_dispatch(bool allow_oob, const char *template, ...) req =qdict_from_vjsonf_nofail (template, ap);va_end (ap); - resp =qmp_dispatch (&qmp_commands,QOBJECT (req), allow_oob,NULL ); + resp =qmp_dispatch (&qmp_commands,QOBJECT (req), allow_oob, false,NULL );g_assert (resp); ret =qdict_get (resp,"return" );g_assert (ret);
@@ -173,7 +173,7 @@ static void do_qmp_dispatch_error(bool allow_oob, ErrorClass cls, req =qdict_from_vjsonf_nofail (template, ap);va_end (ap); - resp =qmp_dispatch (&qmp_commands,QOBJECT (req), allow_oob,NULL ); + resp =qmp_dispatch (&qmp_commands,QOBJECT (req), allow_oob, false,NULL );g_assert (resp); error =qdict_get_qdict (resp,"error" );g_assert (error);
@@ -229,7 +229,7 @@ static void test_dispatch_cmd_success_response(void)QDict *resp;qdict_put_str (req,"execute" ,"cmd-success-response" ); - resp =qmp_dispatch (&qmp_commands,QOBJECT (req), false,NULL ); + resp =qmp_dispatch (&qmp_commands,QOBJECT (req), false, false,NULL );g_assert_null (resp);qobject_unref (req); }
Signature · 1 line
2.25.1
Quoted 15 lines · Denis Plotnikov
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=onExample 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}}
Quoted 8 lines
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 <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>
Quoted 8 lines
--- 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 +++++++++++++++++++++++++++-
[..]
Quoted 7 lines
QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
qapi/qmp-dispatch.c +1
-1- bool allow_oob, Monitor *cur_mon) + bool allow_oob, bool timestamp, Monitor *cur_mon) { Error *err = NULL;bool oob;
qapi/qmp-dispatch.c QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, · line 169
Quoted 8 lines
qapi/qmp-dispatch.c +5
-0@@ -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.
Quoted 14 lines
qapi/qmp-dispatch.c +5
-0dict =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; }
Signature · 2 lines
Best regards, Vladimir
Quoted 5 lines · Denis Plotnikov
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
I'm not convinced a cmdline flag is the right approach here.
I think it ought be something defined by the QMP spec.
The "QMP" greeting should report "timestamp" capabilities.
The 'qmp_capabilities' command can be used to turn on this capability for all commands henceforth.
As an option extra, the 'execute' command could gain a parameter to allow this to be requested for only an individual command.
Alternatively we could say the overhead of adding the timestmaps is small enough that we just add this unconditionally for everything hence, with no opt-in/opt-out.
Quoted 9 lines
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}}
Quoted 5 lines
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.
Can you explain the problem scenario in more detail.
The mgmt app already knows when it send the QMP command and knows when it gets the QMP reply. This covers the time the QMP was queued before processing (might be large if QMP is blocked on another slow command) , the processing time, and the time any reply was queued before sending (ought to be small).
So IIUC, the value these fields add is that they let the mgmt app extract only the command processing time, eliminating any variance do to queue before/after.
Quoted 257 lines
Suggested-by Andrey Ryabinin <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>--- 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 +++++++++++++++++++++++++++- qga/main.c | 2 +- stubs/monitor-core.c | 2 +- tests/unit/test-qmp-cmds.c | 6 +++--- 10 files changed, 49 insertions(+), 11 deletions(-)include/monitor/monitor.h +1
-1@@ -19,7 +19,7 @@ bool monitor_cur_is_qmp(void);void monitor_init_globals (void );void monitor_init_globals_core (void ); -void monitor_init_qmp (Chardev *chr,bool pretty,Error **errp); +void monitor_init_qmp (Chardev *chr,bool pretty,bool timestamp,Error **errp);void monitor_init_hmp (Chardev *chr,bool use_readline,Error **errp);int monitor_init (MonitorOptions *opts,bool allow_hmp,Error **errp);int monitor_init_opts (QemuOpts *opts,Error **errp);include/qapi/qmp/dispatch.h +1
-1@@ -56,7 +56,7 @@ const char *qmp_command_name(const QmpCommand *cmd);bool qmp_has_success_response (const QmpCommand *cmd);QDict *qmp_error_response (Error *err);QDict *qmp_dispatch (const QmpCommandList *cmds,QObject *request, -bool allow_oob,Monitor *cur_mon); +bool allow_oob,bool timestamp,Monitor *cur_mon);bool qmp_is_oob (const QDict *dict);typedef void (*qmp_cmd_callback_fn )(const QmpCommand *cmd,void *opaque);monitor/monitor-internal.h +1
-0@@ -136,6 +136,7 @@ typedef struct {Monitor common;JSONMessageParser parser;bool pretty; +bool timestamp;/* * When a client connects, we're in capabilities negotiation mode. * @commands is &qmp_cap_negotiation_commands then. When command monitor/monitor.c +8
-1@@ -726,7 +726,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)switch (opts->mode) {case MONITOR_MODE_CONTROL : -monitor_init_qmp (chr, opts->pretty, &local_err); +monitor_init_qmp (chr, opts->pretty, opts->timestamp, &local_err);break ;case MONITOR_MODE_READLINE :if (!allow_hmp) {@@ -737,6 +737,10 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)error_setg (errp,"'pretty' is not compatible with HMP monitors" );return -1 ; } +if (opts->timestamp) { +error_setg (errp,"'timestamp' is not compatible with HMP monitors" ); +return -1 ; + }monitor_init_hmp (chr, true, &local_err);break ;default :@@ -782,6 +786,9 @@ QemuOptsList qemu_mon_opts = { },{ .name = "pretty", .type = QEMU_OPT_BOOL, + },{ + .name = "timestamp", + .type = QEMU_OPT_BOOL, }, {/* end of list */ } },monitor/qmp.c +3
-2@@ -142,7 +142,7 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObject *req)QDict *error; rsp =qmp_dispatch (mon->commands, req,qmp_oob_enabled (mon), - &mon->common); + mon->timestamp, &mon->common);if (mon->commands == &qmp_cap_negotiation_commands) { error =qdict_get_qdict (rsp,"error" );@@ -495,7 +495,7 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)monitor_list_append (&mon->common); } -void monitor_init_qmp (Chardev *chr,bool pretty,Error **errp) +void monitor_init_qmp (Chardev *chr,bool pretty,bool timestamp,Error **errp) {MonitorQMP *mon =g_new0 (MonitorQMP,1 );@@ -510,6 +510,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp) qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_GCONTEXT)); mon->pretty = pretty; + mon->timestamp = timestamp;qemu_mutex_init (&mon->qmp_queue_lock); mon->qmp_requests =g_queue_new ();qapi/control.json +3
-0@@ -199,6 +199,8 @@ # # @pretty: Enables pretty printing (QMP only) # +# @timestamp: Enables qmp command start and end timestamps printing (QMP only) +# # @chardev: Name of a character device to expose the monitor on # # Since: 5.0@@ -208,5 +210,6 @@ '*id': 'str', '*mode': 'MonitorMode', '*pretty': 'bool', + '*timestamp': 'bool', 'chardev': 'str' } }qapi/qmp-dispatch.c +27
-1@@ -110,6 +110,22 @@ bool qmp_is_oob(const QDict *dict) && !qdict_haskey (dict,"execute" ); } +static void add_timestamps (QDict *qdict,uint64_t start_ms,uint64_t end_ms) +{ +QDict *start_dict, *end_dict; + + start_dict =qdict_new (); +qdict_put_int (start_dict,"seconds" , start_ms /G_USEC_PER_SEC ); +qdict_put_int (start_dict,"microseconds" , start_ms %G_USEC_PER_SEC ); + + end_dict =qdict_new (); +qdict_put_int (end_dict,"seconds" , end_ms /G_USEC_PER_SEC ); +qdict_put_int (end_dict,"microseconds" , end_ms %G_USEC_PER_SEC ); + +qdict_put_obj (qdict,"start" ,QOBJECT (start_dict)); +qdict_put_obj (qdict,"end" ,QOBJECT (end_dict)); +} + typedef struct QmpDispatchBH { const QmpCommand *cmd; Monitor *cur_mon;@@ -135,7 +151,7 @@ static void do_qmp_dispatch_bh(void *opaque)* context for everything else. */ 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 (); + } 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; }qga/main.c +1
-1@@ -573,7 +573,7 @@ static void process_event(void *opaque, QObject *obj, Error *err) }g_debug ("processing command" ); - rsp =qmp_dispatch (&ga_commands, obj, false,NULL ); + rsp =qmp_dispatch (&ga_commands, obj, false, false,NULL ); end: ret =send_response (s, rsp);stubs/monitor-core.c +1
-1@@ -12,7 +12,7 @@ Monitor *monitor_set_cur(Coroutine *co, Monitor *mon)return NULL ; } -void monitor_init_qmp (Chardev *chr,bool pretty,Error **errp) +void monitor_init_qmp (Chardev *chr,bool pretty,bool timestamp,Error **errp) { }tests/unit/test-qmp-cmds.c +3
-3@@ -150,7 +150,7 @@ static QObject *do_qmp_dispatch(bool allow_oob, const char *template, ...) req =qdict_from_vjsonf_nofail (template, ap);va_end (ap); - resp =qmp_dispatch (&qmp_commands,QOBJECT (req), allow_oob,NULL ); + resp =qmp_dispatch (&qmp_commands,QOBJECT (req), allow_oob, false,NULL );g_assert (resp); ret =qdict_get (resp,"return" );g_assert (ret);@@ -173,7 +173,7 @@ static void do_qmp_dispatch_error(bool allow_oob, ErrorClass cls, req =qdict_from_vjsonf_nofail (template, ap);va_end (ap); - resp =qmp_dispatch (&qmp_commands,QOBJECT (req), allow_oob,NULL ); + resp =qmp_dispatch (&qmp_commands,QOBJECT (req), allow_oob, false,NULL );g_assert (resp); error =qdict_get_qdict (resp,"error" );g_assert (error);@@ -229,7 +229,7 @@ static void test_dispatch_cmd_success_response(void)QDict *resp;qdict_put_str (req,"execute" ,"cmd-success-response" ); - resp =qmp_dispatch (&qmp_commands,QOBJECT (req), false,NULL ); + resp =qmp_dispatch (&qmp_commands,QOBJECT (req), false, false,NULL );g_assert_null (resp);qobject_unref (req); }Signature · 1 line
2.25.1
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 10 lines · Daniel P. Berrangé
Quoted 5 lines · Denis Plotnikov
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=onI'm not convinced a cmdline flag is the right approach here.
I think it ought be something defined by the QMP spec.
The QMP spec is docs/interop/qmp-spec.txt. The feature needs to be defined there regardless of how we control it.
Quoted 4 lines
The "QMP" greeting should report "timestamp" capabilities.
The '
qmp_capabilities' command can be used to turn on this capability for all commands henceforth.
Yes, this is how optional QMP protocol features should be controlled.
Bonus: control is per connection, not just globally.
Quoted 3 lines
As an option extra, the 'execute' command could gain a parameter to allow this to be requested for only an individual command.
Needs a use case.
Quoted 3 lines
Alternatively we could say the overhead of adding the timestmaps is small enough that we just add this unconditionally for everything hence, with no opt-in/opt-out.
Yes, because the extension is backwards compatible.
Aside: qmp-spec.txt could be clearer on what that means.
Quoted 11 lines
Quoted 11 lines
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.
Seconds and microseconds since when? The update to qmp-spec.txt should tell.
Why split the time into seconds and microseconds? If you use microseconds since the Unix epoch (1970-01-01 UTC), 64 bit unsigned will result in a year 586524 problem:
$ date --date "@`echo '2^64/1000000' | bc`"
Wed Jan 19 09:01:49 CET 586524Even a mere 53 bits will last until 2255.
Quoted 4 lines
Quoted 2 lines
These times may be helpful for the management layer in understanding of the actual timeline of a qmp command processing.
Can you explain the problem scenario in more detail.
Yes, please, because:
Quoted 12 lines
The mgmt app already knows when it send the QMP command and knows when it gets the QMP reply. This covers the time the QMP was queued before processing (might be large if QMP is blocked on another slow command) , the processing time, and the time any reply was queued before sending (ought to be small).
So IIUC, the value these fields add is that they let the mgmt app extract only the command processing time, eliminating any variance do to queue before/after.
Quoted 2 lines
Suggested-by Andrey Ryabinin <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>
Quoted 8 lines · Markus Armbruster
Quoted 6 lines · Daniel P. Berrangé
Quoted 5 lines · Denis Plotnikov
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
Quoted 5 lines
Quoted 3 lines
I'm not convinced a cmdline flag is the right approach here.
I think it ought be something defined by the QMP spec.
The QMP spec is
docs/interop/qmp-spec.txt. The feature needs to be defined there regardless of how we control it.
ok, thanks for pointing out
Quoted 12 lines
Quoted 5 lines
The "QMP" greeting should report "timestamp" capabilities.
The '
qmp_capabilities' command can be used to turn on this capability for all commands henceforth.Yes, this is how optional QMP protocol features should be controlled.
Bonus: control is per connection, not just globally.
Quoted 3 lines
As an option extra, the 'execute' command could gain a parameter to allow this to be requested for only an individual command.
Quoted 6 lines
Needs a use case.
Quoted 3 lines
Alternatively we could say the overhead of adding the timestmaps is small enough that we just add this unconditionally for everything hence, with no opt-in/opt-out.
Yes, because the extension is backwards compatible.
May be it worth to send the timestamps always in the response if doesn't contradicts with anything and doesn't bring any unnecessary data overhead.
From the other hand turning it on via qmp capabilities seems to be more flexible solution.
Quoted 17 lines
Aside: qmp-spec.txt could be clearer on what that means.
Quoted 11 lines
Quoted 11 lines
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.
Seconds and microseconds since when? The update to qmp-spec.txt should tell.
Quoted 8 lines
Why split the time into seconds and microseconds? If you use microseconds since the Unix epoch (1970-01-01 UTC), 64 bit unsigned will result in a year 586524 problem:
$ date --date "@`echo '2^64/1000000' | bc`" Wed Jan 19 09:01:49 CET 586524Even a mere 53 bits will last until 2255.
This is Just for convenience, may be it's too much and timestamp in msec if enough
Quoted 15 lines
Quoted 4 lines
Quoted 3 lines
These times may be helpful for the management layer in understanding of the actual timeline of a qmp command processing.
Can you explain the problem scenario in more detail.
Yes, please, because:
Quoted 9 lines
The mgmt app already knows when it send the QMP command and knows when it gets the QMP reply. This covers the time the QMP was queued before processing (might be large if QMP is blocked on another slow command) , the processing time, and the time any reply was queued before sending (ought to be small).
So IIUC, the value these fields add is that they let the mgmt app extract only the command processing time, eliminating any variance do to queue before/after.
So the scenario is the following: we need a means to understand from the management layer prospecitive of what is the timeline of the command execution. This is needed for a problem resolving if a qmp command executes for too long from the management layer point of view. Specifically, management layer sees the execution time as "management_layer_internal_routine_time" + "qemu_dispatching_time" + "qemu_qmp_command_execution_time". Suggested qmp command timestaps gives "qemu_command_execution_time". Management layer calculates "management_layer_internal_routine_time" internally. Using those two things we can calculate "qemu_dispatching_time" and decide where the potential delays comes from. This will gives us a direction of further problem investigation.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Suggested-by Andrey Ryabinin <[email protected]>Signed-off-by Denis Plotnikov <[email protected]>
Quoted 11 lines · Markus Armbruster
Quoted 10 lines · Daniel P. Berrangé
Quoted 9 lines · Denis Plotnikov
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}}
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
The responce of the qmp command contains the start & end time of the qmp command processing.
Seconds and microseconds since when? The update to qmp-spec.txt should tell.
Why split the time into seconds and microseconds?
This is exactly how timestamps in QMP events are done, so we thought we'd just follow suit
Quoted 9 lines
Quoted 9 lines
The mgmt app already knows when it send the QMP command and knows when it gets the QMP reply. This covers the time the QMP was queued before processing (might be large if QMP is blocked on another slow command) , the processing time, and the time any reply was queued before sending (ought to be small).
So IIUC, the value these fields add is that they let the mgmt app extract only the command processing time, eliminating any variance do to queue before/after.
Right, this is precisely the motivation.
Thanks,
Roman.
Quoted 15 lines · Roman Kagan
Quoted 14 lines · Markus Armbruster
Quoted 12 lines · Daniel P. Berrangé
Quoted 11 lines · Denis Plotnikov
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.
Quoted 7 lines
Quoted 4 lines
Seconds and microseconds since when? The update to qmp-spec.txt should tell.
Why split the time into seconds and microseconds?
This is exactly how timestamps in QMP events are done, so we thought we'd just follow suit
Yes, I think its good to have consistency with the rest of the spec, despite Markus' point that it could be simplified to one field.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|