conf: Add XML format/parse methods for VIR_STORAGE_NET_PROTOCOL_NFS

Signed-off-by: Ryan Gahagan <rgahagan@cs.utexas.edu>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Ryan Gahagan 2021-01-06 15:32:29 -06:00 committed by Peter Krempa
parent 943871f971
commit 86e26645ee

View File

@ -6888,6 +6888,23 @@ virDomainStorageNetworkParseHosts(xmlNodePtr node,
}
static void
virDomainStorageNetworkParseNFS(xmlNodePtr node,
xmlXPathContextPtr ctxt,
virStorageSourcePtr src)
{
xmlNodePtr nfsIdentityNode = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
ctxt->node = node;
if ((nfsIdentityNode = virXPathNode("./identity", ctxt))) {
src->nfs_user = virXMLPropString(nfsIdentityNode, "user");
src->nfs_group = virXMLPropString(nfsIdentityNode, "group");
}
}
static int
virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
xmlXPathContextPtr ctxt,
@ -8250,6 +8267,9 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
if (virDomainStorageNetworkParseHosts(node, ctxt, &src->hosts, &src->nhosts) < 0)
return -1;
if (src->protocol == VIR_STORAGE_NET_PROTOCOL_NFS)
virDomainStorageNetworkParseNFS(node, ctxt, src);
virStorageSourceNetworkAssignDefaultPorts(src);
virStorageSourceInitiatorParseXML(ctxt, &src->initiator);
@ -23851,6 +23871,17 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
virBufferAddLit(childBuf, "/>\n");
}
if (src->protocol == VIR_STORAGE_NET_PROTOCOL_NFS &&
(src->nfs_user || src->nfs_group)) {
virBufferAddLit(childBuf, "<identity");
virBufferEscapeString(childBuf, " user='%s'", src->nfs_user);
virBufferEscapeString(childBuf, " group='%s'", src->nfs_group);
virBufferAddLit(childBuf, "/>\n");
}
virBufferEscapeString(childBuf, "<snapshot name='%s'/>\n", src->snapshot);
virBufferEscapeString(childBuf, "<config file='%s'/>\n", src->configFile);