Skip to content

Commit

Permalink
vdi: Fix .bdrv_has_zero_init()
Browse files Browse the repository at this point in the history
Static VDI images cannot guarantee to be zero-initialized.  If the image
has been statically allocated, forward the call to the underlying
storage node.

Reported-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Tested-by: Stefano Garzarella <sgarzare@redhat.com>
Message-id: 20190724171239.8764-8-mreitz@redhat.com
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
XanClic committed Aug 19, 2019
1 parent 38841dc commit 0a28bf2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion block/vdi.c
Expand Up @@ -988,6 +988,17 @@ static void vdi_close(BlockDriverState *bs)
error_free(s->migration_blocker);
}

static int vdi_has_zero_init(BlockDriverState *bs)
{
BDRVVdiState *s = bs->opaque;

if (s->header.image_type == VDI_TYPE_STATIC) {
return bdrv_has_zero_init(bs->file->bs);
} else {
return 1;
}
}

static QemuOptsList vdi_create_opts = {
.name = "vdi-create-opts",
.head = QTAILQ_HEAD_INITIALIZER(vdi_create_opts.head),
Expand Down Expand Up @@ -1028,7 +1039,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_child_perm = bdrv_format_default_perms,
.bdrv_co_create = vdi_co_create,
.bdrv_co_create_opts = vdi_co_create_opts,
.bdrv_has_zero_init = bdrv_has_zero_init_1,
.bdrv_has_zero_init = vdi_has_zero_init,
.bdrv_co_block_status = vdi_co_block_status,
.bdrv_make_empty = vdi_make_empty,

Expand Down

0 comments on commit 0a28bf2

Please sign in to comment.