[PATCH 3/5] virDomainFeaturesCapabilitiesDefParse: 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 | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bb4f1fdb94..d510279472 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16462,7 +16462,10 @@ static int
 virDomainFeaturesCapabilitiesDefParse(virDomainDef *def,
                                       xmlNodePtr node)
 {
+    g_autofree xmlNodePtr *caps = NULL;
+    size_t ncaps = virXMLNodeGetSubelementList(node, NULL, &caps);
     virDomainCapabilitiesPolicy policy;
+    size_t i;

     if (virXMLPropEnumDefault(node, "policy",
                               virDomainCapabilitiesPolicyTypeFromString,
@@ -16472,25 +16475,23 @@ virDomainFeaturesCapabilitiesDefParse(virDomainDef *def,

     def->features[VIR_DOMAIN_FEATURE_CAPABILITIES] = policy;

-    node = xmlFirstElementChild(node);
-    while (node) {
+    for (i = 0; i < ncaps; i++) {
         virTristateSwitch state;
-        int val = virDomainProcessCapsFeatureTypeFromString((const char *)node->name);
+        int val = virDomainProcessCapsFeatureTypeFromString((const char *)caps[i]->name);
         if (val < 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("unexpected capability feature '%1$s'"), node->name);
+                           _("unexpected capability feature '%1$s'"), caps[i]->name);
             return -1;
         }


-        if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_NONE, &state) < 0)
+        if (virXMLPropTristateSwitch(caps[i], "state", VIR_XML_PROP_NONE, &state) < 0)
             return -1;

         if (state == VIR_TRISTATE_SWITCH_ABSENT)
             state = VIR_TRISTATE_SWITCH_ON;

         def->caps_features[val] = state;
-        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