[PATCH 07/17] conf: error out for multiple protocol elements while parsing chardev

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

 



Remove check whether a variable was already set because the element
is parsed only once now.

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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 639aa430ae..bb4be5d1cd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10918,6 +10918,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
     char *haveTLS = NULL;
     char *tlsFromConfig = NULL;
     bool logParsed = false;
+    bool protocolParsed = false;
     int sourceParsed = 0;
 
     for (; cur; cur = cur->next) {
@@ -11032,8 +11033,14 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
             logfile = virXMLPropString(cur, "file");
             logappend = virXMLPropString(cur, "append");
         } else if (virXMLNodeNameEqual(cur, "protocol")) {
-            if (!protocol)
-                protocol = virXMLPropString(cur, "type");
+            if (protocolParsed) {
+                virReportError(VIR_ERR_XML_ERROR, "%s",
+                               _("only one log element is allowed for "
+                                 "character device"));
+                goto error;
+            }
+            protocolParsed = true;
+            protocol = virXMLPropString(cur, "type");
         }
     }
 
-- 
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