[PATCH 1/3] qemu: throw original error when failing to lookup pool or volume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/qemu/qemu_conf.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 094f9f7..d616d7a 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1466,6 +1466,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
     virStoragePoolPtr pool = NULL;
     virStorageVolPtr vol = NULL;
     virStorageVolInfo info;
+    virErrorPtr orig_err = NULL;
     int ret = -1;
 
     if (def->type != VIR_DOMAIN_DISK_TYPE_VOLUME)
@@ -1475,7 +1476,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
         return 0;
 
     if (!(pool = virStoragePoolLookupByName(conn, def->srcpool->pool)))
-        return -1;
+        goto cleanup;
 
     if (!(vol = virStorageVolLookupByName(pool, def->srcpool->volume)))
         goto cleanup;
@@ -1506,7 +1507,15 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
     def->srcpool->voltype = info.type;
     ret = 0;
 cleanup:
+    if (ret < 0 && !orig_err)
+        orig_err = virSaveLastError();
+
     virStoragePoolFree(pool);
     virStorageVolFree(vol);
+
+    if (orig_err) {
+        virSetError(orig_err);
+        virFreeError(orig_err);
+    }
     return ret;
 }
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]