mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
block: add bdrv_co_is_allocated() interface
This patch introduces the public bdrv_co_is_allocated() interface which can be used to query image allocation status while the VM is running. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
6aebab140d
commit
060f51c9de
2 changed files with 26 additions and 13 deletions
37
block.c
37
block.c
|
@ -1896,17 +1896,6 @@ typedef struct BdrvCoIsAllocatedData {
|
|||
bool done;
|
||||
} BdrvCoIsAllocatedData;
|
||||
|
||||
/* Coroutine wrapper for bdrv_is_allocated() */
|
||||
static void coroutine_fn bdrv_is_allocated_co_entry(void *opaque)
|
||||
{
|
||||
BdrvCoIsAllocatedData *data = opaque;
|
||||
BlockDriverState *bs = data->bs;
|
||||
|
||||
data->ret = bs->drv->bdrv_co_is_allocated(bs, data->sector_num,
|
||||
data->nb_sectors, data->pnum);
|
||||
data->done = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true iff the specified sector is present in the disk image. Drivers
|
||||
* not implementing the functionality are assumed to not support backing files,
|
||||
|
@ -1918,8 +1907,8 @@ static void coroutine_fn bdrv_is_allocated_co_entry(void *opaque)
|
|||
*
|
||||
* 'nb_sectors' is the max value 'pnum' should be set to.
|
||||
*/
|
||||
int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
||||
int *pnum)
|
||||
int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t sector_num,
|
||||
int nb_sectors, int *pnum)
|
||||
{
|
||||
if (!bs->drv->bdrv_co_is_allocated) {
|
||||
int64_t n;
|
||||
|
@ -1932,6 +1921,28 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
|||
return 1;
|
||||
}
|
||||
|
||||
return bs->drv->bdrv_co_is_allocated(bs, sector_num, nb_sectors, pnum);
|
||||
}
|
||||
|
||||
/* Coroutine wrapper for bdrv_is_allocated() */
|
||||
static void coroutine_fn bdrv_is_allocated_co_entry(void *opaque)
|
||||
{
|
||||
BdrvCoIsAllocatedData *data = opaque;
|
||||
BlockDriverState *bs = data->bs;
|
||||
|
||||
data->ret = bdrv_co_is_allocated(bs, data->sector_num, data->nb_sectors,
|
||||
data->pnum);
|
||||
data->done = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Synchronous wrapper around bdrv_co_is_allocated().
|
||||
*
|
||||
* See bdrv_co_is_allocated() for details.
|
||||
*/
|
||||
int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
||||
int *pnum)
|
||||
{
|
||||
Coroutine *co;
|
||||
BdrvCoIsAllocatedData data = {
|
||||
.bs = bs,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue