Allow callers to request XML validation against the schema. All callers
for now pass 'false'.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/node_device_conf.c | 5 +++--
src/conf/node_device_conf.h | 3 ++-
src/hypervisor/domain_driver.c | 6 +++---
src/node_device/node_device_driver.c | 4 ++--
src/test/test_driver.c | 4 ++--
tests/nodedevmdevctltest.c | 4 ++--
tests/nodedevxml2xmltest.c | 3 ++-
7 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index bdfbbab434..f5283a77b3 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -2479,14 +2479,15 @@ virNodeDeviceDefParse(const char *str,
int create,
const char *virt_type,
virNodeDeviceDefParserCallbacks *parserCallbacks,
- void *opaque)
+ void *opaque,
+ bool validate)
{
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
g_autoptr(virNodeDeviceDef) def = NULL;
if (!(xml = virXMLParse(filename, str, _("(node_device_definition)"),
- "device", &ctxt, NULL, false)))
+ "device", &ctxt, "nodedev.rng",
validate)))
return NULL;
if (!(def = virNodeDeviceDefParseXML(ctxt, create, virt_type)))
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index a556358632..2b2c8f797e 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -382,7 +382,8 @@ virNodeDeviceDefParse(const char *str,
int create,
const char *virt_type,
virNodeDeviceDefParserCallbacks *parserCallbacks,
- void *opaque);
+ void *opaque,
+ bool validate);
virNodeDeviceDef *
virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c
index c154f00eea..d020b94921 100644
--- a/src/hypervisor/domain_driver.c
+++ b/src/hypervisor/domain_driver.c
@@ -395,7 +395,7 @@ virDomainDriverNodeDeviceReset(virNodeDevicePtr dev,
if (!xml)
return -1;
- def = virNodeDeviceDefParse(xml, NULL, EXISTING_DEVICE, NULL, NULL, NULL);
+ def = virNodeDeviceDefParse(xml, NULL, EXISTING_DEVICE, NULL, NULL, NULL, false);
if (!def)
return -1;
@@ -440,7 +440,7 @@ virDomainDriverNodeDeviceReAttach(virNodeDevicePtr dev,
if (!xml)
return -1;
- def = virNodeDeviceDefParse(xml, NULL, EXISTING_DEVICE, NULL, NULL, NULL);
+ def = virNodeDeviceDefParse(xml, NULL, EXISTING_DEVICE, NULL, NULL, NULL, false);
if (!def)
return -1;
@@ -488,7 +488,7 @@ virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr dev,
if (!xml)
return -1;
- def = virNodeDeviceDefParse(xml, NULL, EXISTING_DEVICE, NULL, NULL, NULL);
+ def = virNodeDeviceDefParse(xml, NULL, EXISTING_DEVICE, NULL, NULL, NULL, false);
if (!def)
return -1;
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 8e93b0dd6f..d067234ab3 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -885,7 +885,7 @@ nodeDeviceCreateXML(virConnectPtr conn,
virt_type = virConnectGetType(conn);
if (!(def = virNodeDeviceDefParse(xmlDesc, NULL, CREATE_DEVICE, virt_type,
- &driver->parserCallbacks, NULL)))
+ &driver->parserCallbacks, NULL, false)))
return NULL;
if (virNodeDeviceCreateXMLEnsureACL(conn, def) < 0)
@@ -1406,7 +1406,7 @@ nodeDeviceDefineXML(virConnect *conn,
virt_type = virConnectGetType(conn);
if (!(def = virNodeDeviceDefParse(xmlDesc, NULL, CREATE_DEVICE, virt_type,
- &driver->parserCallbacks, NULL)))
+ &driver->parserCallbacks, NULL, false)))
return NULL;
if (virNodeDeviceDefineXMLEnsureACL(conn, def) < 0)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 67c70de11d..9b397e66b1 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -7629,7 +7629,7 @@ testNodeDeviceMockCreateVport(testDriver *driver,
if (!xml)
goto cleanup;
- if (!(def = virNodeDeviceDefParse(xml, NULL, EXISTING_DEVICE, NULL, NULL, NULL)))
+ if (!(def = virNodeDeviceDefParse(xml, NULL, EXISTING_DEVICE, NULL, NULL, NULL,
false)))
goto cleanup;
VIR_FREE(def->name);
@@ -7691,7 +7691,7 @@ testNodeDeviceCreateXML(virConnectPtr conn,
virCheckFlags(0, NULL);
- if (!(def = virNodeDeviceDefParse(xmlDesc, NULL, CREATE_DEVICE, NULL, NULL, NULL)))
+ if (!(def = virNodeDeviceDefParse(xmlDesc, NULL, CREATE_DEVICE, NULL, NULL, NULL,
false)))
goto cleanup;
/* We run this simply for validation - it essentially validates that
diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c
index 02e85d4779..4dc524b5a5 100644
--- a/tests/nodedevmdevctltest.c
+++ b/tests/nodedevmdevctltest.c
@@ -71,7 +71,7 @@ testMdevctlCmd(virMdevctlCommand cmd_type,
}
if (!(def = virNodeDeviceDefParse(NULL, mdevxml, create, VIRT_TYPE,
- &parser_callbacks, NULL)))
+ &parser_callbacks, NULL, false)))
return -1;
/* this function will set a stdin buffer containing the json configuration
@@ -143,7 +143,7 @@ testMdevctlAutostart(const void *data G_GNUC_UNUSED)
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
if (!(def = virNodeDeviceDefParse(NULL, mdevxml, CREATE_DEVICE, VIRT_TYPE,
- &parser_callbacks, NULL)))
+ &parser_callbacks, NULL, false)))
return -1;
virCommandSetDryRun(dryRunToken, &buf, true, true, NULL, NULL);
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index d1c0652e7d..068ec68769 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -23,7 +23,8 @@ testCompareXMLToXMLFiles(const char *xml, const char *outfile)
if (virTestLoadFile(xml, &xmlData) < 0)
goto fail;
- if (!(dev = virNodeDeviceDefParse(xmlData, NULL, EXISTING_DEVICE, NULL, NULL,
NULL)))
+ if (!(dev = virNodeDeviceDefParse(xmlData, NULL, EXISTING_DEVICE, NULL,
+ NULL, NULL, false)))
goto fail;
/* Calculate some things that are not read in */
--
2.37.3