From aa99ea747e3db142c7990412c80265dac4b7cfec Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Mon, 14 Aug 2017 14:31:52 +0200 Subject: [PATCH] conf: use virXMLPropString for KeyWrapCipherDef parsing XPath is good for random search of elements, not for accessing attributes of one node. Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 528d11c17d..9dc788e9f9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -933,7 +933,6 @@ virDomainXMLOptionClassDispose(void *obj) * * @def Domain definition * @node An XML cipher node - * @ctxt The XML context * * Parse the attributes from the cipher node and store the state * attribute in @def. @@ -947,8 +946,7 @@ virDomainXMLOptionClassDispose(void *obj) */ static int virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap, - xmlNodePtr node, - xmlXPathContextPtr ctxt) + xmlNodePtr node) { char *name = NULL; @@ -956,10 +954,8 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap, int state_type; int name_type; int ret = -1; - xmlNodePtr oldnode = ctxt->node; - ctxt->node = node; - if (!(name = virXPathString("string(./@name)", ctxt))) { + if (!(name = virXMLPropString(node, "name"))) { virReportError(VIR_ERR_CONF_SYNTAX, "%s", _("missing name for cipher")); goto cleanup; @@ -971,7 +967,7 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap, goto cleanup; } - if (!(state = virXPathString("string(./@state)", ctxt))) { + if (!(state = virXMLPropString(node, "state"))) { virReportError(VIR_ERR_CONF_SYNTAX, _("missing state for cipher named %s"), name); goto cleanup; @@ -1017,7 +1013,6 @@ virDomainKeyWrapCipherDefParseXML(virDomainKeyWrapDefPtr keywrap, cleanup: VIR_FREE(name); VIR_FREE(state); - ctxt->node = oldnode; return ret; } @@ -1036,7 +1031,7 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlXPathContextPtr ctxt) goto cleanup; for (i = 0; i < n; i++) { - if (virDomainKeyWrapCipherDefParseXML(def->keywrap, nodes[i], ctxt) < 0) + if (virDomainKeyWrapCipherDefParseXML(def->keywrap, nodes[i]) < 0) goto cleanup; }