@@ -827,3 +827,11 @@ int do_block_job_set_speed(Monitor *mon, const QDict *params,
qerror_report(QERR_NOT_SUPPORTED);
return -1;
}
+
+int do_block_job_cancel(Monitor *mon, const QDict *params, QObject **ret_data)
+{
+ const char *device = qdict_get_str(params, "device");
+
+ qerror_report(QERR_DEVICE_NOT_ACTIVE, device);
+ return -1;
+}
@@ -68,5 +68,6 @@ 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);
+int do_block_job_cancel(Monitor *mon, const QDict *qdict, QObject **ret_data);
#endif
@@ -101,6 +101,21 @@ Set maximum speed for a background block operation.
ETEXI
{
+ .name = "block_job_cancel",
+ .args_type = "device:B",
+ .params = "device",
+ .help = "stop an active block streaming operation",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_block_job_cancel,
+ },
+
+STEXI
+@item block_job_cancel
+@findex block_job_cancel
+Stop an active block streaming operation.
+ETEXI
+
+ {
.name = "eject",
.args_type = "force:-f,device:B",
.params = "[-f] device",
@@ -794,6 +794,46 @@ Example:
EQMP
{
+ .name = "block_job_cancel",
+ .args_type = "device:B",
+ .params = "device",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_block_job_cancel,
+ },
+
+SQMP
+
+block_job_cancel
+----------------
+
+Stop an active block streaming operation.
+
+This command returns once the active block streaming operation has been
+stopped. It is an error to call this command if no operation is in progress.
+
+The image file retains its backing file unless the streaming operation happens
+to complete just as it is being cancelled.
+
+A new block streaming operation can be started at a later time to finish
+copying all data from the backing file.
+
+Arguments:
+
+- device: device name (json-string)
+
+Errors:
+
+DeviceNotActive: streaming is not active on this device
+DeviceInUse: cancellation already in progress
+
+Examples:
+
+-> { "execute": "block_job_cancel", "arguments": { "device": "virtio0" } }
+<- { "return": {} }
+
+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_cancel HMP/QMP command. It is currently unimplemented and returns the 'DeviceNotActive' error. block_job_cancel ---------------- Stop an active block streaming operation. This command returns once the active block streaming operation has been stopped. It is an error to call this command if no operation is in progress. The image file retains its backing file unless the streaming operation happens to complete just as it is being cancelled. A new block streaming operation can be started at a later time to finish copying all data from the backing file. Arguments: - device: device name (json-string) Errors: DeviceNotActive: streaming is not active on this device DeviceInUse: cancellation already in progress Examples: -> { "execute": "block_job_cancel", "arguments": { "device": "virtio0" } } <- { "return": {} } Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> --- blockdev.c | 8 ++++++++ blockdev.h | 1 + hmp-commands.hx | 15 +++++++++++++++ qmp-commands.hx | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 0 deletions(-)