diff mbox series

[OSSTEST] grub2 setup: Set GRUB_TERMINAL=console, if no other setting

Message ID 20191031171029.3627-1-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show
Series [OSSTEST] grub2 setup: Set GRUB_TERMINAL=console, if no other setting | expand

Commit Message

Ian Jackson Oct. 31, 2019, 5:10 p.m. UTC
The default for d-i, if it doesn't know better, is to let update-grub
set grub's terminal to `gfxterm'.  But in osstest we do not really
ever want to use a graphical console.

Let us discuss some of the cases in a bit more detail:

On UEFI systems with a serial console, the UEFI console ought (and in
our installation is in all cases so far) typically linked to the
serial console.  So GRUB_TERMINAL=console would be right for UEFI.
This appears to be correct on the albanas, our one pair of in-service
x86 boxes with a UEFI firmware configuration.

But on x86 systems, we generally pass console=ttyS... arguments on the
d-i command line, and d-i arranges for GRUB_TERMINAL=serial and
appropriate other settings.  We already have a workaround that changes
that to "serial console", which is fine whether "console" means a VGA
console we don't look at, or some kind of BIOS console redirection.
This currently works on all our x86 machines including o UEFI.

On our ThunderX (arm64) boxes, `gfxterm' does not work at all.
`console', does, because it goes to the UEFI console which UEFI sends
to the serial port.

The best approach to unpicking this mess seems to be to apply a
default setting of GRUB_TERMINAL=console.  The effect of this is to
change `gfxterm' in grub.cfg.  In practice all our x86
boxes (including our x86 UEFI boxes, where `console' would work) have
it set to `serial' (modified by us to `serial console') so remain
unchanged.

The net result is that on ARM, we now set `GRUB_TERMINAL=console', and
we now get all of the bootloader serial output on the rochesters.

I have tested this on:
  rochester0         - arm64 uefi ThunderX, used not to work
  laxton1            - arm64 uefi SoftIron
  albana0            - x86 uefi
  huxelrebe0         - x86 bios
  arndale-westfield  - armhf u-boot
  cubietruck-gleizes - armhf u-boot

Thanks to Brian Woods for poking at rochester0 and making the key
suggestions.

CC: Brian Woods <brian.woods@xilinx.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
CC: Jürgen Groß <jgross@suse.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/Debian.pm | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm
index 79aa2d24..c22aaadf 100644
--- a/Osstest/Debian.pm
+++ b/Osstest/Debian.pm
@@ -624,9 +624,11 @@  END
         
         target_editfile_root($ho, '/etc/default/grub', sub {
             my %k;
+	    my $had_terminal;
             while (<::EI>) {
 		# some bioses block the serial still so we try vga too
 		s/^(GRUB_TERMINAL=)(['"]?)serial\2\s*$/$1'serial console'\n/;
+		$had_terminal ||= m/^GRUB_TERMINAL=/;
 
                 if (m/^\s*([A-Z_]+)\s*\=\s*(.*?)\s*$/) {
                     my ($k,$v) = ($1,$2);
@@ -636,6 +638,11 @@  END
                 next if m/^GRUB_CMDLINE_(?:XEN|LINUX(?:_XEN_REPLACE)?(?:_DEFAULT)?).*\=|^GRUB_DEFAULT.*\=/;
                 print ::EO;
             }
+            print ::EO <<END or die $! unless $had_terminal;
+
+GRUB_TERMINAL="console"
+END
+
             print ::EO <<END or die $!;
 
 GRUB_DEFAULT="$entry->{MenuEntryPath}"