[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 10/15] blockjob: Add 'id' parameter to 'block-job
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH v2 10/15] blockjob: Add 'id' parameter to 'block-job-set-speed' |
Date: |
Wed, 22 Jun 2016 15:25:07 +0300 |
This patch allows the 'block-job-set-speed' command to identify the
job by either its ID or its device name. The latter becomes now
optional since the ID alone is enough to identify the job.
The HMP 'block_job_set_speed' command remains unchanged.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
blockdev.c | 7 +++++--
hmp.c | 2 +-
qapi/block-core.json | 9 +++++++--
qmp-commands.hx | 2 +-
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 4c2f659..bd276ee 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3760,10 +3760,13 @@ static BlockJob *find_block_job(const char *id, const
char *device,
return job;
}
-void qmp_block_job_set_speed(const char *device, int64_t speed, Error **errp)
+void qmp_block_job_set_speed(bool has_id, const char *id, bool has_device,
+ const char *device, int64_t speed, Error **errp)
{
AioContext *aio_context;
- BlockJob *job = find_block_job(NULL, device, &aio_context, errp);
+ BlockJob *job = find_block_job(has_id ? id : NULL,
+ has_device ? device : NULL,
+ &aio_context, errp);
if (!job) {
return;
diff --git a/hmp.c b/hmp.c
index 6b7786e..f498ccd 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1498,7 +1498,7 @@ void hmp_block_job_set_speed(Monitor *mon, const QDict
*qdict)
const char *device = qdict_get_str(qdict, "device");
int64_t value = qdict_get_int(qdict, "speed");
- qmp_block_job_set_speed(device, value, &error);
+ qmp_block_job_set_speed(false, NULL, true, device, value, &error);
hmp_handle_error(mon, &error);
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
index f754c29..64038cc 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1469,7 +1469,12 @@
#
# Throttling can be disabled by setting the speed to 0.
#
-# @device: the device name
+# The job must be identified with the @id or @device parameters, but
+# only one of them must be set.
+#
+# @id: #optional the job identifier. (Since 2.7)
+#
+# @device: #optional the device name.
#
# @speed: the maximum speed, in bytes per second, or 0 for unlimited.
# Defaults to 0.
@@ -1480,7 +1485,7 @@
# Since: 1.1
##
{ 'command': 'block-job-set-speed',
- 'data': { 'device': 'str', 'speed': 'int' } }
+ 'data': { '*id': 'str', '*device': 'str', 'speed': 'int' } }
##
# @block-job-cancel:
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 9ee14a8..cc70007 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1311,7 +1311,7 @@ EQMP
{
.name = "block-job-set-speed",
- .args_type = "device:B,speed:o",
+ .args_type = "id:s?,device:B?,speed:o",
.mhandler.cmd_new = qmp_marshal_block_job_set_speed,
},
--
2.8.1
- [Qemu-devel] [PATCH v2 06/15] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror', (continued)
- [Qemu-devel] [PATCH v2 06/15] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror', Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 01/15] stream: Fix prototype of stream_start(), Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 08/15] stream: Add 'job-id' parameter to 'block-stream', Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 09/15] commit: Add 'job-id' parameter to 'block-commit', Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 02/15] blockjob: Decouple the ID from the device name in the BlockJob struct, Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 05/15] blockjob: Add 'job_id' parameter to block_job_create(), Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 04/15] block: Simplify find_block_job() and make it accept a job ID, Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 10/15] blockjob: Add 'id' parameter to 'block-job-set-speed',
Alberto Garcia <=
- [Qemu-devel] [PATCH v2 15/15] blockjob: Add 'id' field to 'BlockJobInfo' and all BLOCK_JOB_* events, Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 12/15] blockjob: Add 'id' parameter to 'block-job-pause', Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 13/15] blockjob: Add 'id' parameter to 'block-job-resume', Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 14/15] blockjob: Add 'id' parameter to 'block-job-complete', Alberto Garcia, 2016/06/22
- [Qemu-devel] [PATCH v2 11/15] blockjob: Add 'id' parameter to 'block-job-cancel', Alberto Garcia, 2016/06/22