mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuConnectGetAllDomainStats: Simplify qemuDomainGetStats() error handling
In qemuConnectGetAllDomainStats() there a loop that iterates over all domains that stats are to be fetched for. Within this loop the qemuDomainGetStats() is called which is responsible for fetching stats for an individual domain. Now, the code that handles successful and failure cases is almost the same. Rework it, so that the code is deduplicated. Note, that the check for !tmp is dropped because upon successful return from qemuDomainGetStats() it is always allocated. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2c6b8cb507
commit
8ad2edad94
@ -18830,6 +18830,10 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
|
|||||||
unsigned int privflags = 0;
|
unsigned int privflags = 0;
|
||||||
unsigned int requestedStats = stats;
|
unsigned int requestedStats = stats;
|
||||||
unsigned int domflags = 0;
|
unsigned int domflags = 0;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING)
|
||||||
|
domflags |= QEMU_DOMAIN_STATS_BACKING;
|
||||||
|
|
||||||
virObjectLock(vm);
|
virObjectLock(vm);
|
||||||
|
|
||||||
@ -18854,23 +18858,17 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
/* else: without a job it's still possible to gather some data */
|
/* else: without a job it's still possible to gather some data */
|
||||||
|
|
||||||
if (flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING)
|
rc = qemuDomainGetStats(conn, vm, requestedStats, &tmp, domflags);
|
||||||
domflags |= QEMU_DOMAIN_STATS_BACKING;
|
|
||||||
if (qemuDomainGetStats(conn, vm, requestedStats, &tmp, domflags) < 0) {
|
|
||||||
if (HAVE_JOB(domflags) && vm)
|
|
||||||
qemuDomainObjEndJob(driver, vm);
|
|
||||||
|
|
||||||
virObjectUnlock(vm);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmp)
|
|
||||||
tmpstats[nstats++] = tmp;
|
|
||||||
|
|
||||||
if (HAVE_JOB(domflags))
|
if (HAVE_JOB(domflags))
|
||||||
qemuDomainObjEndJob(driver, vm);
|
qemuDomainObjEndJob(driver, vm);
|
||||||
|
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
|
|
||||||
|
if (rc < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
tmpstats[nstats++] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
*retStats = g_steal_pointer(&tmpstats);
|
*retStats = g_steal_pointer(&tmpstats);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user