if (ret->name == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing volume name element"));
- goto cleanup;
+ goto error;
}
/* Auto-generated so deliberately ignore */
if (capacity == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing capacity element"));
- goto cleanup;
+ goto error;
}
if (virStorageSize(unit, capacity, &ret->capacity) < 0)
- goto cleanup;
- VIR_FREE(capacity);
+ goto error;
VIR_FREE(unit);
allocation = virXPathString("string(./allocation)", ctxt);
if (allocation) {
unit = virXPathString("string(./allocation/@unit)", ctxt);
if (virStorageSize(unit, allocation, &ret->allocation) < 0)
- goto cleanup;
- VIR_FREE(allocation);
- VIR_FREE(unit);
+ goto error;
} else {
ret->allocation = ret->capacity;
}
virReportError(VIR_ERR_XML_ERROR,
_("unknown volume format type %s"), format);
VIR_FREE(format);
- goto cleanup;
+ goto error;
}
VIR_FREE(format);
}
if (virStorageDefParsePerms(ctxt, &ret->target.perms,
"./target/permissions",
DEFAULT_VOL_PERM_MODE) < 0)
- goto cleanup;
+ goto error;
node = virXPathNode("./target/encryption", ctxt);
if (node != NULL) {
ret->target.encryption = virStorageEncryptionParseNode(ctxt->doc,
node);
if (ret->target.encryption == NULL)
- goto cleanup;
+ goto error;
}
ret->backingStore.path = virXPathString("string(./backingStore/path)", ctxt);
virReportError(VIR_ERR_XML_ERROR,
_("unknown volume format type %s"), format);
VIR_FREE(format);
- goto cleanup;
+ goto error;
}
VIR_FREE(format);
}
if (virStorageDefParsePerms(ctxt, &ret->backingStore.perms,
"./backingStore/permissions",
DEFAULT_VOL_PERM_MODE) < 0)
- goto cleanup;
-
- return ret;
+ goto error;
cleanup:
VIR_FREE(allocation);
VIR_FREE(capacity);
VIR_FREE(unit);
+ return ret;
+
+error:
virStorageVolDefFree(ret);
- return NULL;
+ ret = NULL;
+ goto cleanup;
}
virStorageVolDefPtr