diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-11-03 19:15:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-03 19:15:04 +0100 |
| commit | 6ea85bda82cc50809d73c6b422308dd4bc52fb6b (patch) | |
| tree | 8dd659021297bb7e23ca19ee19f28113966cf755 /src/migration-scripts | |
| parent | a100a7f62325beac2c9c3a75778bca09da3e9d08 (diff) | |
| parent | 44d929a1b973d3f4131d25d7f9cd7b69c3cf3514 (diff) | |
| download | vyos-1x-6ea85bda82cc50809d73c6b422308dd4bc52fb6b.tar.gz vyos-1x-6ea85bda82cc50809d73c6b422308dd4bc52fb6b.zip | |
Merge pull request #5627 from c-po/T9567-serial-console-compat-migration
serial: T9567: honor booted serial console during 31 -> 32 migration
Diffstat (limited to 'src/migration-scripts')
| -rw-r--r-- | src/migration-scripts/system/31-to-32 | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/migration-scripts/system/31-to-32 b/src/migration-scripts/system/31-to-32 index 89b604a7f..4f537cd41 100644 --- a/src/migration-scripts/system/31-to-32 +++ b/src/migration-scripts/system/31-to-32 @@ -17,9 +17,12 @@ from vyos.configtree import ConfigTree from vyos.flavor import get_image_serial_console +from vyos.system import compat from vyos.system import disk +from vyos.system import image from vyos.system.grub import CFG_VYOS_VARS from vyos.system.grub import vars_read +from vyos.utils.kernel import get_kernel_primary_console base = ['system', 'console'] @@ -35,6 +38,25 @@ def migrate(config: ConfigTree) -> None: console_type, console_num = 'ttyS', '0' serial_console = f'{console_type}{console_num}' + if not config.exists(base + ['device', serial_console]): + return + + # A container shares the kernel command line of its host, which says + # nothing about the console of VyOS itself + if image.is_running_as_container(): + return + + # An installed legacy image keeps GRUB in compat mode. The GRUB structure + # update then rewrites the GRUB vars on every boot before migration runs, + # so they may not reflect the boot console - use the console the kernel + # booted with instead + if compat.mode(): + kernel_type, kernel_num, _ = get_kernel_primary_console() + if kernel_type is not None: + if f'{kernel_type}{kernel_num}' == serial_console: + config.set(base + ['device', serial_console, 'kernel']) + return + root_dir = disk.find_persistence() vars_file: str = f'{root_dir}/{CFG_VYOS_VARS}' vars_current: dict[str, str] = vars_read(vars_file) @@ -46,5 +68,4 @@ def migrate(config: ConfigTree) -> None: # Check if VyOS installation uses serial boot console if vars_current['console_type'] == console_type: - if config.exists(base + ['device', serial_console]): - config.set(base + ['device', serial_console, 'kernel']) + config.set(base + ['device', serial_console, 'kernel']) |
