From 1904ad28bf3c9a819d180d9b157f563a1f57631f Mon Sep 17 00:00:00 2001 From: Jeffrey Cody Date: Thu, 10 Jul 2014 23:24:30 +0200 Subject: [PATCH 30/44] vpc, vhdx: add get_info RH-Author: Jeffrey Cody Message-id: <0a4265f3a52101341ebf7898b084055cc5668db5.1405033137.git.jcody@redhat.com> Patchwork-id: 59766 O-Subject: [RHEL6-6 qemu-kvm PATCH v2 21/24] vpc, vhdx: add get_info Bugzilla: 1063559 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Fam Zheng RH-Acked-by: Markus Armbruster From: Paolo Bonzini Signed-off-by: Paolo Bonzini Reviewed-by: Peter Lieven Signed-off-by: Stefan Hajnoczi (cherry picked from commit 97b00e285119e611f500686f32f9bccffbb9126a) Signed-off-by: Jeff Cody --- block/vhdx.c | 10 ++++++++++ block/vpc.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+) Signed-off-by: Miroslav Rezanina --- block/vhdx.c | 10 ++++++++++ block/vpc.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/block/vhdx.c b/block/vhdx.c index dfdf6ea..256bbe8 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1058,6 +1058,15 @@ static void vhdx_block_translate(BDRVVHDXState *s, int64_t sector_num, } +static int vhdx_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + BDRVVHDXState *s = bs->opaque; + + bdi->cluster_size = s->block_size; + + return 0; +} + static coroutine_fn int vhdx_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) @@ -1895,6 +1904,7 @@ static BlockDriver bdrv_vhdx = { .bdrv_co_readv = vhdx_co_readv, .bdrv_co_writev = vhdx_co_writev, .bdrv_create = vhdx_create, + .bdrv_get_info = vhdx_get_info, .create_options = vhdx_create_options, }; diff --git a/block/vpc.c b/block/vpc.c index 39b9942..3e75740 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -464,6 +464,18 @@ fail: return -1; } +static int vpc_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + BDRVVPCState *s = (BDRVVPCState *)bs->opaque; + VHDFooter *footer = (VHDFooter *) s->footer_buf; + + if (cpu_to_be32(footer->type) != VHD_FIXED) { + bdi->cluster_size = s->block_size; + } + + return 0; +} + static int vpc_read(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { @@ -871,6 +883,8 @@ static BlockDriver bdrv_vpc = { .bdrv_read = vpc_co_read, .bdrv_write = vpc_co_write, + .bdrv_get_info = vpc_get_info, + .create_options = vpc_create_options, .bdrv_has_zero_init = vpc_has_zero_init, }; -- 1.7.1