diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index d7375a5160..c11f40488d 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -972,43 +972,21 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) } -virStoragePoolDef * -virStoragePoolDefParseNode(xmlDocPtr xml, - xmlNodePtr root) -{ - g_autoptr(xmlXPathContext) ctxt = NULL; - - if (!virXMLNodeNameEqual(root, "pool")) { - virReportError(VIR_ERR_XML_ERROR, - _("unexpected root element <%s>, " - "expecting "), - root->name); - return NULL; - } - - if (!(ctxt = virXMLXPathContextNew(xml))) - return NULL; - - ctxt->node = root; - return virStoragePoolDefParseXML(ctxt); -} - - static virStoragePoolDef * virStoragePoolDefParse(const char *xmlStr, const char *filename, unsigned int flags) { - virStoragePoolDef *ret = NULL; g_autoptr(xmlDoc) xml = NULL; + g_autoptr(xmlXPathContext) ctxt = NULL; bool validate = flags & VIR_STORAGE_POOL_DEFINE_VALIDATE; - if ((xml = virXMLParse(filename, xmlStr, _("(storage_pool_definition)"), - NULL, NULL, "storagepool.rng", validate))) { - ret = virStoragePoolDefParseNode(xml, xmlDocGetRootElement(xml)); - } - return ret; + if (!(xml = virXMLParse(filename, xmlStr, _("(storage_pool_definition)"), + "pool", &ctxt, "storagepool.rng", validate))) + return NULL; + + return virStoragePoolDefParseXML(ctxt); } diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index a1bf243935..5eee5b6881 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -278,10 +278,6 @@ virStoragePoolDefParseString(const char *xml, virStoragePoolDef * virStoragePoolDefParseFile(const char *filename); -virStoragePoolDef * -virStoragePoolDefParseNode(xmlDocPtr xml, - xmlNodePtr root); - char * virStoragePoolDefFormat(virStoragePoolDef *def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3ef3210184..ddc2394fb9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1054,7 +1054,6 @@ virStoragePartedFsTypeToString; virStoragePoolDefFormat; virStoragePoolDefFree; virStoragePoolDefParseFile; -virStoragePoolDefParseNode; virStoragePoolDefParseSourceString; virStoragePoolDefParseString; virStoragePoolFormatDiskTypeFromString; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5eae22f591..27cf3ced43 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1145,20 +1145,15 @@ testParseInterfaces(testDriver *privconn, static int testOpenVolumesForPool(const char *file, xmlXPathContextPtr ctxt, - virStoragePoolObj *obj, - int objidx) + virStoragePoolObj *obj) { virStoragePoolDef *def = virStoragePoolObjGetDef(obj); size_t i; int num; - g_autofree char *vol_xpath = NULL; g_autofree xmlNodePtr *nodes = NULL; g_autoptr(virStorageVolDef) volDef = NULL; - /* Find storage volumes */ - vol_xpath = g_strdup_printf("/node/pool[%d]/volume", objidx); - - num = virXPathNodeSet(vol_xpath, ctxt, &nodes); + num = virXPathNodeSet("/pool/volume", ctxt, &nodes); if (num < 0) return -1; @@ -1195,6 +1190,7 @@ testParseStorage(testDriver *privconn, const char *file, xmlXPathContextPtr ctxt) { + VIR_XPATH_NODE_AUTORESTORE(ctxt) int num; size_t i; virStoragePoolObj *obj; @@ -1206,12 +1202,11 @@ testParseStorage(testDriver *privconn, for (i = 0; i < num; i++) { virStoragePoolDef *def; - xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file); - if (!node) + + if (!(ctxt->node = testParseXMLDocFromFile(nodes[i], file))) return -1; - def = virStoragePoolDefParseNode(ctxt->doc, node); - if (!def) + if (!(def = virStoragePoolDefParseXML(ctxt))) return -1; if (!(obj = virStoragePoolObjListAdd(privconn->pools, &def, 0))) { @@ -1226,7 +1221,7 @@ testParseStorage(testDriver *privconn, virStoragePoolObjSetActive(obj, true); /* Find storage volumes */ - if (testOpenVolumesForPool(file, ctxt, obj, i+1) < 0) { + if (testOpenVolumesForPool(file, ctxt, obj) < 0) { virStoragePoolObjEndAPI(&obj); return -1; }