1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

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.
This commit is contained in:
Lennart Poettering 2024-04-19 14:41:43 +02:00
parent 77290bc83f
commit 6f9a1adf6d
2 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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)