From bcada37b19e79329c47a956c4c2dd5c81727e8c8 Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Wed, 18 Jun 2014 08:43:47 +0200 Subject: 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 Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- blockdev.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'blockdev.c') diff --git a/blockdev.c b/blockdev.c index 9b0f8ac45e..03ab153d01 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1847,23 +1847,21 @@ void qmp_block_resize(bool has_device, const char *device, static void block_job_cb(void *opaque, int ret) { BlockDriverState *bs = opaque; - QObject *obj; + const char *msg = NULL; trace_block_job_cb(bs, bs->job, ret); assert(bs->job); - obj = qobject_from_block_job(bs->job); + if (ret < 0) { - QDict *dict = qobject_to_qdict(obj); - qdict_put(dict, "error", qstring_from_str(strerror(-ret))); + msg = strerror(-ret); } if (block_job_is_cancelled(bs->job)) { - monitor_protocol_event(QEVENT_BLOCK_JOB_CANCELLED, obj); + block_job_event_cancelled(bs->job); } else { - monitor_protocol_event(QEVENT_BLOCK_JOB_COMPLETED, obj); + block_job_event_completed(bs->job, msg); } - qobject_decref(obj); bdrv_put_ref_bh_schedule(bs); } -- cgit v1.2.3