nspawn: add --forward-journal= and --forward-journal-*= options
Add --forward-journal=FILE|DIR to forward the container's journal
entries to the host via systemd-journal-remote. When specified,
nspawn starts systemd-journal-remote listening on a Unix socket,
bind-mounts it into the container at /run/host/journal/socket, and
passes a journal.forward_to_socket credential pointing to it.
Add --forward-journal-max-use=, --forward-journal-keep-free=,
--forward-journal-max-file-size=, and --forward-journal-max-files=
to configure disk usage limits for the forwarded journal.
Consolidate nspawn's per-machine on-disk state under a single runtime
directory at /run/systemd/nspawn/<machine>/. The container rootdir
mount point moves from /tmp/nspawn-root-XXXXXX to <runtime_dir>/root,
the unix-export directory moves from
/run/systemd/nspawn/unix-export/<machine> to <runtime_dir>/unix-export,
and the journal-remote socket lives at
<runtime_dir>/journal-remote-socket. Update ssh-generator and
ssh-proxy to follow the new unix-export path layout.
Extract fork_journal_remote() into fork-notify.{c,h} as a shared
helper used by both nspawn and vmspawn, replacing vmspawn's
start_systemd_journal_remote().
Extract runtime_directory_make() into path-lookup.{c,h} as a shared
helper used by both nspawn and vmspawn, replacing vmspawn's inline
runtime directory creation logic.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Daan De Meyer
parent
012d87c1fc
commit
cc8f398202
@@ -338,7 +338,7 @@ static int add_export_unix_socket(
|
||||
return r;
|
||||
|
||||
log_debug("Binding SSH to AF_UNIX socket /run/host/unix-export/ssh\n"
|
||||
"→ connect via 'ssh unix/run/systemd/nspawn/unix-export/\?\?\?/ssh' from host");
|
||||
"→ connect via 'ssh unix/run/systemd/nspawn/\?\?\?/unix-export/ssh' from host");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -349,11 +349,11 @@ static int process_machine(const char *machine, const char *port) {
|
||||
if (!streq_ptr(p.service, "systemd-nspawn"))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EMEDIUMTYPE), "Don't know how to SSH into '%s' container %s.", p.service, machine);
|
||||
|
||||
r = runtime_directory_generic(scope, "systemd/nspawn/unix-export", &path);
|
||||
r = runtime_directory_generic(scope, "systemd/nspawn", &path);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to determine runtime directory: %m");
|
||||
|
||||
if (!path_extend(&path, machine, "ssh"))
|
||||
if (!path_extend(&path, machine, "unix-export", "ssh"))
|
||||
return log_oom();
|
||||
|
||||
r = is_socket(path);
|
||||
|
||||
Reference in New Issue
Block a user