Subject: cloner: Handle --nonsparse for qcow2 images (bz 1675743) From: Cole Robinson crobinso@redhat.com Mon Mar 4 13:20:51 2019 -0500 Date: Mon Mar 4 14:04:34 2019 -0500: Git: 4f66c423f7833e270b61536d53a0772ce1242abc https://bugzilla.redhat.com/show_bug.cgi?id=1675743 diff --git a/tests/clone-xml/cross-pool-disks-out.xml b/tests/clone-xml/cross-pool-disks-out.xml index 260f321c..6093e240 100644 --- a/tests/clone-xml/cross-pool-disks-out.xml +++ b/tests/clone-xml/cross-pool-disks-out.xml @@ -1,7 +1,7 @@ new1.img 1000000 - 50000 + 1000000 @@ -12,7 +12,7 @@ new2.img 1000000 - 50000 + 1000000 diff --git a/virtinst/cloner.py b/virtinst/cloner.py index ba89a26f..b29027e3 100644 --- a/virtinst/cloner.py +++ b/virtinst/cloner.py @@ -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: diff --git a/virtinst/storage.py b/virtinst/storage.py index 3249c454..2e92c5d6 100644 --- a/virtinst/storage.py +++ b/virtinst/storage.py @@ -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,