[systemd-devel] [PATCH 0/7] Make "journalctl -M" work with journals inside overlayfs

Krzesimir Nowak krzesimir at endocode.com
Mon Jun 1 08:28:56 PDT 2015


Hi,

When having a container that keeps its journal inside overlayfs,
journalctl from host can't access them anymore. The way to fix, as
proposed by Lennart, was basically journalctl to get file descriptor
of journal directory from machined and go from there. This situation
happens inside rkt containers - currently to get logs from them, we
need to link the journal to host and call journalctl with merge flag,
journalctl -m _HOSTNAME=<machine-id>

So, first three commits are some fixes for minor bugs I noticed or
small refactorings I made during this work.

Fourth patch adds a GetJournal() method to machine1.Manager which
takes a machine name and returns a file descriptor. It works by
entering a mount namespace of machine's leader and getting a
descriptor of /var/log/journal.

Fifth and sixth patches convert the JournalFile from being open()ed
with a path to being openat()ed with dirfd and filename. The fifth
patch wraps the directory fd and path into a refcounted struct, so
many JournalFiles actually hold a ref to JournalDirectory instead of
holding a descriptor. The sixth patch changes the JournalFile to use
JournalDirectory and all the other sources that were using
JournalFile. The patch is quite big because of that, sorry about
that. Maybe you will want to minimize the changes (by preserving
JournalFile's path member).

Seventh patch hooks journalctl to machine1.Manager's GetJournal.

Krzesimir Nowak (7):
  nspawn, shared: Factor out sending and receiving fd
  nspawn: Close unneeded sockets in outer child
  nspawn, machined: Fix comments and error messages related to child
    failures
  machined: Add getter for machine's journal directory descriptor
  journal: Add JournalDirectory
  journal: Open JournalFile by dirfd and filename instead of path
  journal: Try getting journal fd from machined

 Makefile.am                                    |   4 +-
 src/journal-remote/journal-remote-write.c      |  12 +-
 src/journal-remote/journal-remote.c            |  34 ++-
 src/journal/journal-dir.c                      | 141 ++++++++++
 src/journal/journal-dir.h                      |  37 +++
 src/journal/journal-file.c                     | 108 +++----
 src/journal/journal-file.h                     |  10 +-
 src/journal/journal-internal.h                 |   3 +-
 src/journal/journal-vacuum.c                   |  27 +-
 src/journal/journal-vacuum.h                   |   3 +-
 src/journal/journal-verify.c                   |   4 +-
 src/journal/journalctl.c                       |   8 +-
 src/journal/journald-server.c                  | 113 +++++---
 src/journal/sd-journal.c                       | 376 ++++++++++++++++++-------
 src/journal/test-journal-flush.c               |  13 +-
 src/journal/test-journal-interleaving.c        |  55 ++--
 src/journal/test-journal-stream.c              |  10 +-
 src/journal/test-journal-verify.c              |  13 +-
 src/journal/test-journal.c                     |  21 +-
 src/machine/machine-dbus.c                     |  18 +-
 src/machine/machined-dbus.c                    | 112 ++++++++
 src/machine/org.freedesktop.machine1.policy.in |  10 +
 src/nspawn/nspawn.c                            |  72 +----
 src/shared/util.c                              |  76 +++++
 src/shared/util.h                              |   4 +
 25 files changed, 949 insertions(+), 335 deletions(-)
 create mode 100644 src/journal/journal-dir.c
 create mode 100644 src/journal/journal-dir.h

-- 
2.1.0



More information about the systemd-devel mailing list