[PATCH 2/4] conf: virnwfilterbindingdef: add validation against schema in create

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

 



We need to validate the XML against schema if option '--validate'
was passed to the virsh command. This patch also includes
propagation of flags into the virNWFilterBindingDefParse().

Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 src/conf/virnwfilterbindingdef.c | 14 +++++++++-----
 src/conf/virnwfilterbindingdef.h |  3 ++-
 src/nwfilter/nwfilter_driver.c   |  2 +-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbindingdef.c
index 5f671030bb..488fdbceab 100644
--- a/src/conf/virnwfilterbindingdef.c
+++ b/src/conf/virnwfilterbindingdef.c
@@ -178,12 +178,15 @@ virNWFilterBindingDefParseNode(xmlDocPtr xml,
 
 static virNWFilterBindingDef *
 virNWFilterBindingDefParse(const char *xmlStr,
-                           const char *filename)
+                           const char *filename,
+                           unsigned int flags)
 {
     virNWFilterBindingDef *def = NULL;
     g_autoptr(xmlDoc) xml = NULL;
 
-    if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_definition)"), NULL, false))) {
+    if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_definition)"),
+                           "nwfilterbinding.rng",
+                           flags & VIR_NWFILTER_BINDING_CREATE_VALIDATE))) {
         def = virNWFilterBindingDefParseNode(xml, xmlDocGetRootElement(xml));
     }
 
@@ -192,16 +195,17 @@ virNWFilterBindingDefParse(const char *xmlStr,
 
 
 virNWFilterBindingDef *
-virNWFilterBindingDefParseString(const char *xmlStr)
+virNWFilterBindingDefParseString(const char *xmlStr,
+                                 unsigned int flags)
 {
-    return virNWFilterBindingDefParse(xmlStr, NULL);
+    return virNWFilterBindingDefParse(xmlStr, NULL, flags);
 }
 
 
 virNWFilterBindingDef *
 virNWFilterBindingDefParseFile(const char *filename)
 {
-    return virNWFilterBindingDefParse(NULL, filename);
+    return virNWFilterBindingDefParse(NULL, filename, 0);
 }
 
 
diff --git a/src/conf/virnwfilterbindingdef.h b/src/conf/virnwfilterbindingdef.h
index 68d531b75d..4bf0f252f8 100644
--- a/src/conf/virnwfilterbindingdef.h
+++ b/src/conf/virnwfilterbindingdef.h
@@ -51,7 +51,8 @@ virNWFilterBindingDefParseNode(xmlDocPtr xml,
                                xmlNodePtr root);
 
 virNWFilterBindingDef *
-virNWFilterBindingDefParseString(const char *xml);
+virNWFilterBindingDefParseString(const char *xml,
+                                 unsigned int flags);
 
 virNWFilterBindingDef *
 virNWFilterBindingDefParseFile(const char *filename);
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 2712baa73f..1d4567855e 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -745,7 +745,7 @@ nwfilterBindingCreateXML(virConnectPtr conn,
         return NULL;
     }
 
-    def = virNWFilterBindingDefParseString(xml);
+    def = virNWFilterBindingDefParseString(xml, 0);
     if (!def)
         return NULL;
 
-- 
2.31.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