From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
Adam Litke <agl@us.ibm.com>
Subject: [Qemu-devel] [PATCH 10/15] qmp: add query-block-jobs command
Date: Wed, 27 Jul 2011 14:44:50 +0100 [thread overview]
Message-ID: <1311774295-8696-11-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1311774295-8696-1-git-send-email-stefanha@linux.vnet.ibm.com>
Active image streaming operations can be enumerated with the
query-block-jobs command. Each operation is listed along with its
total progress.
The command synopsis is:
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 <stefanha@linux.vnet.ibm.com>
---
blockdev.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
blockdev.h | 2 ++
hmp-commands.hx | 2 ++
monitor.c | 16 ++++++++++++++++
qmp-commands.hx | 31 +++++++++++++++++++++++++++++++
5 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index e9bc577..422b43b 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -802,6 +802,52 @@ out:
return ret;
}
+static void monitor_print_block_stream(Monitor *mon, const QObject *data)
+{
+ QDict *stream;
+
+ assert(data);
+ stream = qobject_to_qdict(data);
+
+ monitor_printf(mon, "Streaming device %s: Completed %" PRId64 " of %"
+ PRId64 " bytes, speed limit %" PRId64 " bytes/s\n",
+ qdict_get_str(stream, "device"),
+ qdict_get_int(stream, "offset"),
+ qdict_get_int(stream, "len"),
+ (int64_t)0);
+}
+
+void monitor_print_block_jobs(Monitor *mon, const QObject *data)
+{
+ QList *streams;
+ QListEntry *entry;
+
+ assert(data);
+ streams = qobject_to_qlist(data);
+ assert(streams); /* we pass a list of stream objects to ourselves */
+
+ if (qlist_empty(streams)) {
+ monitor_printf(mon, "No active jobs\n");
+ return;
+ }
+
+ QLIST_FOREACH_ENTRY(streams, entry) {
+ monitor_print_block_stream(mon, entry->value);
+ }
+}
+
+void do_info_block_jobs(Monitor *mon, QObject **ret_data)
+{
+ QList *streams;
+ StreamState *s;
+
+ streams = qlist_new();
+ QLIST_FOREACH(s, &block_streams, list) {
+ qlist_append_obj(streams, stream_get_qobject(s));
+ }
+ *ret_data = QOBJECT(streams);
+}
+
int do_block_stream(Monitor *mon, const QDict *params, QObject **ret_data)
{
const char *device = qdict_get_str(params, "device");
diff --git a/blockdev.h b/blockdev.h
index a3cde69..0a32793 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -66,6 +66,8 @@ int do_change_block(Monitor *mon, const char *device,
int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data);
int do_block_resize(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);
int do_block_stream(Monitor *mon, const QDict *params, QObject **ret_data);
int do_block_job_cancel(Monitor *mon, const QDict *params,
MonitorCompletion cb, void *opaque);
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 613eb76..74a74d8 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1383,6 +1383,8 @@ show device tree
show qdev device model list
@item info roms
show roms
+@item info block-jobs
+show progress of background block device operations
@end table
ETEXI
diff --git a/monitor.c b/monitor.c
index 700b534..bc2f630 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3141,6 +3141,14 @@ static const mon_cmd_t info_cmds[] = {
},
#endif
{
+ .name = "block-jobs",
+ .args_type = "",
+ .params = "",
+ .help = "show block job status",
+ .user_print = monitor_print_block_jobs,
+ .mhandler.info_new = do_info_block_jobs,
+ },
+ {
.name = NULL,
},
};
@@ -3282,6 +3290,14 @@ static const mon_cmd_t qmp_query_cmds[] = {
.mhandler.info_async = do_info_balloon,
.flags = MONITOR_CMD_ASYNC,
},
+ {
+ .name = "block-jobs",
+ .args_type = "",
+ .params = "",
+ .help = "show block job status",
+ .user_print = monitor_print_block_jobs,
+ .mhandler.info_new = do_info_block_jobs,
+ },
{ /* NULL */ },
};
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 5ab15a4..c3a72ad 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1971,3 +1971,34 @@ 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
next prev parent reply other threads:[~2011-07-27 13:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-27 13:44 [Qemu-devel] [RFC v2 00/15] QED image streaming Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 01/15] block: add -drive copy-on-read=on|off Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 02/15] qed: replace is_write with flags field Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 03/15] qed: extract qed_start_allocating_write() Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 04/15] qed: make qed_aio_write_alloc() reusable Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 05/15] qed: add support for copy-on-read Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 06/15] qed: avoid deadlock on emulated synchronous I/O Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 07/15] block: add bdrv_aio_copy_backing() Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 08/15] qmp: add block_stream command Stefan Hajnoczi
2011-07-28 15:53 ` Marcelo Tosatti
2011-07-28 15:57 ` Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 09/15] qmp: add block_job_cancel command Stefan Hajnoczi
2011-07-27 13:44 ` Stefan Hajnoczi [this message]
2011-07-27 13:44 ` [Qemu-devel] [PATCH 11/15] qmp: add block_job_set_speed command Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 12/15] block: add -drive stream=on|off Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 13/15] qed: intelligent streaming implementation Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 14/15] trace: trace bdrv_aio_readv/writev error paths Stefan Hajnoczi
2011-07-27 13:44 ` [Qemu-devel] [PATCH 15/15] tests: add image streaming QMP interface tests Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1311774295-8696-11-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=agl@us.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).