Bug 1297255

Summary: add possibility to sparsify image during block copy
Product: Red Hat Enterprise Linux 7 Reporter: Fam Zheng <famz>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED CANTFIX QA Contact: yisun
Severity: high Docs Contact:
Priority: high    
Version: 7.3CC: areis, asoni, byount, cww, dmaley, dyuan, fjin, hhan, jsuchane, juzhang, knoel, lmen, meili, mkalinin, mtessun, pbonzini, pbrady, pezhang, pkrempa, virt-bugs, virt-maint, xfu, xuzhang
Target Milestone: rcFlags: asoni: needinfo-
Target Release: 7.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1232914 Environment:
Last Closed: 2018-12-18 12:14:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1232914, 1242316, 1533975    
Bug Blocks: 1229843, 1288337, 1401400, 1473733, 1477664, 1546815    

Comment 24 Peter Krempa 2017-12-12 09:01:46 UTC
Fixing summary to clarify. 

Description asks libvirt to add possibility to enable sparsification of the regions of the image containing only zero blocks so that they are actually unmapped.

Note that this comes with a performance penalty thus it should not be enabled by default.

Also note that qemu already keeps the unmaped regions unmapped when copying, so this is useful only when the regions were not unmapped before for some reasons.

Comment 31 Peter Krempa 2018-12-18 12:14:35 UTC
So unfortunately it looks like qemu will not provide the required interface (https://bugzilla.redhat.com/show_bug.cgi?id=1533975) which will allow to skip zero-writes when doing a block-copy operation into a raw file.

Closing as CANTFIX

It is possible to do a workaround with a few manual/external steps:
1) create a snapshot on top of the raw file on the local filesystem or NFS (virsh snapshot-create --no-metadata ...)
2) manually copy over the original file and sparsify it since it's no longer written to
3) manually create an empty qcow2 file with a backing file which points to the new file copied in step 2
4) use block copy operation to switch to the new file: (virsh blockcopy --reuse-external --transient-job --shallow --pivot ...) and wait for it to finish
5) use block-commit to remove the temporary snapshot and start using the copied file (virsh blockcommit --active --pivot ...)