[RFC 23/29] conf: Extract error-checking code from virNetworkDNSDefParseXML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx>
---
 docs/schemas/network.rng |  6 +++++-
 src/conf/network_conf.c  | 33 +++++++++++++++++++++++++++------
 2 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 702018b..884cd64 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -259,7 +259,11 @@
         <optional>
           <!-- VIRT:DIRECTIVE {
             "structure": {"output": "src/conf/network_conf"},
-            "clearfunc": {"output": "src/conf/network_conf"}
+            "clearfunc": {"output": "src/conf/network_conf"},
+            "parsefunc": {
+              "post": true,
+              "args.instname": true
+            }
           } -->
           <element name="dns">
             <optional>
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 3a43e40..d231fea 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -764,6 +764,30 @@ virNetworkDNSHostDefParseXMLPost(xmlNodePtr curnode G_GNUC_UNUSED,
 }
 
 
+static int
+virNetworkDNSDefParseXMLPost(xmlNodePtr curnode G_GNUC_UNUSED,
+                             virNetworkDNSDefPtr def,
+                             xmlXPathContextPtr ctxt G_GNUC_UNUSED,
+                             const char *networkName,
+                             const char *enableStr G_GNUC_UNUSED,
+                             const char *forwardPlainNamesStr G_GNUC_UNUSED,
+                             int nForwarderNodes,
+                             int nTxtNodes,
+                             int nSrvNodes,
+                             int nHostNodes)
+{
+    if (def->enable == VIR_TRISTATE_BOOL_NO &&
+        (nForwarderNodes || nHostNodes || nSrvNodes || nTxtNodes)) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Extra data in disabled network '%s'"),
+                       networkName);
+        return -1;
+    }
+
+    return 0;
+}
+
+
 static int
 virNetworkDNSDefParseXML(const char *networkName,
                          xmlNodePtr node,
@@ -892,13 +916,10 @@ virNetworkDNSDefParseXML(const char *networkName,
         }
     }
 
-    if (def->enable == VIR_TRISTATE_BOOL_NO &&
-        (nfwds || nhosts || nsrvs || ntxts)) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       _("Extra data in disabled network '%s'"),
-                       networkName);
+    if (virNetworkDNSDefParseXMLPost(node, def, ctxt, networkName, enable,
+                                     forwardPlainNames, nfwds, ntxts,
+                                     nsrvs, nhosts) < 0)
         goto cleanup;
-    }
 
     ret = 0;
  cleanup:
-- 
2.17.1







[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux