From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
Adam Litke <agl@us.ibm.com>
Subject: [Qemu-devel] [PATCH 2/4] qmp: add block_job_set_speed command
Date: Tue, 23 Aug 2011 13:58:23 +0100 [thread overview]
Message-ID: <1314104305-20523-3-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1314104305-20523-1-git-send-email-stefanha@linux.vnet.ibm.com>
This patch introduces the block_job_set_speed HMP/QMP command. It is
currently unimplemented and returns the 'NotSupported' error.
block_job_set_speed
-------------------
Set maximum speed for a background block operation.
This command can only be issued when there is an active block job.
Throttling can be disabled by setting the speed to 0.
Arguments:
- device: device name (json-string)
- value: maximum speed, in bytes per second (json-int)
Errors:
NotSupported: job type does not support speed setting
DeviceNotActive: streaming is not active on this device
Example:
-> { "execute": "block_job_set_speed",
"arguments": { "device": "virtio0", "value": 1024 } }
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
blockdev.c | 19 +++++++++++++++++++
blockdev.h | 2 ++
hmp-commands.hx | 15 +++++++++++++++
qmp-commands.hx | 35 +++++++++++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 208bfc9..ee40263 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -808,3 +808,22 @@ int do_block_stream(Monitor *mon, const QDict *params, QObject **ret_data)
qerror_report(QERR_NOT_SUPPORTED);
return -1;
}
+
+int do_block_job_set_speed(Monitor *mon, const QDict *params,
+ QObject **ret_data)
+{
+ const char *device = qdict_get_str(params, "device");
+ BlockDriverState *bs;
+
+ bs = bdrv_find(device);
+ if (!bs) {
+ qerror_report(QERR_DEVICE_NOT_ACTIVE, device);
+ return -1;
+ }
+
+ /* This command is not yet implemented. The device not found check above
+ * is done so that error ordering will not change when fully implemented.
+ */
+ qerror_report(QERR_NOT_SUPPORTED);
+ return -1;
+}
diff --git a/blockdev.h b/blockdev.h
index ad98d37..6b48405 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -66,5 +66,7 @@ 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);
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);
#endif
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 2a16fd9..a5fb4d5 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -86,6 +86,21 @@ Copy data from a backing file into a block device.
ETEXI
{
+ .name = "block_job_set_speed",
+ .args_type = "device:B,value:o",
+ .params = "device value",
+ .help = "set maximum speed for a background block operation",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_block_job_set_speed,
+ },
+
+STEXI
+@item block_job_set_stream
+@findex block_job_set_stream
+Set maximum speed for a background block operation.
+ETEXI
+
+ {
.name = "eject",
.args_type = "force:-f,device:B",
.params = "[-f] device",
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 60c9bdf..eface05 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -759,6 +759,41 @@ Examples:
EQMP
{
+ .name = "block_job_set_speed",
+ .args_type = "device:B,value:o",
+ .params = "device value",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_block_job_set_speed,
+ },
+
+SQMP
+
+block_job_set_speed
+-------------------
+
+Set maximum speed for a background block operation.
+
+This command can only be issued when there is an active block job.
+
+Throttling can be disabled by setting the speed to 0.
+
+Arguments:
+
+- device: device name (json-string)
+- value: maximum speed, in bytes per second (json-int)
+
+Errors:
+NotSupported: job type does not support speed setting
+DeviceNotActive: streaming is not active on this device
+
+Example:
+
+-> { "execute": "block_job_set_speed",
+ "arguments": { "device": "virtio0", "value": 1024 } }
+
+EQMP
+
+ {
.name = "blockdev-snapshot-sync",
.args_type = "device:B,snapshot-file:s?,format:s?",
.params = "device [new-image-file] [format]",
--
1.7.5.4
next prev parent reply other threads:[~2011-08-23 12:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-23 12:58 [Qemu-devel] [PATCH 0/4] Image Streaming API Stefan Hajnoczi
2011-08-23 12:58 ` [Qemu-devel] [PATCH 1/4] qmp: add block_stream command Stefan Hajnoczi
2011-08-23 16:33 ` Adam Litke
2011-08-30 9:43 ` Stefan Hajnoczi
2011-08-23 12:58 ` Stefan Hajnoczi [this message]
2011-08-23 12:58 ` [Qemu-devel] [PATCH 3/4] qmp: add block_job_cancel command Stefan Hajnoczi
2011-08-23 12:58 ` [Qemu-devel] [PATCH 4/4] qmp: add query-block-jobs Stefan Hajnoczi
2011-08-23 16:28 ` Adam Litke
2011-08-29 19:16 ` [Qemu-devel] [PATCH 0/4] Image Streaming API Anthony Liguori
2011-08-29 19:45 ` Luiz Capitulino
2011-08-30 3:19 ` Zhi Yong Wu
2011-08-30 9:28 ` Stefan Hajnoczi
2011-08-30 13:32 ` Adam Litke
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=1314104305-20523-3-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=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).