[libvirt PATCH 2/2] virCPUDefParseXML: Log schema validation errors

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

 



Schema validation was only performed if the "validateXML" flag was set.
Make invalid XML visible in the logs by always validating, but only treat
validation errors as errors if said flag is set.

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/conf/cpu_conf.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index c095ab0e89..c584b0f360 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -329,6 +329,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
     VIR_XPATH_NODE_AUTORESTORE(ctxt)
     int n;
     size_t i;
+    g_autofree char *schemafile = NULL;
     g_autofree char *cpuMode = NULL;
     g_autofree char *fallback = NULL;
     g_autofree char *vendor_id = NULL;
@@ -347,16 +348,13 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt,
         return -1;
     }
 
-    if (validateXML) {
-        g_autofree char *schemafile = NULL;
-
-        if (!(schemafile = virFileFindResource("cpu.rng",
-                                               abs_top_srcdir "/docs/schemas",
-                                               PKGDATADIR "/schemas")))
-            return -1;
+    if (!(schemafile = virFileFindResource("cpu.rng",
+                                           abs_top_srcdir "/docs/schemas",
+                                           PKGDATADIR "/schemas")))
+        return -1;
 
-        if (virXMLValidateNodeAgainstSchema(schemafile, ctxt->doc,
-                                            ctxt->node) < 0)
+    if (virXMLValidateNodeAgainstSchema(schemafile, ctxt->node) < 0) {
+        if (validateXML)
             return -1;
     }
 
-- 
2.26.2




[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