From f607dd58bdfaca1c3c243be04348a1c3787c0d4c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 10 May 2024 11:27:48 +0900 Subject: [PATCH 1/2] vmspawn: trivial cleanups for start_systemd_journal_remote() - prefix argument for storing result with 'ret_', - align arguments for strv_new(). --- src/vmspawn/vmspawn.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index 05661961ed0..a5666459a34 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -929,7 +929,7 @@ static int start_tpm( return 0; } -static int start_systemd_journal_remote(sd_bus *bus, const char *scope, unsigned port, const char *sd_journal_remote, char **listen_address) { +static int start_systemd_journal_remote(sd_bus *bus, const char *scope, unsigned port, const char *sd_journal_remote, char **ret_listen_address) { _cleanup_free_ char *scope_prefix = NULL; _cleanup_(socket_service_pair_done) SocketServicePair ssp = { .socket_type = SOCK_STREAM, @@ -952,7 +952,8 @@ static int start_systemd_journal_remote(sd_bus *bus, const char *scope, unsigned if (r < 0) return log_oom(); - ssp.exec_start = strv_new(sd_journal_remote, + ssp.exec_start = strv_new( + sd_journal_remote, "--output", arg_forward_journal, "--split-mode", endswith(arg_forward_journal, ".journal") ? "none" : "host"); if (!ssp.exec_start) @@ -962,8 +963,8 @@ static int start_systemd_journal_remote(sd_bus *bus, const char *scope, unsigned if (r < 0) return r; - if (listen_address) - *listen_address = TAKE_PTR(ssp.listen_address); + if (ret_listen_address) + *ret_listen_address = TAKE_PTR(ssp.listen_address); return 0; } From e8357737c649ab3f1e83d02f7c7870738ee63d5b Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 10 May 2024 11:36:24 +0900 Subject: [PATCH 2/2] vmspawn: fix finding systemd-journal-remote binary Follow-up for 258d26940fb6bfa1b5b8acf03cc4a37f2657e4ac. Fixes https://github.com/systemd/systemd/pull/31218#discussion_r1596168449. --- src/vmspawn/vmspawn.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index a5666459a34..4a6ef759a57 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -1923,7 +1923,15 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) { if (arg_forward_journal) { _cleanup_free_ char *sd_journal_remote = NULL, *listen_address = NULL, *cred = NULL; - r = find_executable("systemd-journal-remote", &sd_journal_remote); + + r = find_executable_full( + "systemd-journal-remote", + /* root = */ NULL, + STRV_MAKE(LIBEXECDIR), + /* use_path_envvar = */ true, /* systemd-journal-remote should be installed in + * LIBEXECDIR, but for supporting fancy setups. */ + &sd_journal_remote, + /* ret_fd = */ NULL); if (r < 0) return log_error_errno(r, "Failed to find systemd-journal-remote binary: %m");