From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgZMf-0005oA-3T for qemu-devel@nongnu.org; Fri, 30 Dec 2011 05:07:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgZMc-0003L4-VN for qemu-devel@nongnu.org; Fri, 30 Dec 2011 05:07:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:26150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgZMc-0003KO-ON for qemu-devel@nongnu.org; Fri, 30 Dec 2011 05:07:02 -0500 Message-Id: <20111230100503.173568803@redhat.com> Date: Fri, 30 Dec 2011 08:03:38 -0200 From: Marcelo Tosatti References: <20111230100337.226685961@redhat.com> Content-Disposition: inline; filename=bdrv-stream-shared-base-helpers Subject: [Qemu-devel] [patch 1/5] block: add bdrv_find_backing_image List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: stefanha@linux.vnet.ibm.com, kwolf@redhat.com, qemu-devel@nongnu.org Cc: Marcelo Tosatti Add bdrv_find_backing_image: given a BlockDriverState pointer, and an id, traverse the backing image chain to locate the id. Signed-off-by: Marcelo Tosatti Index: stefanha/block.c =================================================================== --- stefanha.orig/block.c +++ stefanha/block.c @@ -2580,6 +2580,23 @@ int bdrv_snapshot_load_tmp(BlockDriverSt return -ENOTSUP; } +/* + * Return the BlockDriverState pointer for a backing image + * with 'id'. + */ +BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, + const char *id) +{ + BlockDriver *drv = bs->drv; + if (!drv) { + return NULL; + } + if (drv->bdrv_find_backing_image) { + return drv->bdrv_find_backing_image(bs, id); + } + return NULL; +} + #define NB_SUFFIXES 4 char *get_human_readable_size(char *buf, int buf_size, int64_t size) Index: stefanha/block.h =================================================================== --- stefanha.orig/block.h +++ stefanha/block.h @@ -146,6 +146,7 @@ int coroutine_fn bdrv_co_writev(BlockDri int nb_sectors, QEMUIOVector *qiov); int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum); +BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *id); int bdrv_truncate(BlockDriverState *bs, int64_t offset); int64_t bdrv_getlength(BlockDriverState *bs); int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); Index: stefanha/block_int.h =================================================================== --- stefanha.orig/block_int.h +++ stefanha/block_int.h @@ -136,6 +136,9 @@ struct BlockDriver { int coroutine_fn (*bdrv_co_is_allocated)(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum); + BlockDriverState *(*bdrv_find_backing_image)(BlockDriverState *bs, + const char *id); + /* * Invalidate any cached meta-data. */