@@ -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;
+}
@@ -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
@@ -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",
@@ -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]",
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(-)