This patch is part of the Fast Virtual Disk (FVD) proposal. See http://wiki.qemu.org/Features/FVD.
This patch adds FVD's implementation of the bdrv_has_zero_init() interface. Signed-off-by: Chunqiang Tang <ct...@us.ibm.com> --- block/fvd-misc.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/block/fvd-misc.c b/block/fvd-misc.c index 766b62b..61e39bb 100644 --- a/block/fvd-misc.c +++ b/block/fvd-misc.c @@ -341,5 +341,12 @@ static int fvd_get_info(BlockDriverState * bs, BlockDriverInfo * bdi) static int fvd_has_zero_init(BlockDriverState * bs) { - return 0; + BDRVFvdState *s = bs->opaque; + + /* For a non-compact image, chunks_relocated is always false. For a + * compact image with chunks_relocated=true, it can no longer guarantee + * zero init even if the file system does that. This is because a partialy + * written chunk X may be relocated to a location previously used by + * another chunk Y and some garbage data are left there by Y. */ + return s->chunks_relocated ? 0 : bdrv_has_zero_init(s->fvd_data); } -- 1.7.0.4