mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-06 17:17:56 +03:00
qemu_driver.c: modernize qemuConnectCPUModelBaseline()
Use g_autoptr() on pointers and remove the unneeded 'cleanup' label. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Message-Id: <20200717211556.1024748-4-danielhb413@gmail.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
f187b2fb98
commit
661533fb67
@ -13343,50 +13343,44 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps,
|
|||||||
virCPUDefPtr *cpus,
|
virCPUDefPtr *cpus,
|
||||||
int ncpus)
|
int ncpus)
|
||||||
{
|
{
|
||||||
qemuProcessQMPPtr proc;
|
g_autoptr(qemuProcessQMP) proc = NULL;
|
||||||
virCPUDefPtr ret = NULL;
|
g_autoptr(virCPUDef) baseline = NULL;
|
||||||
virCPUDefPtr baseline = NULL;
|
|
||||||
qemuMonitorCPUModelInfoPtr result = NULL;
|
qemuMonitorCPUModelInfoPtr result = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps),
|
if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps),
|
||||||
libDir, runUid, runGid, false)))
|
libDir, runUid, runGid, false)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (qemuProcessQMPStart(proc) < 0)
|
if (qemuProcessQMPStart(proc) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(baseline) < 0)
|
if (VIR_ALLOC(baseline) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (virCPUDefCopyModel(baseline, cpus[0], false))
|
if (virCPUDefCopyModel(baseline, cpus[0], false))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
for (i = 1; i < ncpus; i++) {
|
for (i = 1; i < ncpus; i++) {
|
||||||
if (qemuMonitorGetCPUModelBaseline(proc->mon, baseline,
|
if (qemuMonitorGetCPUModelBaseline(proc->mon, baseline,
|
||||||
cpus[i], &result) < 0)
|
cpus[i], &result) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
|
if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expand_features) {
|
if (expand_features) {
|
||||||
if (qemuMonitorGetCPUModelExpansion(proc->mon,
|
if (qemuMonitorGetCPUModelExpansion(proc->mon,
|
||||||
QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
|
QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
|
||||||
baseline, true, false, &result) < 0)
|
baseline, true, false, &result) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
|
if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = g_steal_pointer(&baseline);
|
return g_steal_pointer(&baseline);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
qemuProcessQMPFree(proc);
|
|
||||||
virCPUDefFree(baseline);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user