diff options
author | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2012-01-18 14:40:48 +0000 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2012-01-26 14:49:18 +0100 |
commit | 370521a1d6f5537ea7271c119f3fbb7b0fa57063 (patch) | |
tree | c94fba9ff82e7690dd9d20a6420cd808b40d5d11 /blockdev.c | |
parent | 2d47c6e9aa2475807913bd46dfca55980cca9fb4 (diff) |
qmp: add block_job_cancel command
Add block_job_cancel, which stops an active block streaming operation.
When the operation has been cancelled the new BLOCK_JOB_CANCELLED event
is emitted.
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.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/blockdev.c b/blockdev.c index 4c8fcdd31e..d3d6718056 100644 --- a/blockdev.c +++ b/blockdev.c @@ -928,7 +928,11 @@ static void block_stream_cb(void *opaque, int ret) qdict_put(dict, "error", qstring_from_str(strerror(-ret))); } - monitor_protocol_event(QEVENT_BLOCK_JOB_COMPLETED, obj); + if (block_job_is_cancelled(bs->job)) { + monitor_protocol_event(QEVENT_BLOCK_JOB_CANCELLED, obj); + } else { + monitor_protocol_event(QEVENT_BLOCK_JOB_COMPLETED, obj); + } qobject_decref(obj); } @@ -989,3 +993,16 @@ void qmp_block_job_set_speed(const char *device, int64_t value, Error **errp) error_set(errp, QERR_NOT_SUPPORTED); } } + +void qmp_block_job_cancel(const char *device, Error **errp) +{ + BlockJob *job = find_block_job(device); + + if (!job) { + error_set(errp, QERR_DEVICE_NOT_ACTIVE, device); + return; + } + + trace_qmp_block_job_cancel(job); + block_job_cancel(job); +} |