[libvirt] [PATCH 1/2] storage: lvm: Don't overwrite lvcreate errors

Before: $ sudo virsh vol-create-as --pool vgvirt sparsetest --capacity 16M --allocation 0 error: Failed to create vol sparsetest error: internal error Child process (/usr/sbin/lvchange -aln vgvirt/sparsetest) unexpected exit status 5: One or more specified logical volume(s) not found. After: $ sudo virsh vol-create-as --pool vgvirt sparsetest --capacity 16M --allocation 0 error: Failed to create vol sparsetest error: internal error Child process (/usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt) unexpected exit status 5: Unable to create new logical volume with no extents --- src/storage/storage_backend_logical.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index a9d785c..eebeec1 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -699,6 +699,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, { int fdret, fd = -1; virCommandPtr cmd = NULL; + virErrorPtr err; if (vol->target.encryption != NULL) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -775,9 +776,11 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, return 0; cleanup: + err = virSaveLastError(); VIR_FORCE_CLOSE(fd); virStorageBackendLogicalDeleteVol(conn, pool, vol, 0); virCommandFree(cmd); + virSetError(err); return -1; } -- 1.7.11.7

On F17 at least, this command fails: $ sudo /usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt Unable to create new logical volume with no extents Which is unfortunate since allocation=0 is what virt-manager tries to use by default. Rather than telling the user 'don't do that', let's just give them the smallest allocation possible if alloc=0 is requested. https://bugzilla.redhat.com/show_bug.cgi?id=866481 --- src/storage/storage_backend_logical.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index eebeec1..de43c3a 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -725,7 +725,8 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, NULL); virCommandAddArg(cmd, "-L"); if (vol->capacity != vol->allocation) { - virCommandAddArgFormat(cmd, "%lluK", VIR_DIV_UP(vol->allocation, 1024)); + virCommandAddArgFormat(cmd, "%lluK", + VIR_DIV_UP(vol->allocation ? vol->allocation : 1, 1024)); virCommandAddArg(cmd, "--virtualsize"); } virCommandAddArgFormat(cmd, "%lluK", VIR_DIV_UP(vol->capacity, 1024)); -- 1.7.11.7

On 10/16/2012 06:38 PM, Cole Robinson wrote:
On F17 at least, this command fails:
$ sudo /usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt Unable to create new logical volume with no extents
Which is unfortunate since allocation=0 is what virt-manager tries to use by default.
Rather than telling the user 'don't do that', let's just give them the smallest allocation possible if alloc=0 is requested.
https://bugzilla.redhat.com/show_bug.cgi?id=866481 --- src/storage/storage_backend_logical.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ACK -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 10/16/2012 09:14 PM, Eric Blake wrote:
On 10/16/2012 06:38 PM, Cole Robinson wrote:
On F17 at least, this command fails:
$ sudo /usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt Unable to create new logical volume with no extents
Which is unfortunate since allocation=0 is what virt-manager tries to use by default.
Rather than telling the user 'don't do that', let's just give them the smallest allocation possible if alloc=0 is requested.
https://bugzilla.redhat.com/show_bug.cgi?id=866481 --- src/storage/storage_backend_logical.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ACK
Thanks Eric, pushed now. - Cole

On 10/16/2012 06:38 PM, Cole Robinson wrote:
Before: $ sudo virsh vol-create-as --pool vgvirt sparsetest --capacity 16M --allocation 0 error: Failed to create vol sparsetest error: internal error Child process (/usr/sbin/lvchange -aln vgvirt/sparsetest) unexpected exit status 5: One or more specified logical volume(s) not found.
After: $ sudo virsh vol-create-as --pool vgvirt sparsetest --capacity 16M --allocation 0 error: Failed to create vol sparsetest error: internal error Child process (/usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt) unexpected exit status 5: Unable to create new logical volume with no extents --- src/storage/storage_backend_logical.c | 3 +++ 1 file changed, 3 insertions(+)
ACK -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Cole Robinson
-
Eric Blake