mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
qemuDomainGetStatsVcpu: Refactor cleanup
Automatically free 'cpuinfo' and remove the cleanup label and ret variable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
66f0dd63b4
commit
6198c44338
@ -17585,8 +17585,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC_UNUSED,
|
||||
virDomainVcpuDef *vcpu;
|
||||
qemuDomainVcpuPrivate *vcpupriv;
|
||||
size_t i;
|
||||
int ret = -1;
|
||||
virVcpuInfoPtr cpuinfo = NULL;
|
||||
g_autofree virVcpuInfoPtr cpuinfo = NULL;
|
||||
g_autofree unsigned long long *cpuwait = NULL;
|
||||
g_autofree unsigned long long *cpudelay = NULL;
|
||||
qemuDomainObjPrivate *priv = dom->privateData;
|
||||
@ -17615,8 +17614,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC_UNUSED,
|
||||
virDomainDefGetVcpus(dom->def),
|
||||
NULL, 0) < 0) {
|
||||
virResetLastError();
|
||||
ret = 0; /* it's ok to be silent and go ahead */
|
||||
goto cleanup;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (HAVE_JOB(privflags) && qemuDomainRefreshStatsSchema(dom) == 0) {
|
||||
@ -17634,7 +17632,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC_UNUSED,
|
||||
|
||||
if (virTypedParamListAddInt(params, cpuinfo[i].state,
|
||||
"vcpu.%u.state", cpuinfo[i].number) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* stats below are available only if the VM is alive */
|
||||
if (!virDomainObjIsActive(dom))
|
||||
@ -17642,15 +17640,15 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC_UNUSED,
|
||||
|
||||
if (virTypedParamListAddULLong(params, cpuinfo[i].cpuTime,
|
||||
"vcpu.%u.time", cpuinfo[i].number) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virTypedParamListAddULLong(params, cpuwait[i],
|
||||
"vcpu.%u.wait", cpuinfo[i].number) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virTypedParamListAddULLong(params, cpudelay[i],
|
||||
"vcpu.%u.delay", cpuinfo[i].number) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* state below is extracted from the individual vcpu structs */
|
||||
if (!(vcpu = virDomainDefGetVcpu(dom->def, cpuinfo[i].number)))
|
||||
@ -17663,7 +17661,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC_UNUSED,
|
||||
vcpupriv->halted == VIR_TRISTATE_BOOL_YES,
|
||||
"vcpu.%u.halted",
|
||||
cpuinfo[i].number) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!queried_stats)
|
||||
@ -17675,11 +17673,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC_UNUSED,
|
||||
qemuDomainAddStatsFromHashTable(stats, priv->statsSchema, prefix, params);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(cpuinfo);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define QEMU_ADD_NET_PARAM(params, num, name, value) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user