mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
conf: snapshot: Remove virDomainSnapshotDefParseNode
Check the root XML node name and fetch XPath context by properly configuring virXMLParse. Callers can use virDomainSnapshotDefParse instead. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2a166e6c12
commit
7782bc39fe
@ -197,7 +197,7 @@ virDomainSnapshotDiskDefParseXML(xmlNodePtr node,
|
||||
* If flags does not include
|
||||
* VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL, then current is ignored.
|
||||
*/
|
||||
static virDomainSnapshotDef *
|
||||
virDomainSnapshotDef *
|
||||
virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
virDomainXMLOption *xmlopt,
|
||||
void *parseOpaque,
|
||||
@ -389,27 +389,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
return g_steal_pointer(&def);
|
||||
}
|
||||
|
||||
virDomainSnapshotDef *
|
||||
virDomainSnapshotDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
virDomainXMLOption *xmlopt,
|
||||
void *parseOpaque,
|
||||
bool *current,
|
||||
unsigned int flags)
|
||||
{
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
|
||||
if (!virXMLNodeNameEqual(root, "domainsnapshot")) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s", _("domainsnapshot"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ctxt = virXMLXPathContextNew(xml)))
|
||||
return NULL;
|
||||
|
||||
ctxt->node = root;
|
||||
return virDomainSnapshotDefParse(ctxt, xmlopt, parseOpaque, current, flags);
|
||||
}
|
||||
|
||||
virDomainSnapshotDef *
|
||||
virDomainSnapshotDefParseString(const char *xmlStr,
|
||||
@ -418,21 +397,20 @@ virDomainSnapshotDefParseString(const char *xmlStr,
|
||||
bool *current,
|
||||
unsigned int flags)
|
||||
{
|
||||
virDomainSnapshotDef *ret = NULL;
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
g_autoptr(xmlDoc) xml = NULL;
|
||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||
bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
|
||||
|
||||
if ((xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
|
||||
NULL, NULL, "domainsnapshot.rng", validate))) {
|
||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
ret = virDomainSnapshotDefParseNode(xml, xmlDocGetRootElement(xml),
|
||||
xmlopt, parseOpaque,
|
||||
current, flags);
|
||||
}
|
||||
xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
|
||||
"domainsnapshot", &ctxt, "domainsnapshot.rng", validate);
|
||||
|
||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
||||
|
||||
return ret;
|
||||
if (!xml)
|
||||
return NULL;
|
||||
|
||||
return virDomainSnapshotDefParse(ctxt, xmlopt, parseOpaque, current, flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,12 +102,13 @@ virDomainSnapshotDef *virDomainSnapshotDefParseString(const char *xmlStr,
|
||||
void *parseOpaque,
|
||||
bool *current,
|
||||
unsigned int flags);
|
||||
virDomainSnapshotDef *virDomainSnapshotDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
virDomainSnapshotDef *
|
||||
virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
virDomainXMLOption *xmlopt,
|
||||
void *parseOpaque,
|
||||
bool *current,
|
||||
unsigned int flags);
|
||||
|
||||
virDomainSnapshotDef *virDomainSnapshotDefNew(void);
|
||||
char *virDomainSnapshotDefFormat(const char *uuidstr,
|
||||
virDomainSnapshotDef *def,
|
||||
|
@ -961,25 +961,23 @@ testParseDomainSnapshots(testDriver *privconn,
|
||||
const char *file,
|
||||
xmlXPathContextPtr ctxt)
|
||||
{
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
size_t i;
|
||||
testDomainNamespaceDef *nsdata = domobj->def->namespaceData;
|
||||
xmlNodePtr *nodes = nsdata->snap_nodes;
|
||||
bool cur;
|
||||
|
||||
for (i = 0; i < nsdata->num_snap_nodes; i++) {
|
||||
virDomainMomentObj *snap;
|
||||
g_autoptr(virDomainSnapshotDef) def = NULL;
|
||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file);
|
||||
if (!node)
|
||||
unsigned int parseFlags = VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL |
|
||||
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
|
||||
bool cur;
|
||||
|
||||
if (!(ctxt->node = testParseXMLDocFromFile(nodes[i], file)))
|
||||
return -1;
|
||||
|
||||
def = virDomainSnapshotDefParseNode(ctxt->doc, node,
|
||||
privconn->xmlopt,
|
||||
NULL,
|
||||
&cur,
|
||||
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL |
|
||||
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE);
|
||||
if (!def)
|
||||
if (!(def = virDomainSnapshotDefParse(ctxt, privconn->xmlopt, NULL,
|
||||
&cur, parseFlags)))
|
||||
return -1;
|
||||
|
||||
if (!(snap = virDomainSnapshotAssignDef(domobj->snapshots, &def)))
|
||||
|
Loading…
Reference in New Issue
Block a user