mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
blockjob: centralize QMP event emissions
There's no reason to leave this to blockdev; we can do it in blockjobs directly and get rid of an extra callback for most users. All non-internal events, even those created outside of QMP, will consistently emit events. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Message-id: 1477584421-1399-5-git-send-email-jsnow@redhat.com Signed-off-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
parent
47970dfb0a
commit
8254b6d953
8 changed files with 42 additions and 83 deletions
42
blockdev.c
42
blockdev.c
|
@ -2905,31 +2905,6 @@ out:
|
|||
aio_context_release(aio_context);
|
||||
}
|
||||
|
||||
static void block_job_cb(void *opaque, int ret)
|
||||
{
|
||||
/* Note that this function may be executed from another AioContext besides
|
||||
* the QEMU main loop. If you need to access anything that assumes the
|
||||
* QEMU global mutex, use a BH or introduce a mutex.
|
||||
*/
|
||||
|
||||
BlockDriverState *bs = opaque;
|
||||
const char *msg = NULL;
|
||||
|
||||
trace_block_job_cb(bs, bs->job, ret);
|
||||
|
||||
assert(bs->job);
|
||||
|
||||
if (ret < 0) {
|
||||
msg = strerror(-ret);
|
||||
}
|
||||
|
||||
if (block_job_is_cancelled(bs->job)) {
|
||||
block_job_event_cancelled(bs->job);
|
||||
} else {
|
||||
block_job_event_completed(bs->job, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
|
||||
bool has_base, const char *base,
|
||||
bool has_base_node, const char *base_node,
|
||||
|
@ -3005,7 +2980,7 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
|
|||
base_name = has_backing_file ? backing_file : base_name;
|
||||
|
||||
stream_start(has_job_id ? job_id : NULL, bs, base_bs, base_name,
|
||||
has_speed ? speed : 0, on_error, block_job_cb, bs, &local_err);
|
||||
has_speed ? speed : 0, on_error, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
goto out;
|
||||
|
@ -3111,16 +3086,16 @@ void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
|
|||
goto out;
|
||||
}
|
||||
commit_active_start(has_job_id ? job_id : NULL, bs, base_bs,
|
||||
BLOCK_JOB_DEFAULT, speed, on_error, block_job_cb,
|
||||
bs, &local_err, false);
|
||||
BLOCK_JOB_DEFAULT, speed, on_error, NULL, NULL,
|
||||
&local_err, false);
|
||||
} else {
|
||||
BlockDriverState *overlay_bs = bdrv_find_overlay(bs, top_bs);
|
||||
if (bdrv_op_is_blocked(overlay_bs, BLOCK_OP_TYPE_COMMIT_TARGET, errp)) {
|
||||
goto out;
|
||||
}
|
||||
commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, speed,
|
||||
on_error, block_job_cb, bs,
|
||||
has_backing_file ? backing_file : NULL, &local_err);
|
||||
on_error, has_backing_file ? backing_file : NULL,
|
||||
&local_err);
|
||||
}
|
||||
if (local_err != NULL) {
|
||||
error_propagate(errp, local_err);
|
||||
|
@ -3241,7 +3216,7 @@ static void do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, Error **errp)
|
|||
backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync,
|
||||
bmap, backup->compress, backup->on_source_error,
|
||||
backup->on_target_error, BLOCK_JOB_DEFAULT,
|
||||
block_job_cb, bs, txn, &local_err);
|
||||
NULL, NULL, txn, &local_err);
|
||||
bdrv_unref(target_bs);
|
||||
if (local_err != NULL) {
|
||||
error_propagate(errp, local_err);
|
||||
|
@ -3312,7 +3287,7 @@ void do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn, Error **errp)
|
|||
backup_start(backup->job_id, bs, target_bs, backup->speed, backup->sync,
|
||||
NULL, backup->compress, backup->on_source_error,
|
||||
backup->on_target_error, BLOCK_JOB_DEFAULT,
|
||||
block_job_cb, bs, txn, &local_err);
|
||||
NULL, NULL, txn, &local_err);
|
||||
if (local_err != NULL) {
|
||||
error_propagate(errp, local_err);
|
||||
}
|
||||
|
@ -3391,8 +3366,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
|
|||
mirror_start(job_id, bs, target,
|
||||
has_replaces ? replaces : NULL,
|
||||
speed, granularity, buf_size, sync, backing_mode,
|
||||
on_source_error, on_target_error, unmap,
|
||||
block_job_cb, bs, errp);
|
||||
on_source_error, on_target_error, unmap, errp);
|
||||
}
|
||||
|
||||
void qmp_drive_mirror(DriveMirror *arg, Error **errp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue