On Thu, Feb 09, 2017 at 02:05:54AM -0000, wayen wrote: > @Eric Blake, I used virt-sparsify to sparsify the qcow2 overlay image. > As you said, the actual disk usage is minimized and the apparent file > size is unchanged.It is very valuable for me, because it means that my > disk can hold more files. > > But we need to be careful when transfer the sparse qcow2 overlays. > Because some tools do not support sparse file and will convert it into a > common file,for example, scp. And I doubt what will happen when transfer > sparse files between different file systems. > > So I want to use qemu-img to convert the sparse qcow2 overlay into > common file. If this was feasible, the holes in the sparse overlay will > be removed and the above problems will disappear.
You can use the drive_mirror HMP command or drive-mirror QMP command on a running QEMU instance to copy the data to a new file and switch to the new file. I'm curious what exactly is being optimized by copying out a fresh qcow2 image. Please post the output of: $ stat delta.qcow2 $ qemu-img map delta.qcow2 $ stat new.qcow2 $ qemu-img map new.qcow2 This will allow us to see the size and data layout differences. Maybe a new command should be added to QEMU to do the optimization in-place. This would avoid the disk space overhead associated with drive-mirror, cp, qemu-img convert, etc. Stefan -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1662050 Title: qemu-img convert a overlay qcow2 image into a entire image Status in QEMU: Incomplete Bug description: I have a base image file "base.qcow2" and a delta qcow2 image file "delta.qcow2" whose backing file is "base.qcow2". Now I use qemu-img to convert "delta.qcow2" and will get a new image file "new.qcow2" which is entire and equivalent to combination of "base.qcow2" and "delta.qcow2". In fact,I don't want to get a complete image.I just want to convert delta qcow2 image file "A" to a New delta overlay qcow2 image "B" which is equivalent to "A". So the "new.qcow2" is not what i want. I have to admit that this is not bug. Could you please take this as a new feature and enable qemu-img to convert qcow2 overlay itself? To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1662050/+subscriptions