mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virStorageBackendISCSIDirectFindPoolSources: Rework cleanup
virISCSIDirectScanTargets now returns a GStrv, so we can use automatic cleanup for it and get rid of the cleanup section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e51ffd2e33
commit
71012d7164
@ -485,8 +485,7 @@ virStorageBackendISCSIDirectFindPoolSources(const char *srcSpec,
|
|||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
size_t ntargets = 0;
|
size_t ntargets = 0;
|
||||||
char **targets = NULL;
|
g_auto(GStrv) targets = NULL;
|
||||||
char *ret = NULL;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
g_autoptr(virStoragePoolSourceList) list = g_new0(virStoragePoolSourceList, 1);
|
g_autoptr(virStoragePoolSourceList) list = g_new0(virStoragePoolSourceList, 1);
|
||||||
g_autofree char *portal = NULL;
|
g_autofree char *portal = NULL;
|
||||||
@ -508,20 +507,20 @@ virStorageBackendISCSIDirectFindPoolSources(const char *srcSpec,
|
|||||||
if (source->nhost != 1) {
|
if (source->nhost != 1) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Expected exactly 1 host for the storage pool"));
|
_("Expected exactly 1 host for the storage pool"));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!source->initiator.iqn) {
|
if (!source->initiator.iqn) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("missing initiator IQN"));
|
_("missing initiator IQN"));
|
||||||
goto cleanup;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(portal = virStorageBackendISCSIDirectPortal(source)))
|
if (!(portal = virStorageBackendISCSIDirectPortal(source)))
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
if (virISCSIDirectScanTargets(source->initiator.iqn, portal, &ntargets, &targets) < 0)
|
if (virISCSIDirectScanTargets(source->initiator.iqn, portal, &ntargets, &targets) < 0)
|
||||||
goto cleanup;
|
return NULL;
|
||||||
|
|
||||||
list->sources = g_new0(virStoragePoolSource, ntargets);
|
list->sources = g_new0(virStoragePoolSource, ntargets);
|
||||||
|
|
||||||
@ -541,14 +540,7 @@ virStorageBackendISCSIDirectFindPoolSources(const char *srcSpec,
|
|||||||
list->nsources++;
|
list->nsources++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ret = virStoragePoolSourceListFormat(list)))
|
return virStoragePoolSourceListFormat(list);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
for (i = 0; i < ntargets; i++)
|
|
||||||
VIR_FREE(targets[i]);
|
|
||||||
VIR_FREE(targets);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct iscsi_context *
|
static struct iscsi_context *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user