mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
virDomainDefParseNode: Pass only the XPath context as argument
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5a1c20c3e5
commit
402c31f3ac
@ -153,11 +153,13 @@ virDomainCheckpointDefParse(xmlXPathContextPtr ctxt,
|
||||
def->parent.parent_name = virXPathString("string(./parent/name)", ctxt);
|
||||
|
||||
if ((domainNode = virXPathNode("./domain", ctxt))) {
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
unsigned int domainParseFlags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
|
||||
|
||||
def->parent.dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
|
||||
xmlopt, parseOpaque,
|
||||
ctxt->node = domainNode;
|
||||
|
||||
def->parent.dom = virDomainDefParseNode(ctxt, xmlopt, parseOpaque,
|
||||
domainParseFlags);
|
||||
if (!def->parent.dom)
|
||||
return NULL;
|
||||
|
@ -19092,7 +19092,7 @@ virDomainDefParse(const char *xmlStr,
|
||||
if (!xml)
|
||||
return NULL;
|
||||
|
||||
return virDomainDefParseNode(xml, ctxt->node, xmlopt, parseOpaque, flags);
|
||||
return virDomainDefParseNode(ctxt, xmlopt, parseOpaque, flags);
|
||||
}
|
||||
|
||||
virDomainDef *
|
||||
@ -19115,20 +19115,13 @@ virDomainDefParseFile(const char *filename,
|
||||
|
||||
|
||||
virDomainDef *
|
||||
virDomainDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root,
|
||||
virDomainDefParseNode(xmlXPathContext *ctxt,
|
||||
virDomainXMLOption *xmlopt,
|
||||
void *parseOpaque,
|
||||
unsigned int flags)
|
||||
{
|
||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||
g_autoptr(virDomainDef) def = NULL;
|
||||
|
||||
if (!(ctxt = virXMLXPathContextNew(xml)))
|
||||
return NULL;
|
||||
|
||||
ctxt->node = root;
|
||||
|
||||
if (!(def = virDomainDefParseXML(ctxt, xmlopt, flags)))
|
||||
return NULL;
|
||||
|
||||
|
@ -3612,8 +3612,7 @@ virDomainDef *virDomainDefParseFile(const char *filename,
|
||||
virDomainXMLOption *xmlopt,
|
||||
void *parseOpaque,
|
||||
unsigned int flags);
|
||||
virDomainDef *virDomainDefParseNode(xmlDocPtr doc,
|
||||
xmlNodePtr root,
|
||||
virDomainDef *virDomainDefParseNode(xmlXPathContext *ctxt,
|
||||
virDomainXMLOption *xmlopt,
|
||||
void *parseOpaque,
|
||||
unsigned int flags);
|
||||
|
@ -266,15 +266,15 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
* clients will have to decide between best effort
|
||||
* initialization or outright failure. */
|
||||
if ((domtype = virXPathString("string(./domain/@type)", ctxt))) {
|
||||
xmlNodePtr domainNode = virXPathNode("./domain", ctxt);
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
|
||||
if (!domainNode) {
|
||||
if (!(ctxt->node = virXPathNode("./domain", ctxt))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("missing domain in snapshot"));
|
||||
return NULL;
|
||||
}
|
||||
def->parent.dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
|
||||
xmlopt, parseOpaque,
|
||||
|
||||
def->parent.dom = virDomainDefParseNode(ctxt, xmlopt, parseOpaque,
|
||||
domainflags);
|
||||
if (!def->parent.dom)
|
||||
return NULL;
|
||||
@ -286,8 +286,12 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
||||
* VM. In case of absent, leave parent.inactiveDom NULL and use
|
||||
* parent.dom for config and live XML. */
|
||||
if ((inactiveDomNode = virXPathNode("./inactiveDomain", ctxt))) {
|
||||
def->parent.inactiveDom = virDomainDefParseNode(ctxt->node->doc, inactiveDomNode,
|
||||
xmlopt, NULL, domainflags);
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
|
||||
ctxt->node = inactiveDomNode;
|
||||
|
||||
def->parent.inactiveDom = virDomainDefParseNode(ctxt, xmlopt, NULL,
|
||||
domainflags);
|
||||
if (!def->parent.inactiveDom)
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1261,7 +1261,6 @@ static int
|
||||
qemuMigrationCookieXMLParse(qemuMigrationCookie *mig,
|
||||
virQEMUDriver *driver,
|
||||
virQEMUCaps *qemuCaps,
|
||||
xmlDocPtr doc,
|
||||
xmlXPathContextPtr ctxt,
|
||||
unsigned int flags)
|
||||
{
|
||||
@ -1356,6 +1355,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookie *mig,
|
||||
|
||||
if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
|
||||
virXPathBoolean("count(./domain) > 0", ctxt)) {
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
|
||||
if ((virXPathNodeSet("./domain", ctxt, &nodes)) != 1) {
|
||||
@ -1363,8 +1363,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookie *mig,
|
||||
_("Too many domain elements in migration cookie"));
|
||||
return -1;
|
||||
}
|
||||
mig->persistent = virDomainDefParseNode(doc, nodes[0],
|
||||
driver->xmlopt, qemuCaps,
|
||||
|
||||
ctxt->node = nodes[0];
|
||||
|
||||
mig->persistent = virDomainDefParseNode(ctxt, driver->xmlopt, qemuCaps,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||
VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION |
|
||||
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
|
||||
@ -1420,7 +1422,7 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie *mig,
|
||||
if (!(doc = virXMLParseStringCtxt(xml, _("(qemu_migration_cookie)"), &ctxt)))
|
||||
return -1;
|
||||
|
||||
return qemuMigrationCookieXMLParse(mig, driver, qemuCaps, doc, ctxt, flags);
|
||||
return qemuMigrationCookieXMLParse(mig, driver, qemuCaps, ctxt, flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1019,14 +1019,14 @@ testParseDomains(testDriver *privconn,
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
g_autoptr(virDomainDef) def = NULL;
|
||||
testDomainNamespaceDef *nsdata;
|
||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file);
|
||||
if (!node)
|
||||
|
||||
if (!(ctxt->node = testParseXMLDocFromFile(nodes[i], file)))
|
||||
goto error;
|
||||
|
||||
def = virDomainDefParseNode(ctxt->doc, node,
|
||||
privconn->xmlopt, NULL,
|
||||
def = virDomainDefParseNode(ctxt, privconn->xmlopt, NULL,
|
||||
VIR_DOMAIN_DEF_PARSE_INACTIVE);
|
||||
if (!def)
|
||||
goto error;
|
||||
|
@ -709,8 +709,7 @@ testCompareXMLToArgv(const void *data)
|
||||
|
||||
parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||
|
||||
if (!(vm->def = virDomainDefParseNode(xml, ctxt->node, driver.xmlopt, NULL,
|
||||
parseFlags))) {
|
||||
if (!(vm->def = virDomainDefParseNode(ctxt, driver.xmlopt, NULL, parseFlags))) {
|
||||
err = virGetLastError();
|
||||
if (!err) {
|
||||
VIR_TEST_DEBUG("no error was reported for expected parse error");
|
||||
|
Loading…
x
Reference in New Issue
Block a user