virDomainHostdevSubsysSCSIPtr def,
xmlXPathContextPtr ctxt)
{
- int ret = -1;
int auth_secret_usage = -1;
xmlNodePtr cur;
- virStorageAuthDefPtr authdef = NULL;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &def->u.iscsi;
+ VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
/* For the purposes of command line creation, this needs to look
* like a disk storage source */
if (!(iscsisrc->src->path = virXMLPropString(sourcenode, "name"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing iSCSI hostdev source path name"));
- goto cleanup;
+ return -1;
}
if (virDomainStorageNetworkParseHosts(sourcenode, &iscsisrc->src->hosts,
&iscsisrc->src->nhosts) < 0)
- goto cleanup;
+ return -1;
if (iscsisrc->src->nhosts < 1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing the host address for the iSCSI hostdev"));
- goto cleanup;
+ return -1;
}
if (iscsisrc->src->nhosts > 1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("only one source host address may be specified "
"for the iSCSI hostdev"));
- goto cleanup;
+ return -1;
}
cur = sourcenode->children;
if (cur->type == XML_ELEMENT_NODE &&
virXMLNodeNameEqual(cur, "auth")) {
if (!(authdef = virStorageAuthDefParse(cur, ctxt)))
- goto cleanup;
+ return -1;
if ((auth_secret_usage =
virSecretUsageTypeFromString(authdef->secrettype)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("invalid secret type %s"),
authdef->secrettype);
- goto cleanup;
+ return -1;
}
if (auth_secret_usage != VIR_SECRET_USAGE_TYPE_ISCSI) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("hostdev invalid secret type '%s'"),
authdef->secrettype);
- goto cleanup;
+ return -1;
}
VIR_STEAL_PTR(iscsisrc->src->auth, authdef);
}
cur = cur->next;
}
- ret = 0;
-
- cleanup:
- virStorageAuthDefFree(authdef);
- return ret;
+ return 0;
}
static int
virStorageEncryptionPtr encryption = NULL;
char *serial = NULL;
char *startupPolicy = NULL;
- virStorageAuthDefPtr authdef = NULL;
char *tray = NULL;
char *removable = NULL;
char *logical_block_size = NULL;
char *vendor = NULL;
char *product = NULL;
char *domain_name = NULL;
+ VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
if (!(def = virDomainDiskDefNew(xmlopt)))
return NULL;
VIR_FREE(target);
VIR_FREE(tray);
VIR_FREE(removable);
- virStorageAuthDefFree(authdef);
VIR_FREE(devaddr);
VIR_FREE(serial);
virStorageEncryptionFree(encryption);
virStorageAuthDefPtr
virStorageAuthDefCopy(const virStorageAuthDef *src)
{
- virStorageAuthDefPtr authdef;
virStorageAuthDefPtr ret = NULL;
+ VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
if (VIR_ALLOC(authdef) < 0)
return NULL;
if (VIR_STRDUP(authdef->username, src->username) < 0)
- goto cleanup;
+ return NULL;
/* Not present for storage pool, but used for disk source */
if (VIR_STRDUP(authdef->secrettype, src->secrettype) < 0)
- goto cleanup;
+ return NULL;
authdef->authType = src->authType;
if (virSecretLookupDefCopy(&authdef->seclookupdef, &src->seclookupdef) < 0)
- goto cleanup;
+ return NULL;
VIR_STEAL_PTR(ret, authdef);
- cleanup:
- virStorageAuthDefFree(authdef);
return ret;
}
xmlXPathContextPtr ctxt)
{
xmlNodePtr saveNode = ctxt->node;
- virStorageAuthDefPtr authdef = NULL;
virStorageAuthDefPtr ret = NULL;
xmlNodePtr secretnode = NULL;
char *authtype = NULL;
+ VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
ctxt->node = node;
cleanup:
VIR_FREE(authtype);
- virStorageAuthDefFree(authdef);
ctxt->node = saveNode;
return ret;
{
char *options = NULL;
char *p, *e, *next;
- virStorageAuthDefPtr authdef = NULL;
+ VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
/* optionally skip the "rbd:" prefix if provided */
if (STRPREFIX(rbdstr, "rbd:"))
error:
VIR_FREE(options);
- virStorageAuthDefFree(authdef);
return -1;
}