diff options
author | Wenchao Xia <wenchaoqemu@gmail.com> | 2014-06-18 08:43:47 +0200 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2014-06-23 11:12:28 -0400 |
commit | bcada37b19e79329c47a956c4c2dd5c81727e8c8 (patch) | |
tree | dd6891d7cfda07168a47bc27aaffac34e810e7ee /blockjob.c | |
parent | c120f0fa14cd763d57270933713dbb25de5446fd (diff) |
qapi event: convert other BLOCK_JOB events
Since BLOCK_JOB_COMPLETED, BLOCK_JOB_CANCELLED, BLOCK_JOB_READY are
related, convert them in one patch. The block_job_event_* functions
are used to keep encapsulation of BlockJob structure.
Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'blockjob.c')
-rw-r--r-- | blockjob.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/blockjob.c b/blockjob.c index ee2a6fbbdc..4da86cdfcd 100644 --- a/blockjob.c +++ b/blockjob.c @@ -26,7 +26,6 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor/monitor.h" #include "block/block.h" #include "block/blockjob.h" #include "block/block_int.h" @@ -233,26 +232,31 @@ static void block_job_iostatus_set_err(BlockJob *job, int error) } } +void block_job_event_cancelled(BlockJob *job) +{ + qapi_event_send_block_job_cancelled(job->driver->job_type, + bdrv_get_device_name(job->bs), + job->len, + job->offset, + job->speed, + &error_abort); +} -QObject *qobject_from_block_job(BlockJob *job) +void block_job_event_completed(BlockJob *job, const char *msg) { - return qobject_from_jsonf("{ 'type': %s," - "'device': %s," - "'len': %" PRId64 "," - "'offset': %" PRId64 "," - "'speed': %" PRId64 " }", - BlockJobType_lookup[job->driver->job_type], - bdrv_get_device_name(job->bs), - job->len, - job->offset, - job->speed); + qapi_event_send_block_job_completed(job->driver->job_type, + bdrv_get_device_name(job->bs), + job->len, + job->offset, + job->speed, + !!msg, + msg, + &error_abort); } -void block_job_ready(BlockJob *job) +void block_job_event_ready(BlockJob *job) { - QObject *data = qobject_from_block_job(job); - monitor_protocol_event(QEVENT_BLOCK_JOB_READY, data); - qobject_decref(data); + qapi_event_send_block_job_ready(bdrv_get_device_name(job->bs), &error_abort); } BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs, |