From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:32826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvqYs-0007dp-1n for qemu-devel@nongnu.org; Tue, 23 Aug 2011 08:58:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QvqYq-00023W-Mr for qemu-devel@nongnu.org; Tue, 23 Aug 2011 08:58:33 -0400 Received: from mtagate3.uk.ibm.com ([194.196.100.163]:51796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvqYq-00023M-Fj for qemu-devel@nongnu.org; Tue, 23 Aug 2011 08:58:32 -0400 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p7NCwV7Q026385 for ; Tue, 23 Aug 2011 12:58:31 GMT Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p7NCwVOX2453702 for ; Tue, 23 Aug 2011 13:58:31 +0100 Received: from d06av08.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p7NCwVEO021120 for ; Tue, 23 Aug 2011 13:58:31 +0100 From: Stefan Hajnoczi Date: Tue, 23 Aug 2011 13:58:25 +0100 Message-Id: <1314104305-20523-5-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1314104305-20523-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1314104305-20523-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 4/4] qmp: add query-block-jobs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Stefan Hajnoczi , Adam Litke 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 --- 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