[PATCH 20/21] Refactoring virDomainVideoDriverDefParseXML() 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 | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b9816c46ed..a5dce8a8af 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15049,25 +15049,16 @@ virDomainVideoResolutionDefParseXML(xmlNodePtr node)
 
 static virDomainVideoDriverDef *
 virDomainVideoDriverDefParseXML(xmlNodePtr node,
-                                xmlXPathContextPtr ctxt G_GNUC_UNUSED)
+                                xmlXPathContextPtr ctxt)
 {
-    xmlNodePtr cur;
     virDomainVideoDriverDef *def;
     int val;
     g_autofree char *vgaconf = NULL;
+    VIR_XPATH_NODE_AUTORESTORE(ctxt)
 
-    cur = node->children;
-    while (cur != NULL) {
-        if (cur->type == XML_ELEMENT_NODE) {
-            if (!vgaconf &&
-                virXMLNodeNameEqual(cur, "driver")) {
-                vgaconf = virXMLPropString(cur, "vgaconf");
-            }
-        }
-        cur = cur->next;
-    }
+    ctxt->node = node;
 
-    if (!vgaconf)
+    if (!(vgaconf = virXPathString("string(./driver/@vgaconf)", ctxt)))
         return NULL;
 
     def = g_new0(virDomainVideoDriverDef, 1);
-- 
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