[PATCH 09/17] conf: move chardev log parsing to separate function

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8fe79f70bf..eb576b90ae 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10909,6 +10909,28 @@ virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def,
 }
 
 
+static int
+virDomainChrSourceDefParseLog(virDomainChrSourceDefPtr def,
+                              xmlNodePtr log)
+{
+    char *append = NULL;
+
+    def->logfile = virXMLPropString(log, "file");
+
+    if ((append = virXMLPropString(log, "append")) &&
+        (def->logappend = virTristateSwitchTypeFromString(append)) <= 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Invalid append attribute value '%s'"),
+                       append);
+        VIR_FREE(append);
+        return -1;
+    }
+
+    VIR_FREE(append);
+    return 0;
+}
+
+
 #define SERIAL_CHANNEL_NAME_CHARS \
     "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-."
 
@@ -10931,8 +10953,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
     char *connectHost = NULL;
     char *connectService = NULL;
     char *path = NULL;
-    char *logfile = NULL;
-    char *logappend = NULL;
     char *mode = NULL;
     char *channel = NULL;
     char *master = NULL;
@@ -11053,8 +11073,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
                 goto error;
             }
             logParsed = true;
-            logfile = virXMLPropString(cur, "file");
-            logappend = virXMLPropString(cur, "append");
+            if (virDomainChrSourceDefParseLog(def, cur) < 0)
+                goto error;
         } else if (virXMLNodeNameEqual(cur, "protocol")) {
             if (protocolParsed) {
                 virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -11228,16 +11248,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
         break;
     }
 
-    def->logfile = logfile;
-    logfile = NULL;
-
-    if (logappend != NULL &&
-        (def->logappend = virTristateSwitchTypeFromString(logappend)) <= 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Invalid append attribute value '%s'"), logappend);
-        goto error;
-    }
-
     ret = 0;
  cleanup:
     VIR_FREE(mode);
@@ -11248,8 +11258,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
     VIR_FREE(path);
     VIR_FREE(channel);
     VIR_FREE(append);
-    VIR_FREE(logappend);
-    VIR_FREE(logfile);
     VIR_FREE(haveTLS);
     VIR_FREE(tlsFromConfig);
 
-- 
2.13.5

--
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