This patch introduces the query-block-jobs HMP/QMP command. It is currently unimplemented and returns an empty dict.
query-block-jobs ---------------- Show progress of ongoing block device operations. Return a json-array of all block device operations. If no operation is active then return an empty array. Each operation is a json-object with the following data: - type: job type ("stream" for image streaming, json-string) - device: device name (json-string) - end: maximum progress value (json-int) - position: current progress value (json-int) - speed: rate limit, bytes per second (json-int) Progress can be observed as position increases and it reaches end when the operation completes. Position and end have undefined units but can be used to calculate a percentage indicating the progress that has been made. Example: -> { "execute": "query-block-jobs" } <- { "return":[ { "type": "stream", "device": "virtio0", "end": 10737418240, "position": 709632, "speed": 0 } ] } Signed-off-by: Stefan Hajnoczi <stefa...@linux.vnet.ibm.com> --- blockdev.c | 10 ++++++++++ blockdev.h | 2 ++ monitor.c | 16 ++++++++++++++++ qmp-commands.hx | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 0 deletions(-) diff --git a/blockdev.c b/blockdev.c index 036b7eb..e9098f6 100644 --- a/blockdev.c +++ b/blockdev.c @@ -835,3 +835,13 @@ int do_block_job_cancel(Monitor *mon, const QDict *params, QObject **ret_data) qerror_report(QERR_DEVICE_NOT_ACTIVE, device); return -1; } + +void monitor_print_block_jobs(Monitor *mon, const QObject *data) +{ + monitor_printf(mon, "No active jobs\n"); +} + +void do_info_block_jobs(Monitor *mon, QObject **ret_data) +{ + *ret_data = QOBJECT(qdict_new()); +} diff --git a/blockdev.h b/blockdev.h index a132d36..f199d7a 100644 --- a/blockdev.h +++ b/blockdev.h @@ -69,5 +69,7 @@ int do_block_stream(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_block_job_set_speed(Monitor *mon, const QDict *qdict, QObject **ret_data); int do_block_job_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data); +void monitor_print_block_jobs(Monitor *mon, const QObject *data); +void do_info_block_jobs(Monitor *mon, QObject **ret_data); #endif diff --git a/monitor.c b/monitor.c index dc55fca..e832d10 100644 --- a/monitor.c +++ b/monitor.c @@ -2907,6 +2907,14 @@ static const mon_cmd_t info_cmds[] = { .mhandler.info_new = bdrv_info_stats, }, { + .name = "block-jobs", + .args_type = "", + .params = "", + .help = "show progress of ongoing block device operations", + .user_print = monitor_print_block_jobs, + .mhandler.info_new = do_info_block_jobs, + }, + { .name = "registers", .args_type = "", .params = "", @@ -3206,6 +3214,14 @@ static const mon_cmd_t qmp_query_cmds[] = { .mhandler.info_new = bdrv_info_stats, }, { + .name = "block-jobs", + .args_type = "", + .params = "", + .help = "show progress of ongoing block device operations", + .user_print = monitor_print_block_jobs, + .mhandler.info_new = do_info_block_jobs, + }, + { .name = "cpus", .args_type = "", .params = "", diff --git a/qmp-commands.hx b/qmp-commands.hx index de442f7..ffac014 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2006,3 +2006,35 @@ Example: EQMP +SQMP + +query-block-jobs +---------------- + +Show progress of ongoing block device operations. + +Return a json-array of all block device operations. If no operation is active +then return an empty array. Each operation is a json-object with the following +data: + +- type: job type ("stream" for image streaming, json-string) +- device: device name (json-string) +- end: maximum progress value (json-int) +- position: current progress value (json-int) +- speed: rate limit, bytes per second (json-int) + +Progress can be observed as position increases and it reaches end when the +operation completes. Position and end have undefined units but can be used to +calculate a percentage indicating the progress that has been made. + +Example: + +-> { "execute": "query-block-jobs" } +<- { "return":[ + { "type": "stream", "device": "virtio0", + "end": 10737418240, "position": 709632, + "speed": 0 } + ] + } + +EQMP -- 1.7.5.4