mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35: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
|
* If flags does not include
|
||||||
* VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL, then current is ignored.
|
* VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL, then current is ignored.
|
||||||
*/
|
*/
|
||||||
static virDomainSnapshotDef *
|
virDomainSnapshotDef *
|
||||||
virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||||
virDomainXMLOption *xmlopt,
|
virDomainXMLOption *xmlopt,
|
||||||
void *parseOpaque,
|
void *parseOpaque,
|
||||||
@ -389,27 +389,6 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|||||||
return g_steal_pointer(&def);
|
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 *
|
virDomainSnapshotDef *
|
||||||
virDomainSnapshotDefParseString(const char *xmlStr,
|
virDomainSnapshotDefParseString(const char *xmlStr,
|
||||||
@ -418,21 +397,20 @@ virDomainSnapshotDefParseString(const char *xmlStr,
|
|||||||
bool *current,
|
bool *current,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virDomainSnapshotDef *ret = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
||||||
bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
|
bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
|
||||||
|
|
||||||
if ((xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
|
xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
|
||||||
NULL, NULL, "domainsnapshot.rng", validate))) {
|
"domainsnapshot", &ctxt, "domainsnapshot.rng", validate);
|
||||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
||||||
ret = virDomainSnapshotDefParseNode(xml, xmlDocGetRootElement(xml),
|
|
||||||
xmlopt, parseOpaque,
|
|
||||||
current, flags);
|
|
||||||
}
|
|
||||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
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,
|
void *parseOpaque,
|
||||||
bool *current,
|
bool *current,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
virDomainSnapshotDef *virDomainSnapshotDefParseNode(xmlDocPtr xml,
|
virDomainSnapshotDef *
|
||||||
xmlNodePtr root,
|
virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||||
virDomainXMLOption *xmlopt,
|
virDomainXMLOption *xmlopt,
|
||||||
void *parseOpaque,
|
void *parseOpaque,
|
||||||
bool *current,
|
bool *current,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
virDomainSnapshotDef *virDomainSnapshotDefNew(void);
|
virDomainSnapshotDef *virDomainSnapshotDefNew(void);
|
||||||
char *virDomainSnapshotDefFormat(const char *uuidstr,
|
char *virDomainSnapshotDefFormat(const char *uuidstr,
|
||||||
virDomainSnapshotDef *def,
|
virDomainSnapshotDef *def,
|
||||||
|
@ -961,25 +961,23 @@ testParseDomainSnapshots(testDriver *privconn,
|
|||||||
const char *file,
|
const char *file,
|
||||||
xmlXPathContextPtr ctxt)
|
xmlXPathContextPtr ctxt)
|
||||||
{
|
{
|
||||||
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
size_t i;
|
size_t i;
|
||||||
testDomainNamespaceDef *nsdata = domobj->def->namespaceData;
|
testDomainNamespaceDef *nsdata = domobj->def->namespaceData;
|
||||||
xmlNodePtr *nodes = nsdata->snap_nodes;
|
xmlNodePtr *nodes = nsdata->snap_nodes;
|
||||||
bool cur;
|
|
||||||
|
|
||||||
for (i = 0; i < nsdata->num_snap_nodes; i++) {
|
for (i = 0; i < nsdata->num_snap_nodes; i++) {
|
||||||
virDomainMomentObj *snap;
|
virDomainMomentObj *snap;
|
||||||
g_autoptr(virDomainSnapshotDef) def = NULL;
|
g_autoptr(virDomainSnapshotDef) def = NULL;
|
||||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file);
|
unsigned int parseFlags = VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL |
|
||||||
if (!node)
|
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE;
|
||||||
|
bool cur;
|
||||||
|
|
||||||
|
if (!(ctxt->node = testParseXMLDocFromFile(nodes[i], file)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
def = virDomainSnapshotDefParseNode(ctxt->doc, node,
|
if (!(def = virDomainSnapshotDefParse(ctxt, privconn->xmlopt, NULL,
|
||||||
privconn->xmlopt,
|
&cur, parseFlags)))
|
||||||
NULL,
|
|
||||||
&cur,
|
|
||||||
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL |
|
|
||||||
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE);
|
|
||||||
if (!def)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(snap = virDomainSnapshotAssignDef(domobj->snapshots, &def)))
|
if (!(snap = virDomainSnapshotAssignDef(domobj->snapshots, &def)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user