[libvirt] [PATCH 2/2] Storage : Fix cloning of raw, sparse volumes.

Prerna Saxena prerna at linux.vnet.ibm.com
Tue May 5 03:17:56 UTC 2015


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.

Reference: https://www.redhat.com/archives/libvir-list/2014-September/msg00064.html

Also fixes : https://bugzilla.redhat.com/show_bug.cgi?id=1130739

Signed-off-by: Prerna Saxena <prerna at linux.vnet.ibm.com>
---
 src/storage/storage_backend.c | 2 +-
 src/storage/storage_driver.c  | 5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 355fc7f..1a7c0cc 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -429,7 +429,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
     }
 #endif
 
-    remain = vol->target.allocation;
+    remain = inputvol->target.capacity;
 
     if (inputvol) {
         /* allow zero blocks to be skipped if we've requested sparse
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index ac4a74a..c511035 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1990,11 +1990,6 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
     if (newvol->target.capacity < origvol->target.capacity)
         newvol->target.capacity = origvol->target.capacity;
 
-    /* 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;
-
     if (!backend->buildVolFrom) {
         virReportError(VIR_ERR_NO_SUPPORT,
                        "%s", _("storage pool does not support"
-- 
1.8.3.1


-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India




More information about the libvir-list mailing list