Both callers be easily made to call virNodeDeviceDefParseXML directly. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/conf/node_device_conf.c | 34 ++++++---------------------------- src/conf/node_device_conf.h | 7 +++---- src/libvirt_private.syms | 2 +- src/test/test_driver.c | 7 +++---- 4 files changed, 13 insertions(+), 37 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 1db9a3240a..7e50904828 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2370,7 +2370,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, } -static virNodeDeviceDef * +virNodeDeviceDef * virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, int create, const char *virt_type) @@ -2473,30 +2473,6 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, } -virNodeDeviceDef * -virNodeDeviceDefParseNode(xmlDocPtr xml, - xmlNodePtr root, - int create, - const char *virt_type) -{ - g_autoptr(xmlXPathContext) ctxt = NULL; - - if (!virXMLNodeNameEqual(root, "device")) { - virReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s> " - "expecting <device>"), - root->name); - return NULL; - } - - if (!(ctxt = virXMLXPathContextNew(xml))) - return NULL; - - ctxt->node = root; - return virNodeDeviceDefParseXML(ctxt, create, virt_type); -} - - static virNodeDeviceDef * virNodeDeviceDefParse(const char *str, const char *filename, @@ -2506,12 +2482,14 @@ virNodeDeviceDefParse(const char *str, void *opaque) { g_autoptr(xmlDoc) xml = NULL; + g_autoptr(xmlXPathContext) ctxt = NULL; g_autoptr(virNodeDeviceDef) def = NULL; if (!(xml = virXMLParse(filename, str, _("(node_device_definition)"), - NULL, NULL, NULL, false)) || - !(def = virNodeDeviceDefParseNode(xml, xmlDocGetRootElement(xml), - create, virt_type))) + "device", &ctxt, NULL, false))) + return NULL; + + if (!(def = virNodeDeviceDefParseXML(ctxt, create, virt_type))) return NULL; if (parserCallbacks) { diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index 21622c62ac..feef22910d 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -391,10 +391,9 @@ virNodeDeviceDefParseFile(const char *filename, void *opaque); virNodeDeviceDef * -virNodeDeviceDefParseNode(xmlDocPtr xml, - xmlNodePtr root, - int create, - const char *virt_type); +virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, + int create, + const char *virt_type); int virNodeDeviceGetWWNs(virNodeDeviceDef *def, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6836c99fff..ffab2b7c43 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -866,8 +866,8 @@ virNodeDeviceCapsListExport; virNodeDeviceDefFormat; virNodeDeviceDefFree; virNodeDeviceDefParseFile; -virNodeDeviceDefParseNode; virNodeDeviceDefParseString; +virNodeDeviceDefParseXML; virNodeDeviceGetAPMatrixDynamicCaps; virNodeDeviceGetCSSDynamicCaps; virNodeDeviceGetMdevParentDynamicCaps; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 50c8a7e2be..7c7ef1b924 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1236,6 +1236,7 @@ testParseNodedevs(testDriver *privconn, const char *file, xmlXPathContextPtr ctxt) { + VIR_XPATH_NODE_AUTORESTORE(ctxt) int num; size_t i; virNodeDeviceObj *obj; @@ -1247,13 +1248,11 @@ testParseNodedevs(testDriver *privconn, for (i = 0; i < num; i++) { virNodeDeviceDef *def; - xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file); - if (!node) + if (!(ctxt->node = testParseXMLDocFromFile(nodes[i], file))) return -1; - def = virNodeDeviceDefParseNode(ctxt->doc, node, 0, NULL); - if (!def) + if (!(def = virNodeDeviceDefParseXML(ctxt, 0, NULL))) return -1; if (!(obj = virNodeDeviceObjListAssignDef(privconn->devs, def))) { -- 2.37.3