mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-18 05:28:36 -07:00
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>
This commit is contained in:
parent
c120f0fa14
commit
bcada37b19
6 changed files with 111 additions and 100 deletions
12
blockdev.c
12
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue