[PATCH 14/21] Refactoring virDomainChrDefParseTargetXML() to use XPath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 163c47b7e0..ca9d54a47a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11614,16 +11614,18 @@ virDomainChrTargetModelFromString(int devtype,
 static int
 virDomainChrDefParseTargetXML(virDomainChrDef *def,
                               xmlNodePtr cur,
-                              xmlXPathContextPtr ctxt G_GNUC_UNUSED,
+                              xmlXPathContextPtr ctxt,
                               unsigned int flags)
 {
-    xmlNodePtr child;
     unsigned int port;
     g_autofree char *targetType = virXMLPropString(cur, "type");
     g_autofree char *targetModel = NULL;
     g_autofree char *addrStr = NULL;
     g_autofree char *portStr = NULL;
     g_autofree char *stateStr = NULL;
+    VIR_XPATH_NODE_AUTORESTORE(ctxt)
+
+    ctxt->node = cur;
 
     if ((def->targetType =
          virDomainChrTargetTypeFromString(def->deviceType,
@@ -11634,14 +11636,7 @@ virDomainChrDefParseTargetXML(virDomainChrDef *def,
         return -1;
     }
 
-    child = cur->children;
-    while (child != NULL) {
-        if (child->type == XML_ELEMENT_NODE &&
-            virXMLNodeNameEqual(child, "model")) {
-            targetModel = virXMLPropString(child, "name");
-        }
-        child = child->next;
-    }
+    targetModel = virXPathString("string(./model/@name)", ctxt);
 
     if ((def->targetModel =
          virDomainChrTargetModelFromString(def->deviceType,
-- 
2.30.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux