|
|
3d61c0 |
From 38fb59d22011f606116691bf3ca5ac15bca3a8bd Mon Sep 17 00:00:00 2001
|
|
|
3d61c0 |
Message-Id: <38fb59d22011f606116691bf3ca5ac15bca3a8bd@dist-git>
|
|
|
3d61c0 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
3d61c0 |
Date: Thu, 2 May 2019 08:40:52 -0400
|
|
|
3d61c0 |
Subject: [PATCH] cloner: Handle --nonsparse for qcow2 images
|
|
|
3d61c0 |
|
|
|
3d61c0 |
From: Cole Robinson <crobinso@redhat.com>
|
|
|
3d61c0 |
|
|
|
3d61c0 |
(cherry picked from commit 4f66c423f7833e270b61536d53a0772ce1242abc)
|
|
|
3d61c0 |
|
|
|
3d61c0 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1675743
|
|
|
3d61c0 |
|
|
|
3d61c0 |
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
|
|
3d61c0 |
---
|
|
|
3d61c0 |
tests/clone-xml/cross-pool-disks-out.xml | 4 ++--
|
|
|
3d61c0 |
virtinst/cloner.py | 2 ++
|
|
|
3d61c0 |
virtinst/storage.py | 4 ++++
|
|
|
3d61c0 |
3 files changed, 8 insertions(+), 2 deletions(-)
|
|
|
3d61c0 |
|
|
|
3d61c0 |
diff --git a/tests/clone-xml/cross-pool-disks-out.xml b/tests/clone-xml/cross-pool-disks-out.xml
|
|
|
3d61c0 |
index 260f321c..6093e240 100644
|
|
|
3d61c0 |
--- a/tests/clone-xml/cross-pool-disks-out.xml
|
|
|
3d61c0 |
+++ b/tests/clone-xml/cross-pool-disks-out.xml
|
|
|
3d61c0 |
@@ -1,7 +1,7 @@
|
|
|
3d61c0 |
<volume>
|
|
|
3d61c0 |
<name>new1.img</name>
|
|
|
3d61c0 |
<capacity>1000000</capacity>
|
|
|
3d61c0 |
- <allocation>50000</allocation>
|
|
|
3d61c0 |
+ <allocation>1000000</allocation>
|
|
|
3d61c0 |
<target>
|
|
|
3d61c0 |
<format type="qcow2"/>
|
|
|
3d61c0 |
<features>
|
|
|
3d61c0 |
@@ -12,7 +12,7 @@
|
|
|
3d61c0 |
<volume>
|
|
|
3d61c0 |
<name>new2.img</name>
|
|
|
3d61c0 |
<capacity>1000000</capacity>
|
|
|
3d61c0 |
- <allocation>50000</allocation>
|
|
|
3d61c0 |
+ <allocation>1000000</allocation>
|
|
|
3d61c0 |
<target>
|
|
|
3d61c0 |
<format type="qcow2"/>
|
|
|
3d61c0 |
<features>
|
|
|
3d61c0 |
diff --git a/virtinst/cloner.py b/virtinst/cloner.py
|
|
|
3d61c0 |
index d54c3f85..3ce44b15 100644
|
|
|
3d61c0 |
--- a/virtinst/cloner.py
|
|
|
3d61c0 |
+++ b/virtinst/cloner.py
|
|
|
3d61c0 |
@@ -348,6 +348,8 @@ class Cloner(object):
|
|
|
3d61c0 |
vol_install.input_vol = orig_disk.get_vol_object()
|
|
|
3d61c0 |
vol_install.sync_input_vol(only_format=True)
|
|
|
3d61c0 |
|
|
|
3d61c0 |
+ if self.clone_sparse:
|
|
|
3d61c0 |
+ vol_install.allocation = vol_install.capacity
|
|
|
3d61c0 |
vol_install.reflink = self.reflink
|
|
|
3d61c0 |
clone_disk.set_vol_install(vol_install)
|
|
|
3d61c0 |
elif orig_disk.path:
|
|
|
3d61c0 |
diff --git a/virtinst/storage.py b/virtinst/storage.py
|
|
|
3d61c0 |
index 9966401a..89ae84f6 100644
|
|
|
3d61c0 |
--- a/virtinst/storage.py
|
|
|
3d61c0 |
+++ b/virtinst/storage.py
|
|
|
3d61c0 |
@@ -835,6 +835,10 @@ class StorageVolume(_StorageObject):
|
|
|
3d61c0 |
self.conn.check_support(
|
|
|
3d61c0 |
self.conn.SUPPORT_POOL_METADATA_PREALLOC, self.pool)):
|
|
|
3d61c0 |
createflags |= libvirt.VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
|
|
|
3d61c0 |
+ if self.capacity == self.allocation:
|
|
|
3d61c0 |
+ # For cloning, this flag will make libvirt+qemu-img preallocate
|
|
|
3d61c0 |
+ # the new disk image
|
|
|
3d61c0 |
+ cloneflags |= libvirt.VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
|
|
|
3d61c0 |
|
|
|
3d61c0 |
if self.reflink:
|
|
|
3d61c0 |
cloneflags |= getattr(libvirt,
|
|
|
3d61c0 |
--
|
|
|
3d61c0 |
2.21.0
|
|
|
3d61c0 |
|