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

Re: Multiple console support in d-i



[ adding a CC to the debian-arm list - review there welcome too... ]

On Sat, Jan 19, 2019 at 04:27:05AM +0000, Wookey wrote:
>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.

ACK. There are also extra complications to confuse the issue. A Cavium
ThunderX "server" machine can also make quite a reasonable workstation
- just put it in a different case with a PCIe video card and USB
peripherals. People are selling these today! But the motherboard
firmware will tell the kernel to use ttyAMA0 as the default console
using ACPI (the SPCR table).

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

Yup. I saw this working yesterday - yay!

>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).

Nod. Potentially we might end up of running on multiple
consoles. Exactly how we define the set is not yet decided. Two
possible options I've thought of:

 * add lots more console= options to the grub.cfg for arm64 (to cover
   all the possibilities), then let d-i startup work out which devices
   exist from /proc/cmdlinge and spawn d-i on each.

   (This will look slightly messy if people look at grub.cfg, but it
    does allow for easy user-controllable changes to add/remove/change
    the settings.)

 * add that arch-specific list into d-i somwhere such that
   reopen-console-linux can grab it and use it, similarly.

   (slightly cleaner, but harder to over-ride. Maybe a hybrid is best
   - add a default list here and *also* parse /proc/cmdline for
   extras?)

>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;
> }

Happy to take this straight away, tbh. Kibi?

>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) "$@"
>+

2 minor nits here:

 1. You're checking for $extraconsole being set, but you're not using
    that, you're using the contents of
    /var/run/extraconsole-device. The two are not guaranteed to be the
    same. Instead, just check for the existence/size of the file (-s
    FILE)?

 2. We might want there to be more than one extra console here,
    depending on the hardware config. Maybe move to $extraconsoles and
    /var/run/extraconsole-devices and a loop to start on all of them?

We might *also* want to think about what console(s) the installed
system will use, but that's the next stage... :-)

-- 
Steve McIntyre, Cambridge, UK.                                steve@einval.com
"I suspect most samba developers are already technically insane... Of
 course, since many of them are Australians, you can't tell." -- Linus Torvalds


Reply to: