From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxDs8-0003Ib-6W for qemu-devel@nongnu.org; Thu, 20 Oct 2016 09:59:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxDs3-0000Un-G1 for qemu-devel@nongnu.org; Thu, 20 Oct 2016 09:59:04 -0400 From: zhanghailiang Date: Thu, 20 Oct 2016 21:57:35 +0800 Message-ID: <1476971860-20860-3-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1476971860-20860-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1476971860-20860-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH RFC 2/7] block-backend: Introduce blk_root() helper List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, qemu-block@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, wency@cn.fujitsu.com, xiecl.fnst@cn.fujitsu.com, zhanghailiang With this helper function, we can get the BdrvChild struct from BlockBackend Signed-off-by: zhanghailiang --- block/block-backend.c | 5 +++++ include/sysemu/block-backend.h | 1 + 2 files changed, 6 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 1a724a8..66387f0 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -389,6 +389,11 @@ BlockDriverState *blk_bs(BlockBackend *blk) return blk->root ? blk->root->bs : NULL; } +BdrvChild *blk_root(BlockBackend *blk) +{ + return blk->root; +} + static BlockBackend *bdrv_first_blk(BlockDriverState *bs) { BdrvChild *child; diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index b07159b..867f9f5 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -99,6 +99,7 @@ void blk_remove_bs(BlockBackend *blk); void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs); bool bdrv_has_blk(BlockDriverState *bs); bool bdrv_is_root_node(BlockDriverState *bs); +BdrvChild *blk_root(BlockBackend *blk); void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow); void blk_iostatus_enable(BlockBackend *blk); -- 1.8.3.1