[libvirt] [PATCH] conf: move the check for secondary consoles of targetType serial

Erik Skultety eskultet at redhat.com
Thu Dec 11 11:28:22 UTC 2014


For historical reasons, only the first <console> element might be of targetType
serial, but we checked for other consoles of targetType serial in our post-parse
callback if and only if we knew the first console was serial, otherwise
the check was skipped.
This patch moves the check one level up, so first
the check for secondary console of type serial is performed and then the
rest of operations continue unchanged.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1170092
---
 src/conf/domain_conf.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ec45b8c..dc0b167 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3023,19 +3023,22 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
      * We then fill def->consoles[0] with a stub just so we get sequencing
      * correct for consoles > 0
      */
+
+    /* Only the first console (if there are any) can be of type serial,
+     * verify that no other console is of type serial
+     */
+    for (i = 1; i < def->nconsoles; i++) {
+        virDomainChrDefPtr cons = def->consoles[i];
+
+        if (cons->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Only the first console can be a serial port"));
+            return -1;
+        }
+    }
     if (def->nconsoles > 0 && STREQ(def->os.type, "hvm") &&
         (def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
          def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) {
-        /* First verify that only the first console is of type serial */
-        for (i = 1; i < def->nconsoles; i++) {
-            virDomainChrDefPtr cons = def->consoles[i];
-
-            if (cons->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("Only the first console can be a serial port"));
-                return -1;
-            }
-        }
 
         /* If there isn't a corresponding serial port:
          *  - create one and set, the console to be an alias for it
-- 
1.9.3




More information about the libvir-list mailing list