Now that qcow2 images have a way to track when the contents are known
to be all zero, it is worth exposing this to clients such as qemu-img
convert. (Of course, until the next patch wires up qcow2 to actually
set the bit, this patch has no immediate effect; however, keeping it
as a separate patch allows for an easier revert when testing if the
bit makes a difference in qemu-img behavior).
Signed-off-by: Eric Blake <eblake@redhat.com>
---
block/qcow2.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/qcow2.c b/block/qcow2.c
index 20cce9410c84..3f61d806a14b 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -4938,6 +4938,9 @@ static int qcow2_known_zeroes(BlockDriverState *bs)
* therefore enough to check the first one.
*/
preallocated = s->l1_size > 0 && s->l1_table[0] != 0;
+ if (s->autoclear_features & QCOW2_AUTOCLEAR_ALL_ZERO) {
+ r |= BDRV_ZERO_OPEN;
+ }
if (qemu_in_coroutine()) {
qemu_co_mutex_unlock(&s->lock);
}
--
2.24.1