aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2012-01-18 14:40:47 +0000
committerKevin Wolf <kwolf@redhat.com>2012-01-26 14:49:17 +0100
commit2d47c6e9aa2475807913bd46dfca55980cca9fb4 (patch)
tree24c53c3bf120c063fc6ab0da03de7c715fe77138 /blockdev.c
parent12bd451fe0be83474910bb63b5874458141d4230 (diff)
qmp: add block_job_set_speed command
Add block_job_set_speed, which sets the maximum speed for a background block operation. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Acked-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c
index 06f179ef87..4c8fcdd31e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -964,3 +964,28 @@ void qmp_block_stream(const char *device, bool has_base,
trace_qmp_block_stream(bs, bs->job);
}
+
+static BlockJob *find_block_job(const char *device)
+{
+ BlockDriverState *bs;
+
+ bs = bdrv_find(device);
+ if (!bs || !bs->job) {
+ return NULL;
+ }
+ return bs->job;
+}
+
+void qmp_block_job_set_speed(const char *device, int64_t value, Error **errp)
+{
+ BlockJob *job = find_block_job(device);
+
+ if (!job) {
+ error_set(errp, QERR_DEVICE_NOT_ACTIVE, device);
+ return;
+ }
+
+ if (block_job_set_speed(job, value) < 0) {
+ error_set(errp, QERR_NOT_SUPPORTED);
+ }
+}