]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: use virXMLPropString for IOThread 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:46:21 +0000 (17:46 +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 cb1b5b55fb9ffa6552139c0ddc669b80edca15b2..6e424c96d877442cfbbd4b378d42f229e0c53d20 100644 (file)
@@ -16209,19 +16209,15 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
  *     </iothreadids>
  */
 static virDomainIOThreadIDDefPtr
-virDomainIOThreadIDDefParseXML(xmlNodePtr node,
-                               xmlXPathContextPtr ctxt)
+virDomainIOThreadIDDefParseXML(xmlNodePtr node)
 {
     virDomainIOThreadIDDefPtr iothrid;
-    xmlNodePtr oldnode = ctxt->node;
     char *tmp = NULL;
 
     if (VIR_ALLOC(iothrid) < 0)
         return NULL;
 
-    ctxt->node = node;
-
-    if (!(tmp = virXPathString("string(./@id)", ctxt))) {
+    if (!(tmp = virXMLPropString(node, "id"))) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("Missing 'id' attribute in <iothread> element"));
         goto error;
@@ -16235,7 +16231,6 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node,
 
  cleanup:
     VIR_FREE(tmp);
-    ctxt->node = oldnode;
     return iothrid;
 
  error:
@@ -16275,7 +16270,7 @@ virDomainDefParseIOThreads(virDomainDefPtr def,
 
     for (i = 0; i < n; i++) {
         virDomainIOThreadIDDefPtr iothrid = NULL;
-        if (!(iothrid = virDomainIOThreadIDDefParseXML(nodes[i], ctxt)))
+        if (!(iothrid = virDomainIOThreadIDDefParseXML(nodes[i])))
             goto error;
 
         if (virDomainIOThreadIDFind(def, iothrid->iothread_id)) {