cloner: Handle --nonsparse for qcow2 images (bz 1675743)

https://bugzilla.redhat.com/show_bug.cgi?id=1675743
This commit is contained in:
Cole Robinson 2019-03-04 13:20:51 -05:00
parent 26a433fc42
commit 4f66c423f7
3 changed files with 8 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<volume>
<name>new1.img</name>
<capacity>1000000</capacity>
<allocation>50000</allocation>
<allocation>1000000</allocation>
<target>
<format type="qcow2"/>
<features>
@ -12,7 +12,7 @@
<volume>
<name>new2.img</name>
<capacity>1000000</capacity>
<allocation>50000</allocation>
<allocation>1000000</allocation>
<target>
<format type="qcow2"/>
<features>

View File

@ -330,6 +330,8 @@ class Cloner(object):
vol_install.input_vol = orig_disk.get_vol_object()
vol_install.sync_input_vol(only_format=True)
if self.clone_sparse:
vol_install.allocation = vol_install.capacity
vol_install.reflink = self.reflink
clone_disk.set_vol_install(vol_install)
elif orig_disk.path:

View File

@ -744,6 +744,10 @@ class StorageVolume(_StorageObject):
self.conn.check_support(
self.conn.SUPPORT_POOL_METADATA_PREALLOC, self.pool)):
createflags |= libvirt.VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
if self.capacity == self.allocation:
# For cloning, this flag will make libvirt+qemu-img preallocate
# the new disk image
cloneflags |= libvirt.VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
if self.reflink:
cloneflags |= getattr(libvirt,