Skip to content

Commit 4291f44

Browse files
sam-leonard-ctbluca
authored andcommitted
vmspawn: extend kernel cmdline with extra args
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.
1 parent 12c8a7d commit 4291f44

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

man/systemd-vmspawn.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<refsect1>
4040
<title>Options</title>
4141

42-
<para>The arguments are passed straight through to QEMU, extending its command line arguments.</para>
42+
<para>The excess arguments are passed as extra kernel command line arguments using SMBIOS.</para>
4343

4444
<para>The following options are understood:</para>
4545

src/vmspawn/vmspawn.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int parse_argv(int argc, char *argv[]) {
211211
static int run_virtual_machine(void) {
212212
_cleanup_(ovmf_config_freep) OvmfConfig *ovmf_config = NULL;
213213
_cleanup_strv_free_ char **cmdline = NULL;
214-
_cleanup_free_ char *machine = NULL, *qemu_binary = NULL, *mem = NULL;
214+
_cleanup_free_ char *machine = NULL, *qemu_binary = NULL, *mem = NULL, *kcl = NULL;
215215
int r;
216216

217217
bool use_kvm = arg_qemu_kvm > 0;
@@ -357,9 +357,23 @@ static int run_virtual_machine(void) {
357357
if (r < 0)
358358
return log_oom();
359359

360-
r = strv_extend_strv(&cmdline, arg_parameters, false);
361-
if (r < 0)
362-
return log_oom();
360+
if (strv_length(arg_parameters) != 0) {
361+
#if ARCHITECTURE_SUPPORTS_SMBIOS
362+
kcl = strv_join(arg_parameters, " ");
363+
if (!kcl)
364+
return log_oom();
365+
366+
r = strv_extend(&cmdline, "-smbios");
367+
if (r < 0)
368+
return log_oom();
369+
370+
r = strv_extendf(&cmdline, "type=11,value=io.systemd.stub.kernel-cmdline-extra=%s", kcl);
371+
if (r < 0)
372+
return log_oom();
373+
#else
374+
log_warning("Cannot append extra args to kernel cmdline, native architecture doesn't support SMBIOS");
375+
#endif
376+
}
363377

364378
pid_t child_pid;
365379
r = safe_fork(qemu_binary, 0, &child_pid);

0 commit comments

Comments
 (0)