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(a)redhat.com>
---
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