I'm not necessarily saying this is a bug, but a change in behaviour in
qemu has caused virt-v2v to fail. The reproducer is quite simple.
Create sparse and preallocated qcow2 files of the same size:
$ qemu-img create -f qcow2 sparse.qcow2 50M
Formatting 'sparse.qcow2', fmt=qcow2 size=52428800 cluster_size=65536
lazy_refcounts=off refcount_bits=16
$ qemu-img create -f qcow2 prealloc.qcow2 50M -o
preallocation=falloc,compat=1.1
Formatting 'prealloc.qcow2', fmt=qcow2 size=52428800 compat=1.1
cluster_size=65536 preallocation=falloc lazy_refcounts=off refcount_bits=16
$ du -m sparse.qcow2 prealloc.qcow2
1 sparse.qcow2
51 prealloc.qcow2
Now copy the sparse file into the preallocated file using the -n
option so qemu-img doesn't create the target:
$ qemu-img convert -p -n -f qcow2 -O qcow2 sparse.qcow2 prealloc.qcow2
(100.00/100%)
In new qemu that makes the target file sparse:
$ du -m sparse.qcow2 prealloc.qcow2
1 sparse.qcow2
1 prealloc.qcow2 <-- should still be 51
In old qemu the target file remained preallocated, which is what
I and virt-v2v are expecting.
I bisected this to the following commit:
4d7c487eac1652dfe4498fe84f32900ad461d61b is the first bad commit
commit 4d7c487eac1652dfe4498fe84f32900ad461d61b
Author: Max Reitz <[email protected]>
Date: Wed Jul 24 19:12:29 2019 +0200
qemu-img: Fix bdrv_has_zero_init() use in convert
bdrv_has_zero_init() only has meaning for newly created images or image
areas. If qemu-img convert did not create the image itself, it cannot
rely on bdrv_has_zero_init()'s result to carry any meaning.
Signed-off-by: Max Reitz <[email protected]>
Message-id: [email protected]
Reviewed-by: Maxim Levitsky <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
qemu-img.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
Reverting this commit on the current master branch restores the
expected behaviour.
Thoughts?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org