Description of problem:
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1.clone a KVM
n22 /var/lib/libvirt/images # ll
-rw------- 1 root root 8591507456 Aug 16 23:10 Gentoo-clone.qcow2
-rw------- 1 root root 4877910016 Aug 16 23:27 Gentoo.qcow2
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:
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:
Author: Prerna Saxena <firstname.lastname@example.org>
AuthorDate: 2015-06-26 17:13:26 +0530
Commit: Ján Tomko <email@example.com>
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.
Also fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1130739
Signed-off-by: Prerna Saxena <firstname.lastname@example.org>
Signed-off-by: Ján Tomko <email@example.com>
git describe: v1.2.17-74-gdd519a2