From 5ea25b78010d9e00ff018078fbd690b5a24b54ce Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mon, 22 Jun 2009 16:33:24 +0000 Subject: [PATCH] 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. --- ChangeLog | 12 ++++++++++++ src/storage_backend_fs.c | 2 +- src/storage_driver.c | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index aeeb1bac1f..28c3fe6eaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon Jun 22 12:31:38 EDT 2009 Cole Robinson + + * 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 * src/test.c: Fix domain ID after redefining a running VM diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c index 0e93e54394..c3d66b52bd 100644 --- a/src/storage_backend_fs.c +++ b/src/storage_backend_fs.c @@ -1047,7 +1047,7 @@ static int createRaw(virConnectPtr conn, goto cleanup; } - remain = vol->capacity; + remain = vol->allocation; if (inputfd != -1) { int amtread = -1; diff --git a/src/storage_driver.c b/src/storage_driver.c index 4a6e5e24e5..7e109ca13f 100644 --- a/src/storage_driver.c +++ b/src/storage_driver.c @@ -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"));