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:
Daniel Henrique Barboza 2020-07-17 18:15:54 -03:00 committed by Jiri Denemark
parent f187b2fb98
commit 661533fb67

View File

@ -13343,50 +13343,44 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps,
virCPUDefPtr *cpus,
int ncpus)
{
qemuProcessQMPPtr proc;
virCPUDefPtr ret = NULL;
virCPUDefPtr baseline = NULL;
g_autoptr(qemuProcessQMP) proc = NULL;
g_autoptr(virCPUDef) baseline = NULL;
qemuMonitorCPUModelInfoPtr result = NULL;
size_t i;
if (!(proc = qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps),
libDir, runUid, runGid, false)))
goto cleanup;
return NULL;
if (qemuProcessQMPStart(proc) < 0)
goto cleanup;
return NULL;
if (VIR_ALLOC(baseline) < 0)
goto cleanup;
return NULL;
if (virCPUDefCopyModel(baseline, cpus[0], false))
goto cleanup;
return NULL;
for (i = 1; i < ncpus; i++) {
if (qemuMonitorGetCPUModelBaseline(proc->mon, baseline,
cpus[i], &result) < 0)
goto cleanup;
return NULL;
if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
goto cleanup;
return NULL;
}
if (expand_features) {
if (qemuMonitorGetCPUModelExpansion(proc->mon,
QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL,
baseline, true, false, &result) < 0)
goto cleanup;
return NULL;
if (qemuConnectStealCPUModelFromInfo(baseline, &result) < 0)
goto cleanup;
return NULL;
}
ret = g_steal_pointer(&baseline);
cleanup:
qemuProcessQMPFree(proc);
virCPUDefFree(baseline);
return ret;
return g_steal_pointer(&baseline);
}