From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqoYD-0007Pq-8E for qemu-devel@nongnu.org; Mon, 26 Oct 2015 16:39:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqoYC-00042x-0n for qemu-devel@nongnu.org; Mon, 26 Oct 2015 16:39:29 -0400 From: Max Reitz Date: Mon, 26 Oct 2015 21:39:05 +0100 Message-Id: <1445891959-27432-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1445891959-27432-1-git-send-email-mreitz@redhat.com> References: <1445891959-27432-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v8 01/15] block: Add blk_remove_bs() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: Kevin Wolf , Alberto Garcia , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz , John Snow , Stefan Hajnoczi 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 --- block/block-backend.c | 12 ++++++++++++ include/sysemu/block-backend.h | 1 + 2 files changed, 13 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 19fdaae..878c448 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -334,6 +334,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. */ void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 9306a52..14a6d32 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -72,6 +72,7 @@ BlockBackend *blk_by_name(const char *name); BlockBackend *blk_next(BlockBackend *blk); BlockDriverState *blk_bs(BlockBackend *blk); +void blk_remove_bs(BlockBackend *blk); void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs); void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk); -- 2.6.2