[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 07/11] vdi: Fix .bdrv_has_zero_init()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v2 07/11] vdi: Fix .bdrv_has_zero_init() |
Date: |
Wed, 24 Jul 2019 19:12:35 +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 <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Stefan Weil <address@hidden>
Acked-by: Stefano Garzarella <address@hidden>
Tested-by: Stefano Garzarella <address@hidden>
---
block/vdi.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/block/vdi.c b/block/vdi.c
index b9845a4cbd..0caa3f281d 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -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,
--
2.21.0
- [Qemu-devel] [PATCH v2 02/11] mirror: Fix bdrv_has_zero_init() use, (continued)
- [Qemu-devel] [PATCH v2 04/11] block: Implement .bdrv_has_zero_init_truncate(), Max Reitz, 2019/07/24
- [Qemu-devel] [PATCH v2 05/11] block: Use bdrv_has_zero_init_truncate(), Max Reitz, 2019/07/24
- [Qemu-devel] [PATCH v2 06/11] qcow2: Fix .bdrv_has_zero_init(), Max Reitz, 2019/07/24
- [Qemu-devel] [PATCH v2 07/11] vdi: Fix .bdrv_has_zero_init(),
Max Reitz <=
- [Qemu-devel] [PATCH v2 08/11] vhdx: Fix .bdrv_has_zero_init(), Max Reitz, 2019/07/24
- [Qemu-devel] [PATCH v2 09/11] iotests: Convert to preallocated encrypted qcow2, Max Reitz, 2019/07/24
- [Qemu-devel] [PATCH v2 10/11] iotests: Test convert -n to pre-filled image, Max Reitz, 2019/07/24
- [Qemu-devel] [PATCH v2 11/11] iotests: Full mirror to existing non-zero image, Max Reitz, 2019/07/24