From: Daan De Meyer Date: Fri, 15 Jul 2022 00:39:12 +0000 (+0200) Subject: Pass kernel args to systemd when booting in nspawn X-Git-Tag: v14~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9ad29b098dc832c384acea6c70b319fe92afb76;p=thirdparty%2Fmkosi.git Pass kernel args to systemd when booting in nspawn When booting systemd in systemd-nspawn, additional arguments can be passed to systemd via nspawn's command line. The arguments get interpreted by systemd in the container as if they were kernel command line args. To take advantage of this, let's pass any configured kernel command line arguments to systemd running in nspawn as well. For example, this allows using systemd.setenv to set environment variables as early as possible for both qemu VMs and nspawn containers. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index b18bd9cde..6be9bf051 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -7760,6 +7760,11 @@ def run_shell_cmdline(args: MkosiArgs, pipe: bool = False, commands: Optional[Se if args.source_file_transfer_final == SourceFileTransfer.mount: cmdline += [f"--bind={args.build_sources}:/root/src", "--chdir=/root/src"] + if args.verb == Verb.boot: + # kernel cmdline args of the form systemd.xxx= get interpreted by systemd when running in nspawn as + # well. + cmdline += args.kernel_command_line + if commands or args.cmdline: # If the verb is 'shell', args.cmdline contains the command to run. # Otherwise, the verb is 'boot', and we assume args.cmdline contains nspawn arguments.