Skip to content

Commit

Permalink
Replace tty0 with tty1 when starting getty
Browse files Browse the repository at this point in the history
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 <mike.malyshev@gmail.com>
  • Loading branch information
rucoder committed Jan 10, 2025
1 parent 0ef9bdc commit 346ca24
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,26 @@ start_getty() {
term="linux"

Check failure on line 15 in pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh

View workflow job for this annotation

GitHub Actions / yetus

blanks:tabs in line
[ "$speed" = "$1" ] && speed=115200

Check failure on line 16 in pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh

View workflow job for this annotation

GitHub Actions / yetus

blanks:tabs in line

# if console=tty0 is specified on the kernel command line, we should not start a getty on tty0

Check failure on line 18 in pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh

View workflow job for this annotation

GitHub Actions / yetus

blanks:tabs in line
# but instead start it on the first available tty. tty0 points to the current console, so if

Check failure on line 19 in pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh

View workflow job for this annotation

GitHub Actions / yetus

blanks:tabs in line
# we start a getty from pillar of debug.enable.console=true we may start it on current tty

Check failure on line 20 in pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh

View workflow job for this annotation

GitHub Actions / yetus

blanks:tabs in line
# which may be occupied by TUI monitor application and tty will be taken away by getty.

Check failure on line 21 in pkg/dom0-ztools/rootfs/usr/bin/rungetty.sh

View workflow job for this annotation

GitHub Actions / yetus

blanks:tabs in line
# 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
PROCESSEDTTY="${PROCESSEDTTY} ${tty}"

# 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

Expand Down

0 comments on commit 346ca24

Please sign in to comment.