[libvirt PATCH v6 13/15] xen_common: Change xenParsePCIList to using virConfGetValueStringList

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

 



The `if (!list || list->type != VIR_CONF_LIST)` couldn't be written in a
100% similar way as `if (virConfGetValueStringList(conf, "pci", false,
&pcis) <= 0)` leads us to just ignore any error and return 0 in case of
failure. However, for what's needed in this function, this is the
closest to the original that we can get and it shouldn't change the
function behaviour.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 src/xenconfig/xen_common.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 09f93ba449..9ad081e56b 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -462,27 +462,30 @@ xenParsePCI(char *entry)
 static int
 xenParsePCIList(virConfPtr conf, virDomainDefPtr def)
 {
-    virConfValuePtr list = virConfGetValue(conf, "pci");
+    char **pcis = NULL, **entries;
+    int ret = -1;
 
-    if (!list || list->type != VIR_CONF_LIST)
+    if (virConfGetValueStringList(conf, "pci", false, &pcis) <= 0)
         return 0;
 
-    for (list = list->list; list; list = list->next) {
+    for (entries = pcis; *entries; entries++) {
+        char *entry = *entries;
         virDomainHostdevDefPtr hostdev;
 
-        if ((list->type != VIR_CONF_STRING) || (list->str == NULL))
-            continue;
-
-        if (!(hostdev = xenParsePCI(list->str)))
-            return -1;
+        if (!(hostdev = xenParsePCI(entry)))
+            goto cleanup;
 
         if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0) {
             virDomainHostdevDefFree(hostdev);
-            return -1;
+            goto cleanup;
         }
     }
 
-    return 0;
+    ret = 0;
+
+ cleanup:
+    virStringListFree(pcis);
+    return ret;
 }
 
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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