[libvirt] [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. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/storage_backend_fs.c | 2 +- src/storage_driver.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c index 0e93e54..c3d66b5 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 71e64a4..57a93c1 100644 --- a/src/storage_driver.c +++ b/src/storage_driver.c @@ -1377,6 +1377,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")); -- 1.6.0.6

Cole Robinson wrote:
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.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/storage_backend_fs.c | 2 +- src/storage_driver.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c index 0e93e54..c3d66b5 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 71e64a4..57a93c1 100644 --- a/src/storage_driver.c +++ b/src/storage_driver.c @@ -1377,6 +1377,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; +
Of course the tweak I make at the last second is completely invalid syntax :(. Besides needing the obvious fix above, the patch does work as expected. Thanks, Cole
if (!backend->buildVolFrom) { virStorageReportError(obj->conn, VIR_ERR_NO_SUPPORT, "%s", _("storage pool does not support volume creation from an existing volume"));

On Thu, Jun 18, 2009 at 03:13:06PM -0400, Cole Robinson wrote:
Cole Robinson wrote:
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. [...] + /* 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; +
Of course the tweak I make at the last second is completely invalid syntax :(. Besides needing the obvious fix above, the patch does work as expected.
Heh, ACK to tyhe fixed fix :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Daniel Veillard wrote:
On Thu, Jun 18, 2009 at 03:13:06PM -0400, Cole Robinson wrote:
Cole Robinson wrote:
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. [...] + /* 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; + Of course the tweak I make at the last second is completely invalid syntax :(. Besides needing the obvious fix above, the patch does work as expected.
Heh, ACK to tyhe fixed fix :-)
Daniel
Thanks, applied with the above syntax fix. - Cole

On Thu, Jun 18, 2009 at 03:13:06PM -0400, Cole Robinson wrote:
Cole Robinson wrote:
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.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/storage_backend_fs.c | 2 +- src/storage_driver.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c index 0e93e54..c3d66b5 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 71e64a4..57a93c1 100644 --- a/src/storage_driver.c +++ b/src/storage_driver.c @@ -1377,6 +1377,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; +
Of course the tweak I make at the last second is completely invalid syntax :(. Besides needing the obvious fix above, the patch does work as expected.
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard