in scripted environments where the `qemu` and `ssh` verbs are used in a quick
succession and the virtual device might not get enough time to configure itself.
+`Credential=`, `--credential`
+
+: Set credentials to be passed to systemd-nspawn or qemu respectively when
+ `mkosi shell/boot` or `mkosi qemu` are used. This option takes a space separated
+ list of key=value assignments.
+
### Commandline-only Options
Those settings cannot be configured in the configuration files.
metavar="PORT",
help="If specified, 'mkosi ssh' will use this port to connect",
)
+ group.add_argument(
+ "--credential",
+ dest="credentials",
+ action=SpaceDelimitedListAction,
+ default=[],
+ help="Pass a systemd credential to systemd-nspawn or qemu",
+ metavar="NAME=VALUE",
+ )
group = parser.add_argument_group("Additional configuration options")
group.add_argument(
else:
args.environment = {}
+ if args.credentials:
+ credentials = {}
+ for s in args.credentials:
+ key, _, value = s.partition("=")
+ credentials[key] = value
+ args.credentials = credentials
+ else:
+ args.credentials = {}
+
if args.cache_path is not None:
args.cache_path = args.cache_path.absolute()
shutil.move(str(state.staging / p.name), str(p))
if p in (state.config.output, state.config.output_split_kernel):
compress_output(state.config, p)
- if state.config.chown and p.exists():
+ if state.config.chown and p.exists():
chown_to_running_user(p)
for p in state.staging.iterdir():
if config.source_file_transfer_final == SourceFileTransfer.mount:
cmdline += [f"--bind={config.build_sources}:/root/src", "--chdir=/root/src"]
+ for k, v in config.credentials.items():
+ cmdline += [f"--set-credential={k}:{v}"]
+
if config.verb == Verb.boot:
# Add nspawn options first since systemd-nspawn ignores all options after the first argument.
cmdline += config.cmdline
"-append", config.output_split_cmdline.read_text().strip(),
]
+ for k, v in config.credentials.items():
+ cmdline += ["-smbios", f"type=11,value=io.systemd.credential:{k}={v}"]
+
with contextlib.ExitStack() as stack:
if config.qemu_boot == "uefi" and fw_supports_sb:
ovmf_vars = stack.enter_context(copy_file_temporary(src=find_ovmf_vars(config), dir=tmp_dir()))