[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/17] vhdx: Fix .bdrv_has_zero_init()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PULL 09/17] vhdx: Fix .bdrv_has_zero_init() |
Date: |
Mon, 19 Aug 2019 18:17:15 +0200 |
Fixed VHDX images cannot guarantee to be zero-initialized. If the image
has the "fixed" subformat, forward the call to the underlying storage
node.
Reported-by: Stefano Garzarella <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Message-id: address@hidden
Reviewed-by: Maxim Levitsky <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
block/vhdx.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/block/vhdx.c b/block/vhdx.c
index a02d1c99a7..6a09d0a55c 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -2075,6 +2075,30 @@ static int coroutine_fn vhdx_co_check(BlockDriverState
*bs,
return 0;
}
+static int vhdx_has_zero_init(BlockDriverState *bs)
+{
+ BDRVVHDXState *s = bs->opaque;
+ int state;
+
+ /*
+ * Check the subformat: Fixed images have all BAT entries present,
+ * dynamic images have none (right after creation). It is
+ * therefore enough to check the first BAT entry.
+ */
+ if (!s->bat_entries) {
+ return 1;
+ }
+
+ state = s->bat[0] & VHDX_BAT_STATE_BIT_MASK;
+ if (state == PAYLOAD_BLOCK_FULLY_PRESENT) {
+ /* Fixed subformat */
+ return bdrv_has_zero_init(bs->file->bs);
+ }
+
+ /* Dynamic subformat */
+ return 1;
+}
+
static QemuOptsList vhdx_create_opts = {
.name = "vhdx-create-opts",
.head = QTAILQ_HEAD_INITIALIZER(vhdx_create_opts.head),
@@ -2128,7 +2152,7 @@ static BlockDriver bdrv_vhdx = {
.bdrv_co_create_opts = vhdx_co_create_opts,
.bdrv_get_info = vhdx_get_info,
.bdrv_co_check = vhdx_co_check,
- .bdrv_has_zero_init = bdrv_has_zero_init_1,
+ .bdrv_has_zero_init = vhdx_has_zero_init,
.create_opts = &vhdx_create_opts,
};
--
2.21.0
- [Qemu-devel] [PULL 00/17] Block patches, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 02/17] qemu-img: Fix bdrv_has_zero_init() use in convert, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 01/17] LUKS: support preallocation, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 03/17] mirror: Fix bdrv_has_zero_init() use, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 04/17] block: Add bdrv_has_zero_init_truncate(), Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 05/17] block: Implement .bdrv_has_zero_init_truncate(), Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 06/17] block: Use bdrv_has_zero_init_truncate(), Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 07/17] qcow2: Fix .bdrv_has_zero_init(), Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 08/17] vdi: Fix .bdrv_has_zero_init(), Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 09/17] vhdx: Fix .bdrv_has_zero_init(),
Max Reitz <=
- [Qemu-devel] [PULL 10/17] iotests: Convert to preallocated encrypted qcow2, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 11/17] iotests: Test convert -n to pre-filled image, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 14/17] vmdk: Make block_status recurse for flat extents, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 15/17] vpc: Do not return RAW from block_status, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 13/17] vdi: Make block_status recurse for fixed images, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 17/17] doc: Preallocation does not require writing zeroes, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 12/17] iotests: Full mirror to existing non-zero image, Max Reitz, 2019/08/19
- [Qemu-devel] [PULL 16/17] iotests: Fix 141 when run with qed, Max Reitz, 2019/08/19
- Re: [Qemu-devel] [PULL 00/17] Block patches, Peter Maydell, 2019/08/20