
On 04/12/2013 03:53 AM, Daniel P. Berrange wrote:
On Fri, Apr 12, 2013 at 05:25:23PM +0800, me,apporc wrote:
After snapshot-delete, the qcow2 image file size doesn't decrease, isn't that a waste of disk space?
Yes, but that's life. When deleting an internal qcow2 snapshot, QEMU will just mark the clusters as unused, it won't return them to the underlying filesystem. These unused clusters will, however, be re-used if the qcow2 file needs to grow later.
Would someone please tell me how to decrease the file size when snapshot-delete, if that's possible?
You can't do it in place. The only option would be to use qemu-img to clone the qcow2 file to a new qcow2 file & delete the original.
Check out 'virt-sparsify' from libguestfs-tools, which is designed to help you minimize disk space (including this trick of copying from one qcow2 to another to reduce space occupied by now-unused clusters). Meanwhile, if you are really ambitious, write a patch to upstream qemu that can do a defrag pass on an existing qcow2 image, and expose it through both qemu-img (for manipulating offline disks) and a QMP monitor command (so that we can request an online defrag without any noticeable guest downtime). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org