mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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);
|
def->parent.parent_name = virXPathString("string(./parent/name)", ctxt);
|
||||||
|
|
||||||
if ((domainNode = virXPathNode("./domain", ctxt))) {
|
if ((domainNode = virXPathNode("./domain", ctxt))) {
|
||||||
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
unsigned int domainParseFlags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
unsigned int domainParseFlags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||||
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
|
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
|
||||||
|
|
||||||
def->parent.dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
|
ctxt->node = domainNode;
|
||||||
xmlopt, parseOpaque,
|
|
||||||
|
def->parent.dom = virDomainDefParseNode(ctxt, xmlopt, parseOpaque,
|
||||||
domainParseFlags);
|
domainParseFlags);
|
||||||
if (!def->parent.dom)
|
if (!def->parent.dom)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -19092,7 +19092,7 @@ virDomainDefParse(const char *xmlStr,
|
|||||||
if (!xml)
|
if (!xml)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return virDomainDefParseNode(xml, ctxt->node, xmlopt, parseOpaque, flags);
|
return virDomainDefParseNode(ctxt, xmlopt, parseOpaque, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainDef *
|
virDomainDef *
|
||||||
@ -19115,20 +19115,13 @@ virDomainDefParseFile(const char *filename,
|
|||||||
|
|
||||||
|
|
||||||
virDomainDef *
|
virDomainDef *
|
||||||
virDomainDefParseNode(xmlDocPtr xml,
|
virDomainDefParseNode(xmlXPathContext *ctxt,
|
||||||
xmlNodePtr root,
|
|
||||||
virDomainXMLOption *xmlopt,
|
virDomainXMLOption *xmlopt,
|
||||||
void *parseOpaque,
|
void *parseOpaque,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
|
||||||
g_autoptr(virDomainDef) def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
|
|
||||||
if (!(ctxt = virXMLXPathContextNew(xml)))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ctxt->node = root;
|
|
||||||
|
|
||||||
if (!(def = virDomainDefParseXML(ctxt, xmlopt, flags)))
|
if (!(def = virDomainDefParseXML(ctxt, xmlopt, flags)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -3612,8 +3612,7 @@ virDomainDef *virDomainDefParseFile(const char *filename,
|
|||||||
virDomainXMLOption *xmlopt,
|
virDomainXMLOption *xmlopt,
|
||||||
void *parseOpaque,
|
void *parseOpaque,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
virDomainDef *virDomainDefParseNode(xmlDocPtr doc,
|
virDomainDef *virDomainDefParseNode(xmlXPathContext *ctxt,
|
||||||
xmlNodePtr root,
|
|
||||||
virDomainXMLOption *xmlopt,
|
virDomainXMLOption *xmlopt,
|
||||||
void *parseOpaque,
|
void *parseOpaque,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
@ -266,15 +266,15 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|||||||
* clients will have to decide between best effort
|
* clients will have to decide between best effort
|
||||||
* initialization or outright failure. */
|
* initialization or outright failure. */
|
||||||
if ((domtype = virXPathString("string(./domain/@type)", ctxt))) {
|
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",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("missing domain in snapshot"));
|
_("missing domain in snapshot"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
def->parent.dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
|
|
||||||
xmlopt, parseOpaque,
|
def->parent.dom = virDomainDefParseNode(ctxt, xmlopt, parseOpaque,
|
||||||
domainflags);
|
domainflags);
|
||||||
if (!def->parent.dom)
|
if (!def->parent.dom)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -286,8 +286,12 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|||||||
* VM. In case of absent, leave parent.inactiveDom NULL and use
|
* VM. In case of absent, leave parent.inactiveDom NULL and use
|
||||||
* parent.dom for config and live XML. */
|
* parent.dom for config and live XML. */
|
||||||
if ((inactiveDomNode = virXPathNode("./inactiveDomain", ctxt))) {
|
if ((inactiveDomNode = virXPathNode("./inactiveDomain", ctxt))) {
|
||||||
def->parent.inactiveDom = virDomainDefParseNode(ctxt->node->doc, inactiveDomNode,
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
xmlopt, NULL, domainflags);
|
|
||||||
|
ctxt->node = inactiveDomNode;
|
||||||
|
|
||||||
|
def->parent.inactiveDom = virDomainDefParseNode(ctxt, xmlopt, NULL,
|
||||||
|
domainflags);
|
||||||
if (!def->parent.inactiveDom)
|
if (!def->parent.inactiveDom)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1261,6 @@ static int
|
|||||||
qemuMigrationCookieXMLParse(qemuMigrationCookie *mig,
|
qemuMigrationCookieXMLParse(qemuMigrationCookie *mig,
|
||||||
virQEMUDriver *driver,
|
virQEMUDriver *driver,
|
||||||
virQEMUCaps *qemuCaps,
|
virQEMUCaps *qemuCaps,
|
||||||
xmlDocPtr doc,
|
|
||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
@ -1356,6 +1355,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookie *mig,
|
|||||||
|
|
||||||
if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
|
if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
|
||||||
virXPathBoolean("count(./domain) > 0", ctxt)) {
|
virXPathBoolean("count(./domain) > 0", ctxt)) {
|
||||||
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
g_autofree xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
|
|
||||||
if ((virXPathNodeSet("./domain", ctxt, &nodes)) != 1) {
|
if ((virXPathNodeSet("./domain", ctxt, &nodes)) != 1) {
|
||||||
@ -1363,8 +1363,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookie *mig,
|
|||||||
_("Too many domain elements in migration cookie"));
|
_("Too many domain elements in migration cookie"));
|
||||||
return -1;
|
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_INACTIVE |
|
||||||
VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION |
|
VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION |
|
||||||
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
|
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
|
||||||
@ -1420,7 +1422,7 @@ qemuMigrationCookieXMLParseStr(qemuMigrationCookie *mig,
|
|||||||
if (!(doc = virXMLParseStringCtxt(xml, _("(qemu_migration_cookie)"), &ctxt)))
|
if (!(doc = virXMLParseStringCtxt(xml, _("(qemu_migration_cookie)"), &ctxt)))
|
||||||
return -1;
|
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;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
g_autoptr(virDomainDef) def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
testDomainNamespaceDef *nsdata;
|
testDomainNamespaceDef *nsdata;
|
||||||
xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file);
|
|
||||||
if (!node)
|
if (!(ctxt->node = testParseXMLDocFromFile(nodes[i], file)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
def = virDomainDefParseNode(ctxt->doc, node,
|
def = virDomainDefParseNode(ctxt, privconn->xmlopt, NULL,
|
||||||
privconn->xmlopt, NULL,
|
|
||||||
VIR_DOMAIN_DEF_PARSE_INACTIVE);
|
VIR_DOMAIN_DEF_PARSE_INACTIVE);
|
||||||
if (!def)
|
if (!def)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -709,8 +709,7 @@ testCompareXMLToArgv(const void *data)
|
|||||||
|
|
||||||
parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
|
||||||
|
|
||||||
if (!(vm->def = virDomainDefParseNode(xml, ctxt->node, driver.xmlopt, NULL,
|
if (!(vm->def = virDomainDefParseNode(ctxt, driver.xmlopt, NULL, parseFlags))) {
|
||||||
parseFlags))) {
|
|
||||||
err = virGetLastError();
|
err = virGetLastError();
|
||||||
if (!err) {
|
if (!err) {
|
||||||
VIR_TEST_DEBUG("no error was reported for expected parse error");
|
VIR_TEST_DEBUG("no error was reported for expected parse error");
|
||||||
|
Loading…
Reference in New Issue
Block a user