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

Multiple console support



Arm64 (arm in general in fact) has a rather fundamental problem with
D-I, which is that both serial and display are sensible default
devices for the installer to run on. Which is 'correct' depends very
much on the hardware and the circumstances. You may be installing a
server in rack, or a dev board with no display, in which case serial
is ideal, or you may have a chromebook or an ARM desktop machine with
a screen plugged in and no easy access to the serial console.

This problem doesn't arise on x86 where there is 'always' a screen (or
some BIOs magic to reflect what would be on the screen to serial).

Steve (McIntyre) and I have been thinking about what to do about this,
so did some investigation and came up with a plan. Essentially it was
to run d-i on both if they are configured/available. This way anyone
looking at just one or the other will see D-I as they expect. The
patch is not intrusive and essentially nothing changes if there is
only one console so this should be a low-risk change.

There are some further questions about whether we enable just
specified consoles (from kernel command line), or all
available+enabled consoles, but we can mess with that once the basic
support is in.

So far I have done a proof-of-concept hack and demonstrated that
running two instances does in fact work nicely without anything
obvious breaking. The console selection still needs some work/checking
(I've run out of time for that tonight, but it can easily be fished
out of the kernel command line args. (or we could get fancier).

The changes are in reopen-console (in rootskel), which runs the
initial d-i menu via an inittab entry, using steal-ctty to make sure
file handles and controlling tty are set up correctly.

Essentially all that has to happen is run extra copies on the other console:

--------------
 	echo /dev/$console > /var/run/console-device
	echo /dev/$extraconsole > /var/run/extraconsole-device
 fi
 
# Some other session may have console as ctty. Steal it from them
# Run D-I on other console if one given
if [ -n $extraconsole ]; then
    ( exec /sbin/steal-ctty $(cat /var/run/extraconsole-device) "$@" & )
fi
exec /sbin/steal-ctty $(cat /var/run/console) "$@"
-----------
(attached as rootskel-multiple-consoles.patch)

The only other place this affects is
packages/finish-install.d/90console which reads
/var/run/console-device when tidying up at the end in order to write
inittab entries for the used console device (serial, xen, etc).

We also added some error-checking to steal-ctty.c which it might be
smart to include, because it currently segfaults if you don't give it
the right number of parameters, and silently fails if you run it in a
context where the calling process is not a session-master.

That's in steal-ctty-errorcheck.patch

Wookey
-- 
Principal hats:  Linaro, Debian, Wookware, ARM
http://wookware.org/
commit 860e5132001dc8a9fb032ada312d590cabc497db
Author: Wookey <wookey@debian.org>
Date:   Fri Jan 18 18:44:09 2019 +0000

    Add steal-ctty error checks

diff --git a/src/sbin/steal-ctty.c b/src/sbin/steal-ctty.c
index 0f3b14f..05a775f 100644
--- a/src/sbin/steal-ctty.c
+++ b/src/sbin/steal-ctty.c
@@ -22,8 +22,12 @@ int main(int argc, char ** argv)
     while (fd > 2) {
         close(fd--);
     }
-    ioctl(0, TIOCSCTTY, (char *) 1);
-    execvp(argv[2], &argv[2]);
+    if (-1 == ioctl(0, TIOCSCTTY, (char *) 1)) {
+      perror("steal-ctty:ioctl");
+    }
+    if (-1 == execvp(argv[2], &argv[2])) {
+      perror("steal-ctty:execvp");
+    }
     /* never reached. */
     return 0;
 }
commit 053b796076981da6fbe38e8e7663f822d935b79b
Author: Wookey <wookey@debian.org>
Date:   Fri Jan 18 18:45:03 2019 +0000

    run two installers

diff --git a/src/sbin/reopen-console-linux b/src/sbin/reopen-console-linux
index 87a7f7a..431bff0 100755
--- a/src/sbin/reopen-console-linux
+++ b/src/sbin/reopen-console-linux
@@ -70,7 +70,13 @@ if ! [ -f /var/run/console-device ]; then
 		console=console
 	fi
 	echo /dev/$console > /var/run/console-device
+	echo /dev/$extraconsole > /var/run/extraconsole-device
 fi
 
-# Some other session may have it as ctty. Steal it from them
-exec /sbin/steal-ctty $(cat /var/run/console-device) "$@"
+# Some other session may have console as ctty. Steal it from them
+# Run D-I on other consoles if they are given
+if [ -n $extraconsole ]; then
+    ( exec /sbin/steal-ctty $(cat /var/run/extraconsole-device) "$@" & )
+fi
+exec /sbin/steal-ctty $(cat /var/run/console) "$@"
+

Attachment: signature.asc
Description: PGP signature


Reply to: