提交 5047524b 编写于 作者: P Peter Krempa

conf: Split out parsing of network disk source XML elements

virDomainDiskSourceParse got to the point of being an ugly spaghetti
mess by adding more and more stuff into it. Split out parsing of network
disk information into a separate function so that it stays contained.
上级 5656596a
......@@ -8106,32 +8106,18 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node,
}
int
virDomainDiskSourceParse(xmlNodePtr node,
static int
virDomainDiskSourceNetworkParse(xmlNodePtr node,
xmlXPathContextPtr ctxt,
virStorageSourcePtr src,
unsigned int flags)
{
int ret = -1;
char *protocol = NULL;
xmlNodePtr saveNode = ctxt->node;
char *haveTLS = NULL;
char *tlsCfg = NULL;
int tlsCfgVal;
int ret = -1;
ctxt->node = node;
switch ((virStorageType)src->type) {
case VIR_STORAGE_TYPE_FILE:
src->path = virXMLPropString(node, "file");
break;
case VIR_STORAGE_TYPE_BLOCK:
src->path = virXMLPropString(node, "dev");
break;
case VIR_STORAGE_TYPE_DIR:
src->path = virXMLPropString(node, "dir");
break;
case VIR_STORAGE_TYPE_NETWORK:
if (!(protocol = virXMLPropString(node, "protocol"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing network source protocol type"));
......@@ -8207,6 +8193,38 @@ virDomainDiskSourceParse(xmlNodePtr node,
virStorageSourceNetworkAssignDefaultPorts(src);
ret = 0;
cleanup:
VIR_FREE(protocol);
return ret;
}
int
virDomainDiskSourceParse(xmlNodePtr node,
xmlXPathContextPtr ctxt,
virStorageSourcePtr src,
unsigned int flags)
{
int ret = -1;
xmlNodePtr saveNode = ctxt->node;
ctxt->node = node;
switch ((virStorageType)src->type) {
case VIR_STORAGE_TYPE_FILE:
src->path = virXMLPropString(node, "file");
break;
case VIR_STORAGE_TYPE_BLOCK:
src->path = virXMLPropString(node, "dev");
break;
case VIR_STORAGE_TYPE_DIR:
src->path = virXMLPropString(node, "dir");
break;
case VIR_STORAGE_TYPE_NETWORK:
if (virDomainDiskSourceNetworkParse(node, ctxt, src, flags) < 0)
goto cleanup;
break;
case VIR_STORAGE_TYPE_VOLUME:
if (virDomainDiskSourcePoolDefParse(node, &src->srcpool) < 0)
......@@ -8229,9 +8247,6 @@ virDomainDiskSourceParse(xmlNodePtr node,
ret = 0;
cleanup:
VIR_FREE(protocol);
VIR_FREE(haveTLS);
VIR_FREE(tlsCfg);
ctxt->node = saveNode;
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册