[PATCH 15/17] conf: move FILE chardev source 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 | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 84184a265e..1baf6b9174 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11006,6 +11006,28 @@ virDomainChrSourceDefParseUnix(virDomainChrSourceDefPtr def,
 
 
 static int
+virDomainChrSourceDefParseFile(virDomainChrSourceDefPtr def,
+                               xmlNodePtr source)
+{
+    char *append = NULL;
+
+    def->data.file.path = virXMLPropString(source, "path");
+
+    if ((append = virXMLPropString(source, "append")) &&
+        (def->data.file.append = virTristateSwitchTypeFromString(append)) <= 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Invalid append attribute value '%s'"),
+                       append);
+        VIR_FREE(append);
+        return -1;
+    }
+
+    VIR_FREE(append);
+    return 0;
+}
+
+
+static int
 virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def,
                                    xmlNodePtr protocol)
 {
@@ -11067,7 +11089,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
                               int nvmSeclabels)
 {
     int ret = -1;
-    char *append = NULL;
     bool logParsed = false;
     bool protocolParsed = false;
     int sourceParsed = 0;
@@ -11095,11 +11116,13 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
 
             switch ((virDomainChrType) def->type) {
             case VIR_DOMAIN_CHR_TYPE_FILE:
+                if (virDomainChrSourceDefParseFile(def, cur) < 0)
+                    goto error;
+                break;
+
             case VIR_DOMAIN_CHR_TYPE_PTY:
             case VIR_DOMAIN_CHR_TYPE_DEV:
             case VIR_DOMAIN_CHR_TYPE_PIPE:
-                if (!append && def->type == VIR_DOMAIN_CHR_TYPE_FILE)
-                    append = virXMLPropString(cur, "append");
                 /* PTY path is only parsed from live xml.  */
                 if (def->type != VIR_DOMAIN_CHR_TYPE_PTY ||
                     !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
@@ -11188,12 +11211,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
     case VIR_DOMAIN_CHR_TYPE_PTY:
     case VIR_DOMAIN_CHR_TYPE_DEV:
     case VIR_DOMAIN_CHR_TYPE_PIPE:
-        if (append && def->type == VIR_DOMAIN_CHR_TYPE_FILE &&
-            (def->data.file.append = virTristateSwitchTypeFromString(append)) <= 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Invalid append attribute value '%s'"), append);
-            goto error;
-        }
         if (!def->data.file.path &&
             def->type != VIR_DOMAIN_CHR_TYPE_PTY) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -11267,8 +11284,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
 
     ret = 0;
  cleanup:
-    VIR_FREE(append);
-
     return ret;
 
  error:
-- 
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