]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Save qemuDomainGetStats error
authorJohn Ferlan <jferlan@redhat.com>
Tue, 27 Nov 2018 15:08:53 +0000 (10:08 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 6 Dec 2018 16:38:07 +0000 (11:38 -0500)
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 <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index 90cbc02745a0fcfb655f2e6c574e6ce2e4565a77..6fe5a43aeb15fdb2f675486902ecc15913bc5609 100644 (file)
@@ -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;
 }