]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Switch back to using ttyS0 as the default serial console
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 30 Apr 2023 15:07:01 +0000 (17:07 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 30 Apr 2023 20:53:55 +0000 (22:53 +0200)
virtio_console is not always a builtin kernel module on all the
distributions we support. This means that the kernel can only
start logging to it after the initramfs has been unpacked and the
virtio_console module has been loaded from it. Any message that's
logged to kmsg before that dissapears into the void which makes
debugging boot failures rather difficult.

Instead, until systemd-stub is recent enough in all supported distros
to receive extra kernel cmdline arguments via smbios, let's use a
default kernel cmdline of "console=ttyS0" so that the serial console
works by default but can still be overridden by users.

.github/mkosi.conf.d/10-common.conf
mkosi.md
mkosi/__init__.py
mkosi/config.py

index f8e66bed5cdf5ea88adba955f7e07d23bc25e5f2..6d34d64ba09a456cb74bc2616b6ce7b5e208d008 100644 (file)
@@ -1,7 +1,6 @@
 [Output]
 CacheDirectory=mkosi.cache
-KernelCommandLine=console=hvc0
-                  systemd.unit=mkosi-check-and-shutdown.service
+KernelCommandLine=systemd.unit=mkosi-check-and-shutdown.service
                   systemd.log_target=console
                   systemd.default_standard_output=journal+console
 
index 1f64a4927ea7a747872ab2043b4032785183c91d..356b94649b64b38f3337fec229f00bcd4ff5be64 100644 (file)
--- a/mkosi.md
+++ b/mkosi.md
@@ -729,7 +729,7 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0",
 `Autologin=`, `--autologin`
 
 : Enable autologin for the `root` user on `/dev/pts/0` (nspawn),
-  `/dev/tty1` and `/dev/hvc0`.
+  `/dev/tty1` and `/dev/ttyS0`.
 
 `BuildScript=`, `--build-script=`
 
index f32813e8f680ac8806ba01b043f3401d5169d427..ff923da467fdb2df4d7df3b44269b99ddd6ebdb6 100644 (file)
@@ -363,8 +363,6 @@ def configure_autologin(state: MkosiState) -> None:
                                         "mkosi.resources", "console_getty_autologin.conf")
         add_dropin_config_from_resource(state.root, "serial-getty@ttyS0.service", "autologin",
                                         "mkosi.resources", "serial_getty_autologin.conf")
-        add_dropin_config_from_resource(state.root, "serial-getty@hvc0.service", "autologin",
-                                        "mkosi.resources", "serial_getty_autologin.conf")
         add_dropin_config_from_resource(state.root, "getty@tty1.service", "autologin",
                                         "mkosi.resources", "getty_autologin.conf")
 
@@ -1934,14 +1932,8 @@ def run_qemu(args: MkosiArgs, config: MkosiConfig) -> None:
             "-nographic",
             "-nodefaults",
             "-chardev", "stdio,mux=on,id=console,signal=off",
-            # Use virtconsole which appears as /dev/hvc0 in the guest on which a getty is automatically
-            # by spawned by systemd without needing a console= cmdline argument.
-            "-device", "virtio-serial",
-            "-device", "virtconsole,chardev=console",
-            "-mon", "console",
-            # EDK2 doesn't support virtio-serial, so add a regular serial console as well to get bootloader
-            # output.
             "-serial", "chardev:console",
+            "-mon", "console",
         ]
 
     for k, v in config.credentials.items():
index ec26dd5ca46c79ce1d0b3564e7c607bc73615f9f..cf249d01c98197806baedf0620289a9e7102a99e 100644 (file)
@@ -755,6 +755,7 @@ class MkosiConfigParser:
             dest="kernel_command_line",
             section="Output",
             parse=config_make_list_parser(delimiter=" "),
+            default=["console=ttyS0"],
         ),
         MkosiConfigSetting(
             dest="secure_boot",
@@ -1860,13 +1861,10 @@ def load_kernel_command_line_extra(args: argparse.Namespace) -> list[str]:
     columns, lines = shutil.get_terminal_size()
 
     cmdline = [
-        f"systemd.tty.term.hvc0={os.getenv('TERM', 'vt220')}",
-        f"systemd.tty.columns.hvc0={columns}",
-        f"systemd.tty.rows.hvc0={lines}",
         f"systemd.tty.term.ttyS0={os.getenv('TERM', 'vt220')}",
         f"systemd.tty.columns.ttyS0={columns}",
         f"systemd.tty.rows.ttyS0={lines}",
-        "console=hvc0",
+        "console=ttyS0",
     ]
 
     if args.output_format == OutputFormat.cpio: