@@ -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;
@@ -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);
}
@@ -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:
@@ -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,
},