diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-04-15 21:19:26 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2026-04-15 21:19:26 +0200 |
| commit | 15a33852bb45ee47b46145cf798cf2ab30c6c8ea (patch) | |
| tree | 68cc414d5342844d3f001a6327eb715ff1ff5ca2 | |
| parent | d9c7cf3bc0e76661f48bd0ce13acfc7be182a326 (diff) | |
| download | vyos-1x-15a33852bb45ee47b46145cf798cf2ab30c6c8ea.tar.gz vyos-1x-15a33852bb45ee47b46145cf798cf2ab30c6c8ea.zip | |
serial: T8375: call update_serial_console() only once for default tty
When there are multiple serial consoles defined; but either none or the
last used the 'kernel' CLI option to disply Kernel messages, the GRUB
code was called multiple times.
By moving the call to the GRUB helpers outside the for loop we gain a single
execution of the code path, not that it matters performance wise - but messing
with the bootloader should be reduced to a minimum.
| -rwxr-xr-x | src/conf_mode/system_console.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/conf_mode/system_console.py b/src/conf_mode/system_console.py index 50e5e607b..4985b80c0 100755 --- a/src/conf_mode/system_console.py +++ b/src/conf_mode/system_console.py @@ -30,8 +30,6 @@ airbag.enable() by_bus_dir = '/dev/serial/by-bus' -default_tty_console = ('tty', '0', '') - def get_config(config=None): if config: conf = config @@ -89,6 +87,8 @@ def generate(console): if 'serial-getty' in basename: os.unlink(os.path.join(root, basename)) + # Define a default console on a tty framebuffer + default_tty_console = ('tty', '0', '') if not console or 'device' not in console: grub_util.update_serial_console(*default_tty_console) return None @@ -110,7 +110,6 @@ def generate(console): else: raise ConfigError(f'Device {device} does not support being used as tty') - use_serial_console = False for device, device_config in console['device'].items(): # Do not render getty configuration if specified device is not a TTY. if not is_tty(device): @@ -126,12 +125,9 @@ def generate(console): # get console type ("ttyS" or "ttyAMA") from device (e.g. "ttyS0") console_type = device.rstrip('0123456789') console_num = device[len(console_type):] - grub_util.update_serial_console(console_type, console_num, device_config['speed']) - use_serial_console = True - - if not use_serial_console: - grub_util.update_serial_console(*default_tty_console) + default_tty_console = (console_type, console_num, device_config['speed']) + grub_util.update_serial_console(*default_tty_console) return None def apply(console): |
