diff options
| author | tv <tv@krebsco.de> | 2026-11-16 03:09:42 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-16 03:09:42 +0000 |
| commit | 2be134b0b5e7173573c64bac49c880276bcb3d59 (patch) | |
| tree | ab652dbf6111d92361e84f9b1872eff0b4a34bf4 /default.nix | |
| parent | f2b536e9d5adf5114025d69a68dfbadd1f8fff01 (diff) | |
pass the terminal size on the kernel command line
When starting the serial getty, systemd asks the terminal for its size
via ANSI sequences and waits up to 333ms for an answer (see
CONSOLE_ANSI_SEQUENCE_TIMEOUT_USEC in src/basic/terminal-util.c). The
journal shows the serial login completing ~0.4s after the getty started,
while the getty on tty1 took 0.08s.
systemd skips the query if systemd.tty.rows.ttyS0 and
systemd.tty.columns.ttyS0 are on the kernel command line, so take them
from the terminal run-firecracker-vm is started from. This also gives
the guest the right terminal size.
Diffstat (limited to 'default.nix')
| -rw-r--r-- | default.nix | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/default.nix b/default.nix index 207588b..aa8a7e4 100644 --- a/default.nix +++ b/default.nix @@ -78,7 +78,7 @@ let boot-source = { kernel_image_path = "${kernel.dev}/vmlinux"; initrd_path = "${initialRamdisk}/${nixos.config.system.boot.loader.initrdFile}"; - boot_args = toString (nixos.config.boot.kernelParams ++ [ "init=${toplevel}/init" ]); + boot_args = toString (nixos.config.boot.kernelParams ++ [ "init=${toplevel}/init" "@TTY_SIZE@" ]); }; network-interfaces = [{ iface_id = "eth0"; @@ -123,6 +123,14 @@ pkgs.writeShellScriptBin "run-firecracker-vm" '' find "$cache" -type f ! -path "$img" -delete fi - sed "s|@STORE_IMAGE@|$img|" ${config} > "$tmp"/config.json + # Tell systemd the terminal size, so it doesn't query it via ANSI + # sequences (and wait up to 333ms for an answer) when starting the getty. + tty_size= + if size=$(stty size 2>/dev/null) && test "$size" != "0 0"; then + read -r rows cols <<< "$size" + tty_size="systemd.tty.rows.ttyS0=$rows systemd.tty.columns.ttyS0=$cols" + fi + + sed -e "s|@STORE_IMAGE@|$img|" -e "s|@TTY_SIZE@|$tty_size|" ${config} > "$tmp"/config.json firecracker --no-api --config-file "$tmp"/config.json '' |
