conf: storage: Remove virStorageVolDefParseNode

Proper use of virXMLParse replaces everything the function provides.
Callers can use virStorageVolDefParseXML instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-09-22 17:17:21 +02:00
parent 97df89d7f5
commit 3c56186031
4 changed files with 13 additions and 39 deletions

View File

@ -1234,7 +1234,7 @@ virStorageCheckCompat(const char *compat)
}
static virStorageVolDef *
virStorageVolDef *
virStorageVolDefParseXML(virStoragePoolDef *pool,
xmlXPathContextPtr ctxt,
unsigned int flags)
@ -1401,45 +1401,20 @@ virStorageVolDefParseXML(virStoragePoolDef *pool,
}
virStorageVolDef *
virStorageVolDefParseNode(virStoragePoolDef *pool,
xmlDocPtr xml,
xmlNodePtr root,
unsigned int flags)
{
g_autoptr(xmlXPathContext) ctxt = NULL;
if (!virXMLNodeNameEqual(root, "volume")) {
virReportError(VIR_ERR_XML_ERROR,
_("unexpected root element <%s>, "
"expecting <volume>"),
root->name);
return NULL;
}
if (!(ctxt = virXMLXPathContextNew(xml)))
return NULL;
ctxt->node = root;
return virStorageVolDefParseXML(pool, ctxt, flags);
}
static virStorageVolDef *
virStorageVolDefParse(virStoragePoolDef *pool,
const char *xmlStr,
const char *filename,
unsigned int flags)
{
virStorageVolDef *ret = NULL;
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(storage_volume_definition)"),
NULL, NULL, NULL, false))) {
ret = virStorageVolDefParseNode(pool, xml, xmlDocGetRootElement(xml), flags);
}
if (!(xml = virXMLParse(filename, xmlStr, _("(storage_volume_definition)"),
"volume", &ctxt, NULL, false)))
return NULL;
return ret;
return virStorageVolDefParseXML(pool, ctxt, flags);
}

View File

@ -297,10 +297,9 @@ virStorageVolDefParseFile(virStoragePoolDef *pool,
unsigned int flags);
virStorageVolDef *
virStorageVolDefParseNode(virStoragePoolDef *pool,
xmlDocPtr xml,
xmlNodePtr root,
unsigned int flags);
virStorageVolDefParseXML(virStoragePoolDef *pool,
xmlXPathContextPtr ctxt,
unsigned int flags);
char *
virStorageVolDefFormat(virStoragePoolDef *pool,

View File

@ -1079,8 +1079,8 @@ virStorageVolDefFindByPath;
virStorageVolDefFormat;
virStorageVolDefFree;
virStorageVolDefParseFile;
virStorageVolDefParseNode;
virStorageVolDefParseString;
virStorageVolDefParseXML;
virStorageVolDefRefreshAllocationTypeFromString;
virStorageVolDefRefreshAllocationTypeToString;
virStorageVolTypeFromString;

View File

@ -1147,6 +1147,7 @@ testOpenVolumesForPool(const char *file,
xmlXPathContextPtr ctxt,
virStoragePoolObj *obj)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
virStoragePoolDef *def = virStoragePoolObjGetDef(obj);
size_t i;
int num;
@ -1158,11 +1159,10 @@ testOpenVolumesForPool(const char *file,
return -1;
for (i = 0; i < num; i++) {
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file);
if (!node)
if (!(ctxt->node = testParseXMLDocFromFile(nodes[i], file)))
return -1;
if (!(volDef = virStorageVolDefParseNode(def, ctxt->doc, node, 0)))
if (!(volDef = virStorageVolDefParseXML(def, ctxt, 0)))
return -1;
if (!volDef->target.path) {