summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-04-19 14:41:43 +0200
committerLennart Poettering <lennart@poettering.net>2024-04-20 12:10:42 +0200
commit6f9a1adf6d1341a7db98c5278e13e035c7a669d5 (patch)
treead5a0789d60172e3c7c6431fcb1158d487a9c8bc
parentvmspawn: enable hyperv enlightenments (diff)
downloadsystemd-6f9a1adf6d1341a7db98c5278e13e035c7a669d5.tar.xz
systemd-6f9a1adf6d1341a7db98c5278e13e035c7a669d5.zip
vmspawn: add env var that can extend the qemu cmdline
This is a bit hackish, but really useful sometimes to play around with some qemu switches.
-rw-r--r--docs/ENVIRONMENT.md3
-rw-r--r--src/vmspawn/vmspawn.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/docs/ENVIRONMENT.md b/docs/ENVIRONMENT.md
index 961601c72e..8068d0d33c 100644
--- a/docs/ENVIRONMENT.md
+++ b/docs/ENVIRONMENT.md
@@ -191,6 +191,9 @@ All tools:
expected format is six groups of two hexadecimal digits separated by colons,
e.g. `SYSTEMD_VMSPAWN_NETWORK_MAC=12:34:56:78:90:AB`
+* `$SYSTEMD_VMSPAWN_QEMU_EXTRA=…` – may contain additional command line
+ arguments to append the qemu command line.
+
`systemd-logind`:
* `$SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1` — if set, report that
diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c
index 9687119df4..2ebb158640 100644
--- a/src/vmspawn/vmspawn.c
+++ b/src/vmspawn/vmspawn.c
@@ -1881,6 +1881,18 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
return log_error_errno(r, "Failed to call getsockname on VSOCK: %m");
}
+ const char *e = secure_getenv("SYSTEMD_VMSPAWN_QEMU_EXTRA");
+ if (e) {
+ _cleanup_strv_free_ char **extra = NULL;
+
+ r = strv_split_full(&extra, e, /* separator= */ NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
+ if (r < 0)
+ return log_error_errno(r, "Failed to split $SYSTEMD_VMSPAWN_QEMU_EXTRA environment variable: %m");
+
+ if (strv_extend_strv(&cmdline, extra, /* filter_duplicates= */ false) < 0)
+ return log_oom();
+ }
+
if (DEBUG_LOGGING) {
_cleanup_free_ char *joined = quote_command_line(cmdline, SHELL_ESCAPE_EMPTY);
if (!joined)