]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Beef up --kernel-command-line-extra= defaults a little bit
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 13 Jul 2023 10:51:46 +0000 (12:51 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 13 Jul 2023 16:09:41 +0000 (18:09 +0200)
Let's provide a better experience out of the box when booting an image:
- Always blacklist vmw_vmci so it can't interfere with vsock
- Always pull in network-online.target
- Configure systemd-network-generator for enp0s1 and host0 if not
  configured explicitly
- Use a default loglevel where only warnings or higher are logged to
  the serial console by the kernel
- Set SYSTEMD_SULOGIN_FORCE=1 unless configured explicitly so users
  get a shell in the initrd if something goes wrong, even if no root
  password is configured

mkosi/config.py

index 2efd0240517bb9099482c90503657c03580b74f1..53818ca4f66d0a38bd6cf22a2e4a5bef5cee9038 100644 (file)
@@ -2021,10 +2021,20 @@ def load_kernel_command_line_extra(args: argparse.Namespace) -> list[str]:
         f"systemd.tty.columns.ttyS0={columns}",
         f"systemd.tty.rows.ttyS0={lines}",
         "console=ttyS0",
+        # Make sure we set up networking in the VM/container.
+        "systemd.wants=network-online.target",
+        # Make sure we don't load vmw_vmci which messes with virtio vsock.
+        "module_blacklist=vmw_vmci",
     ]
 
-    if args.output_format == OutputFormat.cpio:
-        cmdline += ["rd.systemd.unit=default.target"]
+    if not any(s.startswith("ip=") for s in args.kernel_command_line_extra):
+        cmdline += ["ip=enp0s1:any", "ip=host0:any"]
+
+    if not any(s.startswith("loglevel=") for s in args.kernel_command_line_extra):
+        cmdline += ["loglevel=4"]
+
+    if not any(s.startswith("SYSTEMD_SULOGIN_FORCE=") for s in args.kernel_command_line_extra):
+        cmdline += ["SYSTEMD_SULOGIN_FORCE=1"]
 
     for s in args.kernel_command_line_extra:
         key, sep, value = s.partition("=")