mirror of https://github.com/proxmox/mirror_qemu
sheepdog: implement .bdrv_get_allocated_file_size
With this patch, qemu-img info sheepdog:image will show disk size for sheepdog images. Cc: Kevin Wolf <kwolf@redhat.com> Cc: Stefan Hajnoczi <stefanha@redhat.com> Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Liu Yuan <namei.unix@gmail.com> Reviewed-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> Signed-off-by: Kevin Wolf <kwolf@redhat.com>master
parent
f8d1daea6f
commit
8582972227
|
@ -2407,6 +2407,22 @@ sd_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int64_t sd_get_allocated_file_size(BlockDriverState *bs)
|
||||||
|
{
|
||||||
|
BDRVSheepdogState *s = bs->opaque;
|
||||||
|
SheepdogInode *inode = &s->inode;
|
||||||
|
unsigned long i, last = DIV_ROUND_UP(inode->vdi_size, SD_DATA_OBJ_SIZE);
|
||||||
|
uint64_t size = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < last; i++) {
|
||||||
|
if (inode->data_vdi_id[i] == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
size += SD_DATA_OBJ_SIZE;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
static QEMUOptionParameter sd_create_options[] = {
|
static QEMUOptionParameter sd_create_options[] = {
|
||||||
{
|
{
|
||||||
.name = BLOCK_OPT_SIZE,
|
.name = BLOCK_OPT_SIZE,
|
||||||
|
@ -2436,6 +2452,7 @@ static BlockDriver bdrv_sheepdog = {
|
||||||
.bdrv_create = sd_create,
|
.bdrv_create = sd_create,
|
||||||
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||||
.bdrv_getlength = sd_getlength,
|
.bdrv_getlength = sd_getlength,
|
||||||
|
.bdrv_get_allocated_file_size = sd_get_allocated_file_size,
|
||||||
.bdrv_truncate = sd_truncate,
|
.bdrv_truncate = sd_truncate,
|
||||||
|
|
||||||
.bdrv_co_readv = sd_co_readv,
|
.bdrv_co_readv = sd_co_readv,
|
||||||
|
@ -2465,6 +2482,7 @@ static BlockDriver bdrv_sheepdog_tcp = {
|
||||||
.bdrv_create = sd_create,
|
.bdrv_create = sd_create,
|
||||||
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||||
.bdrv_getlength = sd_getlength,
|
.bdrv_getlength = sd_getlength,
|
||||||
|
.bdrv_get_allocated_file_size = sd_get_allocated_file_size,
|
||||||
.bdrv_truncate = sd_truncate,
|
.bdrv_truncate = sd_truncate,
|
||||||
|
|
||||||
.bdrv_co_readv = sd_co_readv,
|
.bdrv_co_readv = sd_co_readv,
|
||||||
|
@ -2494,6 +2512,7 @@ static BlockDriver bdrv_sheepdog_unix = {
|
||||||
.bdrv_create = sd_create,
|
.bdrv_create = sd_create,
|
||||||
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
.bdrv_has_zero_init = bdrv_has_zero_init_1,
|
||||||
.bdrv_getlength = sd_getlength,
|
.bdrv_getlength = sd_getlength,
|
||||||
|
.bdrv_get_allocated_file_size = sd_get_allocated_file_size,
|
||||||
.bdrv_truncate = sd_truncate,
|
.bdrv_truncate = sd_truncate,
|
||||||
|
|
||||||
.bdrv_co_readv = sd_co_readv,
|
.bdrv_co_readv = sd_co_readv,
|
||||||
|
|
Loading…
Reference in New Issue