From: Ján Tomko Date: Wed, 24 Jul 2013 08:38:20 +0000 (+0200) Subject: Don't overwrite errors in qemuTranslateDiskSourcePool X-Git-Tag: v1.1.1-rc2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=926055474dca4439c6db6832d16f90b7141ebd1a;p=thirdparty%2Flibvirt.git Don't overwrite errors in qemuTranslateDiskSourcePool Both virStoragePoolFree and virStorageVolFree reset the last error, which might lead to the cryptic message: An error occurred, but the cause is unknown When the volume wasn't found, virStorageVolFree was called with NULL, leading to an error: invalid storage volume pointer in virStorageVolFree This patch changes it to: Storage volume not found: no storage vol with matching name 'tomato' --- diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 3e7b78a30f..18e926cc60 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1248,6 +1248,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, char *poolxml = NULL; virStorageVolInfo info; int ret = -1; + virErrorPtr savedError = NULL; if (def->type != VIR_DOMAIN_DISK_TYPE_VOLUME) return 0; @@ -1324,8 +1325,17 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, def->srcpool->voltype = info.type; ret = 0; cleanup: - virStoragePoolFree(pool); - virStorageVolFree(vol); + if (ret < 0) + savedError = virSaveLastError(); + if (pool) + virStoragePoolFree(pool); + if (vol) + virStorageVolFree(vol); + if (savedError) { + virSetError(savedError); + virFreeError(savedError); + } + VIR_FREE(poolxml); virStoragePoolDefFree(pooldef); return ret;