]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix raw storage volume creation for allocation < capacity.
authorCole Robinson <crobinso@redhat.com>
Mon, 22 Jun 2009 16:33:24 +0000 (16:33 +0000)
committerCole Robinson <crobinso@redhat.com>
Mon, 22 Jun 2009 16:33:24 +0000 (16:33 +0000)
CreateXMLFrom changes accidentally caused all raw volume creation to be
fully allocated (as though allocation == capacity). Fix this.

Also force CreateXMLFrom to maintain the previous behavior: sparseness
should still be maintained since we search for holes when copying, and the
clone behavior hasn't been tested with anything but the broken behavior.

ChangeLog
src/storage_backend_fs.c
src/storage_driver.c

index aeeb1bac1f12ddab3bc902f1ebf6479bbc9c7c0b..28c3fe6eafbacc85d2ac0cb612bdc843ae2abed8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Mon Jun 22 12:31:38 EDT 2009 Cole Robinson <crobinso@redhat.com>
+
+       * src/storage_backend_fs.c src/storage_driver.c:
+       Fix raw storage volume creation for allocation < capacity.
+
+CreateXMLFrom changes accidentally caused all raw volume creation to be
+fully allocated (as though allocation == capacity). Fix this.
+
+Also force CreateXMLFrom to maintain the previous behavior: sparseness
+should still be maintained since we search for holes when copying, and the
+clone behavior hasn't been tested with anything but the broken behavior.
+
 Mon Jun 22 11:09:18 EDT 2009 Cole Robinson <crobinso@redhat.com>
 
        * src/test.c: Fix domain ID after redefining a running VM
index 0e93e54394ec7d8a93e5af6c9421d5ef8ad8f47c..c3d66b52bd01fd16bb1f047d82c2f3774c9c70c9 100644 (file)
@@ -1047,7 +1047,7 @@ static int createRaw(virConnectPtr conn,
         goto cleanup;
     }
 
-    remain = vol->capacity;
+    remain = vol->allocation;
 
     if (inputfd != -1) {
         int amtread = -1;
index 4a6e5e24e5cedbb40b6e7ad5a807b0cfb5c66b85..7e109ca13fb3a70208a3cead6d36dbf4e163ab7b 100644 (file)
@@ -1379,6 +1379,11 @@ storageVolumeCreateXMLFrom(virStoragePoolPtr obj,
     if (newvol->capacity < origvol->capacity)
         newvol->capacity = origvol->capacity;
 
+    /* Make sure allocation is at least as large as the destination cap,
+     * to make absolutely sure we copy all possible contents */
+    if (newvol->allocation < origvol->capacity)
+        newvol->allocation = origvol->capacity;
+
     if (!backend->buildVolFrom) {
         virStorageReportError(obj->conn, VIR_ERR_NO_SUPPORT,
                               "%s", _("storage pool does not support volume creation from an existing volume"));