]> Git Repo - qemu.git/commitdiff
vdi: Fix .bdrv_has_zero_init()
authorMax Reitz <[email protected]>
Wed, 24 Jul 2019 17:12:35 +0000 (19:12 +0200)
committerMax Reitz <[email protected]>
Mon, 19 Aug 2019 15:13:26 +0000 (17:13 +0200)
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 <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Stefan Weil <[email protected]>
Acked-by: Stefano Garzarella <[email protected]>
Tested-by: Stefano Garzarella <[email protected]>
Message-id: 20190724171239[email protected]
Reviewed-by: Maxim Levitsky <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
block/vdi.c

index b9845a4cbded0a27d70101461e8da05a188a971a..0caa3f281d262f2dcb00a8d13d28f7cfb7ea20b0 100644 (file)
@@ -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),
@@ -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,
 
This page took 0.027398 seconds and 4 git commands to generate.