Signed-off-by: Shi Lei <shi_lei(a)massclouds.com>
---
po/POTFILES.in | 1 +
src/conf/meson.build | 1 +
src/conf/network_conf.c | 45 ++++++-----------------------------------
src/conf/network_conf.h | 8 +++++---
4 files changed, 13 insertions(+), 42 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c9c0262..0356f1e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
@BUILDDIR(a)src/access/viraccessapicheckqemu.c
@BUILDDIR(a)src/admin/admin_client.h
@BUILDDIR(a)src/admin/admin_server_dispatch_stubs.h
+@BUILDDIR(a)src/conf/network_conf.generated.c
@BUILDDIR(a)src/remote/remote_client_bodies.h
@BUILDDIR(a)src/remote/remote_daemon_dispatch_stubs.h
@SRCDIR(a)scripts/xmlgen/directive.py
diff --git a/src/conf/meson.build b/src/conf/meson.build
index d82bffc..0619ca6 100644
--- a/src/conf/meson.build
+++ b/src/conf/meson.build
@@ -1,4 +1,5 @@
xmlgen_input = [
+ 'network_conf.h',
]
xmlgen_output = []
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 9ca8f74..036df20 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -174,14 +174,6 @@ virNetworkIPDefClear(virNetworkIPDefPtr def)
}
-static void
-virNetworkDNSTxtDefClear(virNetworkDNSTxtDefPtr def)
-{
- VIR_FREE(def->name);
- VIR_FREE(def->value);
-}
-
-
static void
virNetworkDNSHostDefClear(virNetworkDNSHostDefPtr def)
{
@@ -885,7 +877,7 @@ virNetworkDNSSrvDefParseXML(const char *networkName,
}
-static int
+int
virNetworkDNSTxtDefParseXMLHook(xmlNodePtr node G_GNUC_UNUSED,
virNetworkDNSTxtDefPtr def,
const char *networkName,
@@ -926,33 +918,6 @@ virNetworkDNSTxtDefParseXMLHook(xmlNodePtr node G_GNUC_UNUSED,
}
-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,
- NULL, &partialOkay) < 0)
- goto error;
-
- return 0;
-
- error:
- virNetworkDNSTxtDefClear(def);
- return -1;
-}
-
-
static int
virNetworkDNSDefParseXML(const char *networkName,
xmlNodePtr node,
@@ -1080,8 +1045,8 @@ virNetworkDNSDefParseXML(const char *networkName,
return -1;
for (i = 0; i < ntxts; i++) {
- if (virNetworkDNSTxtDefParseXML(networkName, txtNodes[i],
- &def->txts[def->ntxts], false) <
0) {
+ if (virNetworkDNSTxtDefParseXML(txtNodes[i],
&def->txts[def->ntxts],
+ networkName, def, NULL) < 0) {
return -1;
}
def->ntxts++;
@@ -3637,6 +3602,7 @@ virNetworkDefUpdateDNSTxt(virNetworkDefPtr def,
virNetworkDNSTxtDef txt;
bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST ||
command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST);
+ bool notAdd;
memset(&txt, 0, sizeof(txt));
@@ -3650,7 +3616,8 @@ virNetworkDefUpdateDNSTxt(virNetworkDefPtr def,
if (virNetworkDefUpdateCheckElementName(def, ctxt->node, "txt") < 0)
goto cleanup;
- if (virNetworkDNSTxtDefParseXML(def->name, ctxt->node, &txt, !isAdd) <
0)
+ notAdd = !isAdd;
+ if (virNetworkDNSTxtDefParseXML(ctxt->node, &txt, def->name, def,
¬Add) < 0)
goto cleanup;
for (foundIdx = 0; foundIdx < dns->ntxts; foundIdx++) {
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 34b9aa9..d5fd8cc 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -130,9 +130,9 @@ struct _virNetworkDHCPHostDef {
typedef struct _virNetworkDNSTxtDef virNetworkDNSTxtDef;
typedef virNetworkDNSTxtDef *virNetworkDNSTxtDefPtr;
-struct _virNetworkDNSTxtDef {
- char *name;
- char *value;
+struct _virNetworkDNSTxtDef { /* genparse:concisehook */
+ char *name; /* xmlattr, required */
+ char *value; /* xmlattr */
};
typedef struct _virNetworkDNSSrvDef virNetworkDNSSrvDef;
@@ -443,3 +443,5 @@ virNetworkDefUpdateSection(virNetworkDefPtr def,
unsigned int flags); /* virNetworkUpdateFlags */
VIR_ENUM_DECL(virNetworkTaint);
+
+#include "network_conf.generated.h"
--
2.25.1