From b6d2e59995fa82c7fe469d47dfc22cf9bf2f8a5e Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 8 Apr 2016 14:51:09 +0200 Subject: 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 Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia Reviewed-by: Max Reitz --- include/block/blockjob.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 4ac6831..32012af 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -82,7 +82,8 @@ struct BlockJob { const BlockJobDriver *driver; /** The block device on which the job is operating. */ - BlockDriverState *bs; + BlockDriverState *bs; /* TODO Remove */ + BlockBackend *blk; /** * The ID of the block job. Currently the BlockBackend name of the BDS -- cgit v1.1