]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: use virXMLPropString for KeyWrapCipherDef parsing
authorPavel Hrdina <phrdina@redhat.com>
Mon, 14 Aug 2017 12:31:52 +0000 (14:31 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 14 Aug 2017 15:42:11 +0000 (17:42 +0200)
XPath is good for random search of elements, not for accessing
attributes of one node.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/conf/domain_conf.c

index 528d11c17d515d0213fafbdc3e111d281f453969..9dc788e9f93509cf139ff3a2cdd405cb685b612d 100644 (file)
@@ -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;
     }