diff mbox series

[14/17] qcow2: Expose all zero bit through .bdrv_known_zeroes

Message ID 20200131174436.2961874-15-eblake@redhat.com (mailing list archive)
State New, archived
Headers show
Series Improve qcow2 all-zero detection | expand

Commit Message

Eric Blake Jan. 31, 2020, 5:44 p.m. UTC
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 mbox series

Patch

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);
     }