[PATCH 5/5] virDomainFeaturesXENDefParse: Use virXMLNodeGetSubelementList

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

 



Rewrite the old-style parser to use virXMLNodeGetSubelementList

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3a08034b9d..02bba77768 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16409,22 +16409,25 @@ static int
 virDomainFeaturesXENDefParse(virDomainDef *def,
                              xmlNodePtr node)
 {
+    g_autofree xmlNodePtr *feats = NULL;
+    size_t nfeats = virXMLNodeGetSubelementList(node, NULL, &feats);
+    size_t i;
+
     def->features[VIR_DOMAIN_FEATURE_XEN] = VIR_TRISTATE_SWITCH_ON;

-    node = xmlFirstElementChild(node);
-    while (node) {
+    for (i = 0; i < nfeats; i++) {
         int feature;
         virTristateSwitch value;

-        feature = virDomainXenTypeFromString((const char *)node->name);
+        feature = virDomainXenTypeFromString((const char *)feats[i]->name);
         if (feature < 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unsupported Xen feature: %1$s"),
-                           node->name);
+                           feats[i]->name);
             return -1;
         }

-        if (virXMLPropTristateSwitch(node, "state",
+        if (virXMLPropTristateSwitch(feats[i], "state",
                                      VIR_XML_PROP_REQUIRED, &value) < 0)
             return -1;

@@ -16438,7 +16441,7 @@ virDomainFeaturesXENDefParse(virDomainDef *def,
             if (value != VIR_TRISTATE_SWITCH_ON)
                 break;

-            if (virXMLPropEnum(node, "mode",
+            if (virXMLPropEnum(feats[i], "mode",
                                virDomainXenPassthroughModeTypeFromString,
                                VIR_XML_PROP_NONZERO,
                                &def->xen_passthrough_mode) < 0)
@@ -16448,8 +16451,6 @@ virDomainFeaturesXENDefParse(virDomainDef *def,
             case VIR_DOMAIN_XEN_LAST:
                 break;
         }
-
-        node = xmlNextElementSibling(node);
     }

     return 0;
-- 
2.41.0




[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