Received: from eggs.gnu.org ([208.118.235.92]:46604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxKxa-0006NU-EN for qemu-devel@nongnu.org; Fri, 03 Aug 2012 12:42:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SxKxQ-0002TL-IP for qemu-devel@nongnu.org; Fri, 03 Aug 2012 12:42:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxKxQ-0002T9-8p for qemu-devel@nongnu.org; Fri, 03 Aug 2012 12:42:36 -0400 From: Luiz Capitulino Date: Fri, 3 Aug 2012 13:42:56 -0300 Message-Id: <1344012178-21084-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1344012178-21084-1-git-send-email-lcapitulino@redhat.com> References: <1344012178-21084-1-git-send-email-lcapitulino@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 2/4] block: create bdrv_get_backing_file_depth() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@us.ibm.com Cc: =?UTF-8?q?Beno=C3=AEt=20Canet?= , qemu-devel@nongnu.org, Benoit Canet From: Beno=C3=AEt Canet Create bdrv_get_backing_file_depth() in order to be able to show in QMP and HMP how many ancestors backing an image a block device have. Signed-off-by: Benoit Canet Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- block.c | 13 +++++++++++++ block.h | 1 + 2 files changed, 14 insertions(+) diff --git a/block.c b/block.c index b38940b..1206bba 100644 --- a/block.c +++ b/block.c @@ -2754,6 +2754,19 @@ BlockDriverState *bdrv_find_backing_image(BlockDri= verState *bs, return NULL; } =20 +int bdrv_get_backing_file_depth(BlockDriverState *bs) +{ + if (!bs->drv) { + return 0; + } + + if (!bs->backing_hd) { + return 0; + } + + return 1 + bdrv_get_backing_file_depth(bs->backing_hd); +} + #define NB_SUFFIXES 4 =20 char *get_human_readable_size(char *buf, int buf_size, int64_t size) diff --git a/block.h b/block.h index c89590d..650d872 100644 --- a/block.h +++ b/block.h @@ -174,6 +174,7 @@ int coroutine_fn bdrv_co_is_allocated_above(BlockDriv= erState *top, int nb_sectors, int *pnum); BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file); +int bdrv_get_backing_file_depth(BlockDriverState *bs); int bdrv_truncate(BlockDriverState *bs, int64_t offset); int64_t bdrv_getlength(BlockDriverState *bs); int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); --=20 1.7.11.2.249.g31c7954.dirty