qemuRefreshPRManagerState: Automatically free GHashTable and refactor cleanup

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Peter Krempa 2021-11-30 11:49:24 +01:00
parent b59430d107
commit 6e9ddad43b

View File

@ -2291,25 +2291,22 @@ qemuRefreshPRManagerState(virQEMUDriver *driver,
virDomainObj *vm) virDomainObj *vm)
{ {
qemuDomainObjPrivate *priv = vm->privateData; qemuDomainObjPrivate *priv = vm->privateData;
GHashTable *info = NULL; g_autoptr(GHashTable) info = NULL;
int ret = -1; int rc;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER) || if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_PR_MANAGER_HELPER) ||
!qemuDomainDefHasManagedPR(vm)) !qemuDomainDefHasManagedPR(vm))
return 0; return 0;
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorGetPRManagerInfo(priv->mon, &info); rc = qemuMonitorGetPRManagerInfo(priv->mon, &info);
qemuDomainObjExitMonitor(driver, vm); qemuDomainObjExitMonitor(driver, vm);
if (ret < 0) if (rc < 0)
goto cleanup; return -1;
ret = qemuProcessRefreshPRManagerState(vm, info);
cleanup: return qemuProcessRefreshPRManagerState(vm, info);
virHashFree(info);
return ret;
} }