From patchwork Thu Oct 20 13:57:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 684649 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t0BPl2B7pz9s65 for ; Fri, 21 Oct 2016 01:43:23 +1100 (AEDT) Received: from localhost ([::1]:55260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxEYy-0005nR-5R for incoming@patchwork.ozlabs.org; Thu, 20 Oct 2016 10:43:20 -0400 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 Received: from szxga03-in.huawei.com ([119.145.14.66]:29854) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1bxDs3-0000Sx-4o; Thu, 20 Oct 2016 09:58:59 -0400 Received: from 172.24.1.47 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CJX49060; Thu, 20 Oct 2016 21:58:28 +0800 (CST) Received: from localhost (10.177.24.212) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Thu, 20 Oct 2016 21:58:19 +0800 From: zhanghailiang To: , Date: Thu, 20 Oct 2016 21:57:35 +0800 Message-ID: <1476971860-20860-3-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 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 X-Originating-IP: [10.177.24.212] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Subject: [Qemu-devel] [PATCH RFC 2/7] block-backend: Introduce blk_root() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, xiecl.fnst@cn.fujitsu.com, zhanghailiang , mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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);