xmlDocPtr doc = NULL;
xmlNodePtr node = NULL;
xmlXPathContextPtr xpath_ctxt = NULL;
- virStoragePoolSourcePtr def = NULL, ret = NULL;
+ virStoragePoolSourcePtr ret = NULL;
+ VIR_AUTOPTR(virStoragePoolSource) def = NULL;
if (!(doc = virXMLParseStringCtxt(srcSpec,
_("(storage_source_specification)"),
VIR_STEAL_PTR(ret, def);
cleanup:
- virStoragePoolSourceFree(def);
xmlFreeDoc(doc);
xmlXPathFreeContext(xpath_ctxt);
VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_AUTOSTART | \
VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)
+VIR_DEFINE_AUTOPTR_FUNC(virStoragePoolSource, virStoragePoolSourceFree);
+
#endif /* LIBVIRT_STORAGE_CONF_H */
.sources = NULL
}
};
- virStoragePoolSourcePtr source = NULL;
char *ret = NULL;
size_t i;
int retNFS = -1;
int retGluster = 0;
+ VIR_AUTOPTR(virStoragePoolSource) source = NULL;
virCheckFlags(0, NULL);
virStoragePoolSourceClear(&state.list.sources[i]);
VIR_FREE(state.list.sources);
- virStoragePoolSourceFree(source);
return ret;
}
.nsources = 0,
.sources = NULL
};
- virStoragePoolSourcePtr source = NULL;
char *ret = NULL;
int rc;
size_t i;
+ VIR_AUTOPTR(virStoragePoolSource) source = NULL;
virCheckFlags(0, NULL);
virStoragePoolSourceClear(&list.sources[i]);
VIR_FREE(list.sources);
- virStoragePoolSourceFree(source);
return ret;
}
virStorageBackendISCSIFindPoolSources(const char *srcSpec,
unsigned int flags)
{
- virStoragePoolSourcePtr source = NULL;
size_t ntargets = 0;
char **targets = NULL;
char *ret = NULL;
.sources = NULL
};
char *portal = NULL;
+ VIR_AUTOPTR(virStoragePoolSource) source = NULL;
virCheckFlags(0, NULL);
VIR_FREE(targets[i]);
VIR_FREE(targets);
VIR_FREE(portal);
- virStoragePoolSourceFree(source);
return ret;
}
virStorageBackendISCSIDirectFindPoolSources(const char *srcSpec,
unsigned int flags)
{
- virStoragePoolSourcePtr source = NULL;
size_t ntargets = 0;
char **targets = NULL;
char *ret = NULL;
.sources = NULL
};
char *portal = NULL;
+ VIR_AUTOPTR(virStoragePoolSource) source = NULL;
virCheckFlags(0, NULL);
VIR_FREE(targets[i]);
VIR_FREE(targets);
VIR_FREE(portal);
- virStoragePoolSourceFree(source);
return ret;
}
const char *srcSpec,
unsigned int flags)
{
- virStoragePoolSourcePtr source = NULL;
int pool_type;
char *ret = NULL;
+ VIR_AUTOPTR(virStoragePoolSource) source = NULL;
virCheckFlags(0, NULL);
if (!pool_type) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown storage pool type %s"), type);
- goto cleanup;
+ return NULL;
}
if (srcSpec) {
source = virStoragePoolDefParseSourceString(srcSpec, pool_type);
if (!source)
- goto cleanup;
+ return NULL;
}
switch (pool_type) {
case VIR_STORAGE_POOL_LOGICAL:
ignore_value(VIR_STRDUP(ret, defaultPoolSourcesLogicalXML));
- break;
+ return ret;
case VIR_STORAGE_POOL_NETFS:
if (!source || !source->hosts[0].name) {
virReportError(VIR_ERR_INVALID_ARG,
"%s", _("hostname must be specified for netfs sources"));
- goto cleanup;
+ return NULL;
}
ignore_value(virAsprintf(&ret, defaultPoolSourcesNetFSXML,
source->hosts[0].name));
- break;
+ return ret;
default:
virReportError(VIR_ERR_NO_SUPPORT,
_("pool type '%s' does not support source discovery"), type);
}
- cleanup:
- virStoragePoolSourceFree(source);
- return ret;
+ return NULL;
}