From 7bfbc562528e14261099b52aae2b192d8b15d171 Mon Sep 17 00:00:00 2001 From: Jeffrey Cody Date: Thu, 10 Jul 2014 23:24:28 +0200 Subject: [PATCH 28/44] vpc: Implement .bdrv_has_zero_init RH-Author: Jeffrey Cody Message-id: <1d955a973ada0441e21f8a6bdae36d38c4bf6a6c.1405033137.git.jcody@redhat.com> Patchwork-id: 59764 O-Subject: [RHEL6-6 qemu-kvm PATCH v2 19/24] vpc: Implement .bdrv_has_zero_init Bugzilla: 1063559 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Fam Zheng RH-Acked-by: Markus Armbruster From: Kevin Wolf Depending on the subformat, has_zero_init on VHD must behave like raw and query the underlying storage (fixed) or like other sparse formats that can always return 1 (dynamic, differencing). Signed-off-by: Kevin Wolf (cherry picked from commit 72c6cc94daa727f41ecfc2b2ff94aa6f0e459b7f) Conflicts: block/vpc.c Signed-off-by: Jeff Cody --- block/vpc.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) Signed-off-by: Miroslav Rezanina --- block/vpc.c | 35 +++++++++++++++++++++++++---------- 1 files changed, 25 insertions(+), 10 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 6094f6b..6c12c01 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -817,6 +817,18 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options) return ret; } +static int vpc_has_zero_init(BlockDriverState *bs) +{ + BDRVVPCState *s = bs->opaque; + struct vhd_footer *footer = (struct vhd_footer *) s->footer_buf; + + if (cpu_to_be32(footer->type) == VHD_FIXED) { + return bdrv_has_zero_init(bs->file); + } else { + return 1; + } +} + static void vpc_close(BlockDriverState *bs) { BDRVVPCState *s = bs->opaque; @@ -848,16 +860,19 @@ static QEMUOptionParameter vpc_create_options[] = { static BlockDriver bdrv_vpc = { .format_name = "vpc", .instance_size = sizeof(BDRVVPCState), - .bdrv_probe = vpc_probe, - .bdrv_open = vpc_open, - .bdrv_read = vpc_co_read, - .bdrv_write = vpc_co_write, - .bdrv_co_flush = vpc_co_flush, - .bdrv_close = vpc_close, - .bdrv_reopen_prepare = vpc_reopen_prepare, - .bdrv_create = vpc_create, - - .create_options = vpc_create_options, + + .bdrv_probe = vpc_probe, + .bdrv_open = vpc_open, + .bdrv_co_flush = vpc_co_flush, + .bdrv_close = vpc_close, + .bdrv_reopen_prepare = vpc_reopen_prepare, + .bdrv_create = vpc_create, + + .bdrv_read = vpc_co_read, + .bdrv_write = vpc_co_write, + + .create_options = vpc_create_options, + .bdrv_has_zero_init = vpc_has_zero_init, }; static void bdrv_vpc_init(void) -- 1.7.1