mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
conf: node_device: Add 'validate' argument to virNodeDeviceDefParse
Allow callers to request XML validation against the schema. All callers for now pass 'false'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
abfdaf8a94
commit
0268270b0f
@ -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)))
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -888,7 +888,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)
|
||||
@ -1409,7 +1409,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)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user