hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainLookupByName

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Matt Coleman 2021-01-21 13:50:56 -05:00 committed by Laine Stump
parent 38560b7efe
commit ebca8a6b72

View File

@ -1689,23 +1689,20 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name)
{
virDomainPtr domain = NULL;
hypervPrivate *priv = conn->privateData;
Msvm_ComputerSystem *computerSystem = NULL;
g_autoptr(Msvm_ComputerSystem) computerSystem = NULL;
if (hypervGetVirtualSystemByName(priv, name, &computerSystem) < 0)
goto cleanup;
return NULL;
if (computerSystem->next) {
virReportError(VIR_ERR_MULTIPLE_DOMAINS,
_("Multiple domains exist with the name '%s': repeat the request using a UUID"),
name);
goto cleanup;
return NULL;
}
hypervMsvmComputerSystemToDomain(conn, computerSystem, &domain);
cleanup:
hypervFreeObject((hypervObject *)computerSystem);
return domain;
}