diff options
author | Sam Leonard <sam.leonard@codethink.co.uk> | 2023-11-06 10:25:12 +0000 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-11-06 11:46:38 +0000 |
commit | 4291f4461e6b0ddcc93b642291311f3fa8c82fb0 (patch) | |
tree | 15360380aaea9ce2dc9f9569fed7038a8281c68e | |
parent | 12c8a7de1248fbf435ed5d521d1a8405d5827b22 (diff) |
vmspawn: extend kernel cmdline with extra argsv255-rc1
This changes how the "extra" command line arguments passed to vmspawn
are handled.
Previously they were appended to the QEMU command line directly.
Now they are appended to the kernel command line using SMBIOS instead.
-rw-r--r-- | man/systemd-vmspawn.xml | 2 | ||||
-rw-r--r-- | src/vmspawn/vmspawn.c | 22 |
2 files changed, 19 insertions, 5 deletions
diff --git a/man/systemd-vmspawn.xml b/man/systemd-vmspawn.xml index be5b443619..bf3aaf028e 100644 --- a/man/systemd-vmspawn.xml +++ b/man/systemd-vmspawn.xml @@ -39,7 +39,7 @@ <refsect1> <title>Options</title> - <para>The arguments are passed straight through to QEMU, extending its command line arguments.</para> + <para>The excess arguments are passed as extra kernel command line arguments using SMBIOS.</para> <para>The following options are understood:</para> diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index 68c483ad02..ab137df0a7 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -211,7 +211,7 @@ static int parse_argv(int argc, char *argv[]) { static int run_virtual_machine(void) { _cleanup_(ovmf_config_freep) OvmfConfig *ovmf_config = NULL; _cleanup_strv_free_ char **cmdline = NULL; - _cleanup_free_ char *machine = NULL, *qemu_binary = NULL, *mem = NULL; + _cleanup_free_ char *machine = NULL, *qemu_binary = NULL, *mem = NULL, *kcl = NULL; int r; bool use_kvm = arg_qemu_kvm > 0; @@ -357,9 +357,23 @@ static int run_virtual_machine(void) { if (r < 0) return log_oom(); - r = strv_extend_strv(&cmdline, arg_parameters, false); - if (r < 0) - return log_oom(); + if (strv_length(arg_parameters) != 0) { +#if ARCHITECTURE_SUPPORTS_SMBIOS + kcl = strv_join(arg_parameters, " "); + if (!kcl) + return log_oom(); + + r = strv_extend(&cmdline, "-smbios"); + if (r < 0) + return log_oom(); + + r = strv_extendf(&cmdline, "type=11,value=io.systemd.stub.kernel-cmdline-extra=%s", kcl); + if (r < 0) + return log_oom(); +#else + log_warning("Cannot append extra args to kernel cmdline, native architecture doesn't support SMBIOS"); +#endif + } pid_t child_pid; r = safe_fork(qemu_binary, 0, &child_pid); |