On Tue, Dec 17, 2013 at 08:06:39PM +0100, Lennart Poettering wrote:
> 
> But why? LXC should either provide a working /dev/kmsg or none at
> all. Providing something that doesn't work where we then have to check
> with a lot of code if they are playing games with us or not is not an
> option really, sorry.

In the meanwhile the default LXC setup has been changed by the LXC
people.  Nevertheless I'm fairly certain the I'll see an other report
about this difficulty especially  from experienced adminstrators using
their own LXC setup.

> Anyway, I suggested in my original reply that I'd be happy to merge a
> patch that downgrades the warning message to debug on ENOENT. I have now
> made such a change in git, and also added another change that closes
> /dev/kmsg if we cannot make use of it anyway.

See the attched patch.

> 
> (Also, log_warning() and friends save/restore errno internally. And
> instead of repeating destruction paths in all if branches is something
> we don't do. Use "goto" to some unified destruction path at the end of
> the call. And running non-trivial functions from if checks is also not
> that a good idea).

Maybe an other interface in libudev for checking common devices would
help a lot.

> Anyway, with the code now in git, is there still something left to do to
> make journald work nicely with a properly set up LXC for you?

Currently I've reports with journaling/compressing file systems in the case
systemd-journald is flushing its journal to /var/log/journal/<id>/system.journal
which causes high system load if the journal is listed with journalctl.

Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
From 83a217228a96fe4ff05ec3972838acfd261575a7 Mon Sep 17 00:00:00 2001
From: Werner Fink <[email protected]>
Date: Wed, 18 Dec 2013 15:03:55 +0100
Subject: [PATCH] Do not warn on not existing /dev/kmsg as in LXC
 environments. If the resulting file descriptor can not be
 polled simply close it.

---
 src/journal/journald-kmsg.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git src/journal/journald-kmsg.c src/journal/journald-kmsg.c
index bc42548..4d1f48f 100644
--- src/journal/journald-kmsg.c
+++ src/journal/journald-kmsg.c
@@ -398,13 +398,18 @@ int server_open_dev_kmsg(Server *s) {
 
         s->dev_kmsg_fd = open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
         if (s->dev_kmsg_fd < 0) {
-                log_warning("Failed to open /dev/kmsg, ignoring: %m");
+                /* Do not warn as it may not exists in e.g. LXC environments */
+                log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
+                         "Failed to open /dev/kmsg, ignoring: %m");
                 return 0;
         }
 
         r = sd_event_add_io(s->event, s->dev_kmsg_fd, EPOLLIN, dispatch_dev_kmsg, s, &s->dev_kmsg_event_source);
         if (r < 0) {
 
+                close_nointr_nofail(s->dev_kmsg_fd);
+                s->dev_kmsg_fd = -1;
+
                 /* This will fail with EPERM on older kernels where
                  * /dev/kmsg is not readable. */
                 if (r == -EPERM)
-- 
1.7.9.2

Attachment: pgpisiLSuzOAa.pgp
Description: PGP signature

_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to