mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
conf: Refactor control flow in virDomainDiskBackingStoreParse
The function does not have any code in the 'cleanup' label so we can simplify the control flow. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4885e9fdd9
commit
3145285a06
@ -9162,19 +9162,16 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
|
|||||||
{
|
{
|
||||||
VIR_XPATH_NODE_AUTORESTORE(ctxt);
|
VIR_XPATH_NODE_AUTORESTORE(ctxt);
|
||||||
xmlNodePtr source;
|
xmlNodePtr source;
|
||||||
int ret = -1;
|
|
||||||
VIR_AUTOUNREF(virStorageSourcePtr) backingStore = NULL;
|
VIR_AUTOUNREF(virStorageSourcePtr) backingStore = NULL;
|
||||||
VIR_AUTOFREE(char *) type = NULL;
|
VIR_AUTOFREE(char *) type = NULL;
|
||||||
VIR_AUTOFREE(char *) format = NULL;
|
VIR_AUTOFREE(char *) format = NULL;
|
||||||
VIR_AUTOFREE(char *) idx = NULL;
|
VIR_AUTOFREE(char *) idx = NULL;
|
||||||
|
|
||||||
if (!(ctxt->node = virXPathNode("./backingStore", ctxt))) {
|
if (!(ctxt->node = virXPathNode("./backingStore", ctxt)))
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(backingStore = virStorageSourceNew()))
|
if (!(backingStore = virStorageSourceNew()))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* backing store is always read-only */
|
/* backing store is always read-only */
|
||||||
backingStore->readonly = true;
|
backingStore->readonly = true;
|
||||||
@ -9182,52 +9179,49 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
|
|||||||
/* terminator does not have a type */
|
/* terminator does not have a type */
|
||||||
if (!(type = virXMLPropString(ctxt->node, "type"))) {
|
if (!(type = virXMLPropString(ctxt->node, "type"))) {
|
||||||
VIR_STEAL_PTR(src->backingStore, backingStore);
|
VIR_STEAL_PTR(src->backingStore, backingStore);
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
|
if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
|
||||||
(idx = virXMLPropString(ctxt->node, "index")) &&
|
(idx = virXMLPropString(ctxt->node, "index")) &&
|
||||||
virStrToLong_uip(idx, NULL, 10, &backingStore->id) < 0) {
|
virStrToLong_uip(idx, NULL, 10, &backingStore->id) < 0) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, _("invalid disk index '%s'"), idx);
|
virReportError(VIR_ERR_XML_ERROR, _("invalid disk index '%s'"), idx);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
backingStore->type = virStorageTypeFromString(type);
|
backingStore->type = virStorageTypeFromString(type);
|
||||||
if (backingStore->type <= 0) {
|
if (backingStore->type <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown disk backing store type '%s'"), type);
|
_("unknown disk backing store type '%s'"), type);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(format = virXPathString("string(./format/@type)", ctxt))) {
|
if (!(format = virXPathString("string(./format/@type)", ctxt))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("missing disk backing store format"));
|
_("missing disk backing store format"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
backingStore->format = virStorageFileFormatTypeFromString(format);
|
backingStore->format = virStorageFileFormatTypeFromString(format);
|
||||||
if (backingStore->format <= 0) {
|
if (backingStore->format <= 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unknown disk backing store format '%s'"), format);
|
_("unknown disk backing store format '%s'"), format);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(source = virXPathNode("./source", ctxt))) {
|
if (!(source = virXPathNode("./source", ctxt))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("missing disk backing store source"));
|
_("missing disk backing store source"));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainDiskSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
|
if (virDomainDiskSourceParse(source, ctxt, backingStore, flags, xmlopt) < 0 ||
|
||||||
virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) < 0)
|
virDomainDiskBackingStoreParse(ctxt, backingStore, flags, xmlopt) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
VIR_STEAL_PTR(src->backingStore, backingStore);
|
VIR_STEAL_PTR(src->backingStore, backingStore);
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PARSE_IOTUNE(val) \
|
#define PARSE_IOTUNE(val) \
|
||||||
|
Loading…
Reference in New Issue
Block a user