[PATCH] LXC: don't doubly link /dev/console

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

 



When a console is configured, /dev/console and /dev/tty1 are created as
symlinks to the same underlying pts. This causes problems since a
separate getty will be spawned for /dev/console and /dev/tty1, but they
are each controlling the same device.

This patch makes it so that /dev/console is the sole symlink to the first
console, /dev/tty1 to the second, /dev/tty2 to the third and so on.

Signed-off-by: Dwight Engen <dwight.engen@xxxxxxxxxx>
---
 src/lxc/lxc_container.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index fd8ab16..dcc6b17 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1034,23 +1034,25 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
     }
 
     for (i = 0; i < nttyPaths; i++) {
-        char *tty;
-        if (virAsprintf(&tty, "/dev/tty%zu", i+1) < 0)
-            return -1;
-        if (symlink(ttyPaths[i], tty) < 0) {
-            virReportSystemError(errno,
-                                 _("Failed to symlink %s to %s"),
-                                 ttyPaths[i], tty);
+        if (i == 0) {
+            if (symlink(ttyPaths[i], "/dev/console") < 0) {
+                virReportSystemError(errno,
+                                     _("Failed to symlink %s to /dev/console"),
+                                     ttyPaths[i]);
+                return -1;
+            }
+        } else {
+            char *tty;
+            if (virAsprintf(&tty, "/dev/tty%zu", i) < 0)
+                return -1;
+            if (symlink(ttyPaths[i], tty) < 0) {
+                virReportSystemError(errno,
+                                     _("Failed to symlink %s to %s"),
+                                     ttyPaths[i], tty);
+                VIR_FREE(tty);
+                return -1;
+            }
             VIR_FREE(tty);
-            return -1;
-        }
-        VIR_FREE(tty);
-        if (i == 0 &&
-            symlink(ttyPaths[i], "/dev/console") < 0) {
-            virReportSystemError(errno,
-                                 _("Failed to symlink %s to /dev/console"),
-                                 ttyPaths[i]);
-            return -1;
         }
     }
     return 0;
-- 
1.9.0

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