[libvirt] [libvirt PATCH v7 6/6] xen_common: Change xenParseCharDev to using virConfGetValueStringList

Fabiano Fidêncio fidencio at redhat.com
Thu Sep 20 13:28:52 UTC 2018


Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 src/xenconfig/xen_common.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 058f35825e..21f1f4a24c 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -773,11 +773,13 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
 static int
 xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
 {
-    virConfValuePtr value = NULL;
+    VIR_AUTOPTR(virString) serials = NULL;
     virDomainChrDefPtr chr = NULL;
 
     if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         VIR_AUTOFREE(char *) parallel = NULL;
+        int rc;
+
         if (xenConfigGetString(conf, "parallel", &parallel, NULL) < 0)
             goto cleanup;
         if (parallel && STRNEQ(parallel, "none") &&
@@ -795,8 +797,8 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
         }
 
         /* Try to get the list of values to support multiple serial ports */
-        value = virConfGetValue(conf, "serial");
-        if (value && value->type == VIR_CONF_LIST) {
+        if ((rc = virConfGetValueStringList(conf, "serial", false, &serials)) == 1) {
+            virString *entries;
             int portnum = -1;
 
             if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) {
@@ -805,18 +807,12 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
                 goto cleanup;
             }
 
-            value = value->list;
-            while (value) {
-                char *port = NULL;
+            for (entries = serials; *entries; entries++) {
+                virString port = *entries;
 
-                if ((value->type != VIR_CONF_STRING) || (value->str == NULL))
-                    goto cleanup;
-                port = value->str;
                 portnum++;
-                if (STREQ(port, "none")) {
-                    value = value->next;
+                if (STREQ(port, "none"))
                     continue;
-                }
 
                 if (!(chr = xenParseSxprChar(port, NULL)))
                     goto cleanup;
@@ -824,11 +820,14 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
                 chr->target.port = portnum;
                 if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) < 0)
                     goto cleanup;
-
-                value = value->next;
             }
         } else {
             VIR_AUTOFREE(char *) serial = NULL;
+
+            rc = xenHandleConfGetValueStringListErrors(rc, virGetLastErrorCode());
+            if (rc < 0)
+                goto cleanup;
+
             /* If domain is not using multiple serial ports we parse data old way */
             if (xenConfigGetString(conf, "serial", &serial, NULL) < 0)
                 goto cleanup;
-- 
2.17.1




More information about the libvir-list mailing list