summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorKevin Wolf2016-04-08 14:51:09 +0200
committerKevin Wolf2016-05-25 19:04:21 +0200
commitb6d2e59995fa82c7fe469d47dfc22cf9bf2f8a5e (patch)
tree4c4b068514226799720a463ebee7016a592285e2 /block
parentblock: Default to enabled write cache in blk_new() (diff)
downloadqemu-b6d2e59995fa82c7fe469d47dfc22cf9bf2f8a5e.tar.gz
qemu-b6d2e59995fa82c7fe469d47dfc22cf9bf2f8a5e.tar.xz
qemu-b6d2e59995fa82c7fe469d47dfc22cf9bf2f8a5e.zip
block: Convert block job core to BlockBackend
This adds a new BlockBackend field to the BlockJob struct, which coexists with the BlockDriverState while converting the individual jobs. When creating a block job, a new BlockBackend is created on top of the given BlockDriverState, and it is destroyed when the BlockJob ends. The reference to the BDS is now held by the BlockBackend instead of calling bdrv_ref/unref manually. We have to be careful when we use bdrv_replace_in_backing_chain() in block jobs because this changes the BDS that job->blk points to. At the moment block jobs are too tightly coupled with their BDS, so that moving a job to another BDS isn't easily possible; therefore, we need to just manually undo this change afterwards. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/mirror.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/mirror.c b/block/mirror.c
index b9986d8218..efca8fc177 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -478,6 +478,9 @@ static void mirror_exit(BlockJob *job, void *opaque)
bdrv_reopen(s->target, bdrv_get_flags(to_replace), NULL);
}
bdrv_replace_in_backing_chain(to_replace, s->target);
+ /* We just changed the BDS the job BB refers to */
+ blk_remove_bs(job->blk);
+ blk_insert_bs(job->blk, src);
}
out: