Description of problem: space wasted Version-Release number of selected component (if applicable): 1.0.1 How reproducible: Steps to Reproduce: 1.clone a KVM 2. 3. Actual results: n22 /var/lib/libvirt/images # ll total 13153688 -rw------- 1 root root 8591507456 Aug 16 23:10 Gentoo-clone.qcow2 -rw------- 1 root root 4877910016 Aug 16 23:27 Gentoo.qcow2 Expected results: Additional info:
Thinking longer about this it should be rather a request-for-enhancement to offer the option to compress the cloned image by the way.
I don't think this is a bug in libvirt because libvirt can't even create a fully allocated qcow2 image on request. Could you share the output of 'virt-manager --debug' when cloning the volume?
Created attachment 929240 [details] debug log output ofc here it is
Oh, I see, libvirt doesn't know it's a qcow2 volume since virt-manager requests 'raw': [Thu, 21 Aug 2014 17:29:19 virt-manager 12161] DEBUG (storage:701) Creating storage volume 'Gentoo-clone1.qcow2' with xml: <volume> <name>Gentoo-clone1.qcow2</name> <capacity>8591507456</capacity> <allocation>2533773312</allocation> <target> <format type="raw"/> </target> </volume> And we explicitly set the allocation to the capacity of original: /* Make sure allocation is at least as large as the destination cap, * to make absolutely sure we copy all possible contents */ if (newvol->target.allocation < origvol->target.capacity) newvol->target.allocation = origvol->target.capacity; We can't really fulfill the 'allocation' requirement if it's less than the data contained in the source volume. Maybe treating (allocation < capacity) as "create a sparse volume" or just treating it as a minimum would make sense here and hopefully not break anything.
Now pushed upstream: commit dd519a294b22646b8dab26627707a525556df4d4 Author: Prerna Saxena <prerna.ibm.com> AuthorDate: 2015-06-26 17:13:26 +0530 Commit: Ján Tomko <jtomko> CommitDate: 2015-07-10 08:54:10 +0200 Fix cloning of raw, sparse volumes When virsh vol-clone is attempted on a raw file where capacity > allocation, the resulting cloned volume has a size that matches the virtual-size of the parent; in place of matching its actual, disk size. This patch fixes the cloned disk to have same _allocated_size_ as the parent file from which it was cloned. Ref: http://www.redhat.com/archives/libvir-list/2015-May/msg00050.html Also fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1130739 Signed-off-by: Prerna Saxena <prerna.ibm.com> Signed-off-by: Ján Tomko <jtomko> git describe: v1.2.17-74-gdd519a2