mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-28 21:03:54 -06:00
job: Move defer_to_main_loop to Job
Move the defer_to_main_loop functionality from BlockJob to Job. The code can be simplified because we can use job->aio_context in job_defer_to_main_loop_bh() now, instead of having to access the BlockDriverState. Probably taking the data->aio_context lock in addition was already unnecessary in the old code because we didn't actually make use of anything protected by the old AioContext except getting the new AioContext, in case it changed between scheduling the BH and running it. But it's certainly unnecessary now that the BDS isn't accessed at all any more. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
parent
08be6fe26f
commit
1908a5590c
12 changed files with 97 additions and 110 deletions
|
@ -72,9 +72,10 @@ typedef struct {
|
|||
int ret;
|
||||
} CommitCompleteData;
|
||||
|
||||
static void commit_complete(BlockJob *job, void *opaque)
|
||||
static void commit_complete(Job *job, void *opaque)
|
||||
{
|
||||
CommitBlockJob *s = container_of(job, CommitBlockJob, common);
|
||||
CommitBlockJob *s = container_of(job, CommitBlockJob, common.job);
|
||||
BlockJob *bjob = &s->common;
|
||||
CommitCompleteData *data = opaque;
|
||||
BlockDriverState *top = blk_bs(s->top);
|
||||
BlockDriverState *base = blk_bs(s->base);
|
||||
|
@ -90,7 +91,7 @@ static void commit_complete(BlockJob *job, void *opaque)
|
|||
* the normal backing chain can be restored. */
|
||||
blk_unref(s->base);
|
||||
|
||||
if (!job_is_cancelled(&s->common.job) && ret == 0) {
|
||||
if (!job_is_cancelled(job) && ret == 0) {
|
||||
/* success */
|
||||
ret = bdrv_drop_intermediate(s->commit_top_bs, base,
|
||||
s->backing_file_str);
|
||||
|
@ -114,7 +115,7 @@ static void commit_complete(BlockJob *job, void *opaque)
|
|||
* block_job_finish_sync()), block_job_completed() won't free it and
|
||||
* therefore the blockers on the intermediate nodes remain. This would
|
||||
* cause bdrv_set_backing_hd() to fail. */
|
||||
block_job_remove_all_bdrv(job);
|
||||
block_job_remove_all_bdrv(bjob);
|
||||
|
||||
block_job_completed(&s->common, ret);
|
||||
g_free(data);
|
||||
|
@ -211,7 +212,7 @@ out:
|
|||
|
||||
data = g_malloc(sizeof(*data));
|
||||
data->ret = ret;
|
||||
block_job_defer_to_main_loop(&s->common, commit_complete, data);
|
||||
job_defer_to_main_loop(&s->common.job, commit_complete, data);
|
||||
}
|
||||
|
||||
static const BlockJobDriver commit_job_driver = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue