From f7cc69b326850c34db5dca2f9f74898cd181f43a Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 13 Jul 2017 18:30:28 +0300 Subject: block: add default implementations for bdrv_co_get_block_status() bdrv_co_get_block_status_from_file() and bdrv_co_get_block_status_from_backing() set *file to bs->file and bs->backing respectively, so that bdrv_co_get_block_status() can recurse to them. Future block drivers won't have to duplicate code to implement this. Reviewed-by: Fam Zheng Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Signed-off-by: Manos Pitsidianakis Signed-off-by: Kevin Wolf --- include/block/block_int.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/block') diff --git a/include/block/block_int.h b/include/block/block_int.h index ca4e7e5629..223801e4fb 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -964,6 +964,24 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared); +/* + * Default implementation for drivers to pass bdrv_co_get_block_status() to + * their file. + */ +int64_t coroutine_fn bdrv_co_get_block_status_from_file(BlockDriverState *bs, + int64_t sector_num, + int nb_sectors, + int *pnum, + BlockDriverState **file); +/* + * Default implementation for drivers to pass bdrv_co_get_block_status() to + * their backing file. + */ +int64_t coroutine_fn bdrv_co_get_block_status_from_backing(BlockDriverState *bs, + int64_t sector_num, + int nb_sectors, + int *pnum, + BlockDriverState **file); const char *bdrv_get_parent_name(const BlockDriverState *bs); void blk_dev_change_media_cb(BlockBackend *blk, bool load, Error **errp); bool blk_dev_has_removable_media(BlockBackend *blk); -- cgit v1.2.3