From 1c95f7e1aff8417ff6e6cc23bc2d04fbcf79d37e Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Mon, 26 Oct 2015 21:39:05 +0100 Subject: block: Add blk_remove_bs() This function removes the BlockDriverState associated with the given BlockBackend from that BB and sets the BDS pointer in the BB to NULL. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/block-backend.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'block') diff --git a/block/block-backend.c b/block/block-backend.c index 19fdaaec1a..878c448855 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -333,6 +333,18 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk) } } +/* + * Disassociates the currently associated BlockDriverState from @blk. + */ +void blk_remove_bs(BlockBackend *blk) +{ + blk_update_root_state(blk); + + blk->bs->blk = NULL; + bdrv_unref(blk->bs); + blk->bs = NULL; +} + /* * Associates a new BlockDriverState with @blk. */ -- cgit v1.2.3