From e1fc7ec08143eca29a9f449de000d04b9bbe09a0 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Tue, 27 Nov 2018 10:08:53 -0500 Subject: [PATCH] qemu: Save qemuDomainGetStats error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During qemuConnectGetAllDomainStats if qemuDomainGetStats causes a failure, then when collecting more than one domain's worth of statistics the loop in virDomainStatsRecordListFree would call virDomainFree which would call virResetLastError effectively wiping out the reason we failed leaving the caller with no idea why the collection failed. To fix this, let's Preserve the error and Restore it prior to return so that a caller such as 'virsh domstats' doesn't get the generic "error: An error occurred, but the cause is unknown". Signed-off-by: John Ferlan Reviewed-by: Ján Tomko --- src/qemu/qemu_driver.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 90cbc02745..6fe5a43aeb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21100,6 +21100,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, unsigned int flags) { virQEMUDriverPtr driver = conn->privateData; + virErrorPtr orig_err = NULL; virDomainObjPtr *vms = NULL; virDomainObjPtr vm; size_t nvms; @@ -21190,8 +21191,10 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, ret = nstats; cleanup: + virErrorPreserveLast(&orig_err); virDomainStatsRecordListFree(tmpstats); virObjectListFreeCount(vms, nvms); + virErrorRestore(&orig_err); return ret; }