===================================================================
@@ -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)
===================================================================
@@ -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);
===================================================================
@@ -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.
*/
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 <mtosatti@redhat.com>