[PATCH 03/11] conf: Add @flags to Network Def processing

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

 



Add a @flags argument when parsing the network definition
via the virNetworkDefParse{XML|Node|String|File} API's as
this will allow us to in the future make parsing decisions
based on the @flags.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/conf/domain_conf.c           |  2 +-
 src/conf/network_conf.c          | 27 +++++++++++++++++----------
 src/conf/network_conf.h          | 12 ++++++++----
 src/conf/virnetworkobj.c         |  4 ++--
 src/esx/esx_network_driver.c     |  2 +-
 src/network/bridge_driver.c      |  4 ++--
 src/qemu/qemu_process.c          |  2 +-
 src/test/test_driver.c           |  6 +++---
 src/vbox/vbox_network.c          |  2 +-
 tests/networkxml2conftest.c      |  2 +-
 tests/networkxml2firewalltest.c  |  2 +-
 tests/networkxml2xmltest.c       |  2 +-
 tests/networkxml2xmlupdatetest.c |  2 +-
 13 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 42b55f01d4..705575fe92 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30004,7 +30004,7 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface)
     if (!(xml = virNetworkGetXMLDesc(net, 0)))
         goto cleanup;
 
-    if (!(def = virNetworkDefParseString(xml)))
+    if (!(def = virNetworkDefParseString(xml, 0)))
         goto cleanup;
 
     switch ((virNetworkForwardType) def->forward.type) {
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c08456ba96..34d132e506 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -259,7 +259,7 @@ virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags)
     /* deep copy with a format/parse cycle */
     if (!(xml = virNetworkDefFormat(def, flags)))
         goto cleanup;
-    newDef = virNetworkDefParseString(xml);
+    newDef = virNetworkDefParseString(xml, 0);
  cleanup:
     VIR_FREE(xml);
     return newDef;
@@ -1584,7 +1584,8 @@ virNetworkForwardDefParseXML(const char *networkName,
 
 
 virNetworkDefPtr
-virNetworkDefParseXML(xmlXPathContextPtr ctxt)
+virNetworkDefParseXML(xmlXPathContextPtr ctxt,
+                      unsigned int flags)
 {
     virNetworkDefPtr def;
     char *tmp = NULL;
@@ -1603,6 +1604,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
     xmlNodePtr vlanNode;
     xmlNodePtr metadataNode = NULL;
 
+    virCheckFlags(0, NULL);
+
     if (VIR_ALLOC(def) < 0)
         return NULL;
 
@@ -2016,14 +2019,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
 
 static virNetworkDefPtr
 virNetworkDefParse(const char *xmlStr,
-                   const char *filename)
+                   const char *filename,
+                   unsigned int flags)
 {
     xmlDocPtr xml;
     virNetworkDefPtr def = NULL;
     int keepBlanksDefault = xmlKeepBlanksDefault(0);
 
     if ((xml = virXMLParse(filename, xmlStr, _("(network_definition)")))) {
-        def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml));
+        def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml), flags);
         xmlFreeDoc(xml);
     }
 
@@ -2033,22 +2037,25 @@ virNetworkDefParse(const char *xmlStr,
 
 
 virNetworkDefPtr
-virNetworkDefParseString(const char *xmlStr)
+virNetworkDefParseString(const char *xmlStr,
+                         unsigned int flags)
 {
-    return virNetworkDefParse(xmlStr, NULL);
+    return virNetworkDefParse(xmlStr, NULL, flags);
 }
 
 
 virNetworkDefPtr
-virNetworkDefParseFile(const char *filename)
+virNetworkDefParseFile(const char *filename,
+                       unsigned int flags)
 {
-    return virNetworkDefParse(NULL, filename);
+    return virNetworkDefParse(NULL, filename, flags);
 }
 
 
 virNetworkDefPtr
 virNetworkDefParseNode(xmlDocPtr xml,
-                       xmlNodePtr root)
+                       xmlNodePtr root,
+                       unsigned int flags)
 {
     xmlXPathContextPtr ctxt = NULL;
     virNetworkDefPtr def = NULL;
@@ -2068,7 +2075,7 @@ virNetworkDefParseNode(xmlDocPtr xml,
     }
 
     ctxt->node = root;
-    def = virNetworkDefParseXML(ctxt);
+    def = virNetworkDefParseXML(ctxt, flags);
 
  cleanup:
     xmlXPathFreeContext(ctxt);
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 54c8ed1c4c..6373b783c6 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -294,17 +294,21 @@ virNetworkDefPtr
 virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags);
 
 virNetworkDefPtr
-virNetworkDefParseXML(xmlXPathContextPtr ctxt);
+virNetworkDefParseXML(xmlXPathContextPtr ctxt,
+                      unsigned int flags);
 
 virNetworkDefPtr
-virNetworkDefParseString(const char *xmlStr);
+virNetworkDefParseString(const char *xmlStr,
+                         unsigned int flags);
 
 virNetworkDefPtr
-virNetworkDefParseFile(const char *filename);
+virNetworkDefParseFile(const char *filename,
+                       unsigned int flags);
 
 virNetworkDefPtr
 virNetworkDefParseNode(xmlDocPtr xml,
-                       xmlNodePtr root);
+                       xmlNodePtr root,
+                       unsigned int flags);
 
 char *
 virNetworkDefFormat(const virNetworkDef *def,
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index b13e5a7b03..d7357007d3 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -885,7 +885,7 @@ virNetworkLoadState(virNetworkObjListPtr nets,
 
     /* parse the definition first */
     ctxt->node = node;
-    if (!(def = virNetworkDefParseXML(ctxt)))
+    if (!(def = virNetworkDefParseXML(ctxt, 0)))
         goto error;
 
     if (STRNEQ(name, def->name)) {
@@ -998,7 +998,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
     if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0)
         goto error;
 
-    if (!(def = virNetworkDefParseFile(configFile)))
+    if (!(def = virNetworkDefParseFile(configFile, 0)))
         goto error;
 
     if (STRNEQ(name, def->name)) {
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index 31bceb7bff..5e2b2b50f7 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -298,7 +298,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
         return NULL;
 
     /* Parse network XML */
-    def = virNetworkDefParseString(xml);
+    def = virNetworkDefParseString(xml, 0);
 
     if (!def)
         return NULL;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f92cc61e47..eef0d83c10 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3609,7 +3609,7 @@ networkCreateXML(virConnectPtr conn,
     virNetworkPtr net = NULL;
     virObjectEventPtr event = NULL;
 
-    if (!(newDef = virNetworkDefParseString(xml)))
+    if (!(newDef = virNetworkDefParseString(xml, 0)))
         goto cleanup;
 
     if (virNetworkCreateXMLEnsureACL(conn, newDef) < 0)
@@ -3661,7 +3661,7 @@ networkDefineXML(virConnectPtr conn,
     virNetworkPtr net = NULL;
     virObjectEventPtr event = NULL;
 
-    if (!(def = virNetworkDefParseString(xml)))
+    if (!(def = virNetworkDefParseString(xml, 0)))
         goto cleanup;
 
     if (virNetworkDefineXMLEnsureACL(conn, def) < 0)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c4e33723d1..ccf6c662c9 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4541,7 +4541,7 @@ qemuProcessGetNetworkAddress(const char *netname,
     if (!xml)
         goto cleanup;
 
-    netdef = virNetworkDefParseString(xml);
+    netdef = virNetworkDefParseString(xml, 0);
     if (!netdef)
         goto cleanup;
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 1a42a4f74b..9826ac3fee 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -966,7 +966,7 @@ testParseNetworks(testDriverPtr privconn,
         if (!node)
             goto error;
 
-        def = virNetworkDefParseNode(ctxt->doc, node);
+        def = virNetworkDefParseNode(ctxt->doc, node, 0);
         if (!def)
             goto error;
 
@@ -3462,7 +3462,7 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml)
     virNetworkPtr net = NULL;
     virObjectEventPtr event = NULL;
 
-    if ((newDef = virNetworkDefParseString(xml)) == NULL)
+    if ((newDef = virNetworkDefParseString(xml, 0)) == NULL)
         goto cleanup;
 
     if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef,
@@ -3498,7 +3498,7 @@ testNetworkDefineXML(virConnectPtr conn,
     virNetworkPtr net = NULL;
     virObjectEventPtr event = NULL;
 
-    if ((newDef = virNetworkDefParseString(xml)) == NULL)
+    if ((newDef = virNetworkDefParseString(xml, 0)) == NULL)
         goto cleanup;
 
     if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, 0)))
diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c
index 50a7a56303..eb47abaf00 100644
--- a/src/vbox/vbox_network.c
+++ b/src/vbox/vbox_network.c
@@ -375,7 +375,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start)
     PRUnichar *networkNameUtf16 = NULL;
     char *networkNameUtf8 = NULL;
     IHostNetworkInterface *networkInterface = NULL;
-    virNetworkDefPtr def = virNetworkDefParseString(xml);
+    virNetworkDefPtr def = virNetworkDefParseString(xml, 0);
     virNetworkIPDefPtr ipdef = NULL;
     unsigned char uuid[VIR_UUID_BUFLEN];
     vboxIID vboxnetiid;
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index 8e7751e36b..569763f0e6 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -29,7 +29,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
     char *pidfile = NULL;
     dnsmasqContext *dctx = NULL;
 
-    if (!(def = virNetworkDefParseFile(inxml)))
+    if (!(def = virNetworkDefParseFile(inxml, 0)))
         goto fail;
 
     if (!(obj = virNetworkObjNew()))
diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c
index 242b645767..49f0300a29 100644
--- a/tests/networkxml2firewalltest.c
+++ b/tests/networkxml2firewalltest.c
@@ -55,7 +55,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
     virCommandSetDryRun(&buf, NULL, NULL);
 
-    if (!(def = virNetworkDefParseFile(xml)))
+    if (!(def = virNetworkDefParseFile(xml, 0)))
         goto cleanup;
 
     if (networkAddFirewallRules(def) < 0)
diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c
index eb7db766fa..7828995df1 100644
--- a/tests/networkxml2xmltest.c
+++ b/tests/networkxml2xmltest.c
@@ -33,7 +33,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
     testCompareNetXML2XMLResult result = TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS;
     virNetworkDefPtr dev = NULL;
 
-    if (!(dev = virNetworkDefParseFile(inxml))) {
+    if (!(dev = virNetworkDefParseFile(inxml, 0))) {
         result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE;
         goto cleanup;
     }
diff --git a/tests/networkxml2xmlupdatetest.c b/tests/networkxml2xmlupdatetest.c
index b4b44ceff3..dfb21c0064 100644
--- a/tests/networkxml2xmlupdatetest.c
+++ b/tests/networkxml2xmlupdatetest.c
@@ -30,7 +30,7 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml,
     if (virTestLoadFile(updatexml, &updateXmlData) < 0)
         goto error;
 
-    if (!(def = virNetworkDefParseFile(netxml)))
+    if (!(def = virNetworkDefParseFile(netxml, 0)))
         goto fail;
 
     if (virNetworkDefUpdateSection(def, command, section, parentIndex,
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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