]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: lvm: Don't overwrite lvcreate errors
authorCole Robinson <crobinso@redhat.com>
Wed, 17 Oct 2012 00:25:41 +0000 (20:25 -0400)
committerCole Robinson <crobinso@redhat.com>
Wed, 17 Oct 2012 01:16:44 +0000 (21:16 -0400)
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

index a9d785ccbfbdfe704992c9163eb9e7cb055a0a04..eebeec1ba80f3837ac99d28b270fee00e95c7356 100644 (file)
@@ -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;
 }