qemu-img: Special post-backing convert handling
commit351c8efff9ad809c822d55620df54d575d536f68
authorMax Reitz <mreitz@redhat.com>
Tue, 1 May 2018 16:57:49 +0000 (1 18:57 +0200)
committerMax Reitz <mreitz@redhat.com>
Mon, 11 Jun 2018 14:18:45 +0000 (11 16:18 +0200)
treee272cd607dba831050f07764c59ddf491b15f14c
parent28036a7f7044fddb79819e3c8fcb4ae5605c60e0
qemu-img: Special post-backing convert handling

Currently, qemu-img convert writes zeroes when it reads zeroes.
Sometimes it does not because the target is initialized to zeroes
anyway, so we do not need to overwrite (and thus potentially allocate)
it.  This is never the case for targets with backing files, though.  But
even they may have an area that is initialized to zeroes, and that is
the area past the end of the backing file (if that is shorter than the
overlay).

So if the target format's unallocated blocks are zero and there is a gap
between the target's backing file's end and the target's end, we do not
have to explicitly write zeroes there.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1527898
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20180501165750.19242-2-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
qemu-img.c