Signed-off-by: Shi Lei <shi_lei(a)massclouds.com>
---
src/conf/network_conf.c | 48 +++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 11 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index f1d22b2..47aaef3 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -904,26 +904,25 @@ virNetworkDNSSrvDefParseXML(const char *networkName,
static int
-virNetworkDNSTxtDefParseXML(const char *networkName,
- xmlNodePtr node,
- virNetworkDNSTxtDefPtr def,
- bool partialOkay)
+virNetworkDNSTxtDefParseXMLHook(xmlNodePtr node G_GNUC_UNUSED,
+ virNetworkDNSTxtDefPtr def,
+ const char *networkName,
+ void *opaque)
{
const char *bad = " ,";
+ bool partialOkay = false;
+
+ if (opaque)
+ partialOkay = *((bool *) opaque);
- if (!(def->name = virXMLPropString(node, "name"))) {
- virReportError(VIR_ERR_XML_DETAIL,
- _("missing required name attribute in DNS TXT record "
- "of network %s"), networkName);
- goto error;
- }
if (strcspn(def->name, bad) != strlen(def->name)) {
virReportError(VIR_ERR_XML_DETAIL,
_("prohibited character in DNS TXT record "
"name '%s' of network %s"), def->name,
networkName);
goto error;
}
- if (!(def->value = virXMLPropString(node, "value")) &&
!partialOkay) {
+
+ if (!def->value && !partialOkay) {
virReportError(VIR_ERR_XML_DETAIL,
_("missing required value attribute in DNS TXT record "
"named '%s' of network %s"), def->name,
networkName);
@@ -936,6 +935,33 @@ virNetworkDNSTxtDefParseXML(const char *networkName,
"in DNS TXT record of network %s"), networkName);
goto error;
}
+
+ return 0;
+
+ error:
+ return -1;
+}
+
+
+static int
+virNetworkDNSTxtDefParseXML(const char *networkName,
+ xmlNodePtr node,
+ virNetworkDNSTxtDefPtr def,
+ bool partialOkay)
+{
+ if (!(def->name = virXMLPropString(node, "name"))) {
+ virReportError(VIR_ERR_XML_DETAIL,
+ _("missing required name attribute in DNS TXT record "
+ "of network %s"), networkName);
+ goto error;
+ }
+
+ def->value = virXMLPropString(node, "value");
+
+ if (virNetworkDNSTxtDefParseXMLHook(node, def, networkName,
+ &partialOkay) < 0)
+ goto error;
+
return 0;
error:
--
2.17.1