From 346ca2432dc753ab7c455a0686e848ca182cc516 Mon Sep 17 00:00:00 2001 From: Mikhail Malyshev Date: Fri, 10 Jan 2025 15:52:28 +0100 Subject: [PATCH] Replace tty0 with tty1 when starting getty 1) tty0 points to current virtual console. it is not a problem when getty is started very early before pillar/monitor are started however under following conditions it causes problems: 1. there is NO 'getty' specified on kernel command line 2. there is console=tty0 specified 3. debug.enable.console=true is set if all 3 are true then getty is started by pillar AFTER monitor app is started on tty2 and since tty0 points to tty2 in this case getty revokes console from monitor app and the output gets corrupted 2) we cannot use /dev/console from rungetty.sh anymore because it corrupts tty2 when running from pillar. Instead we use /dev/tty so the logs will be redirected to proper stdout and it should work in both cases: when getty is started by 'getty' parameter and when it is started from context of pillar. In later case logs will appear from pillar context which is correct Signed-off-by: Mikhail Malyshev --- pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh b/pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh index 61b5920e9e..9da9f95a18 100755 --- a/pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh +++ b/pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh @@ -15,9 +15,18 @@ start_getty() { term="linux" [ "$speed" = "$1" ] && speed=115200 + # if console=tty0 is specified on the kernel command line, we should not start a getty on tty0 + # but instead start it on the first available tty. tty0 points to the current console, so if + # we start a getty from pillar of debug.enable.console=true we may start it on current tty + # which may be occupied by TUI monitor application and tty will be taken away by getty. + # replacing tty0 with tty1 should be ok because this is the user's intention + if [ "$tty" = "tty0" ]; then + tty="tty1" + fi + # did we already process this tty? if $(echo "${PROCESSEDTTY}" | grep -q -w "$tty"); then - echo "getty: already processed tty for $tty, not starting twice" | tee /dev/console + echo "getty: already processed tty for $tty, not starting twice" | tee /dev/tty return fi # now indicate that we are processing it @@ -25,7 +34,7 @@ start_getty() { # does the device even exist? if [ ! -c /dev/$tty ]; then - echo "getty: cmdline has console=$tty but /dev/$tty is not a character device; not starting getty for $tty" | tee /dev/console + echo "getty: cmdline has console=$tty but /dev/$tty is not a character device; not starting getty for $tty" | tee /dev/tty return fi