[lxc-devel] [PATCH] Remove /dev/kmsg symlinking.

Alexander Vladimirov alexander.idkfa.vladimirov at gmail.com
Mon Jan 7 15:31:08 UTC 2013


process_event function in journald
(http://cgit.freedesktop.org/systemd/systemd/tree/src/journal/journald-server.c#n987)
handles events differently depending on descriptor type.
Debugging with gdb showed that /dev/kmsg being a symlink triggers
"invalid event" error at line 1032
(http://cgit.freedesktop.org/systemd/systemd/tree/src/journal/journald-server.c#n1032)
and terminates journald immediately.
I asked about that error on #systemd and Kay told me that symlinking
is wrong because /dev/kmsg has specific semantics, that cannot be
reproduced by /dev/console symlink. Journald has config option to
forward messages to console other way around and other logging systems
should be able to do that too.

2013/1/7 Serge Hallyn <serge.hallyn at canonical.com>:
> Quoting Alexander Vladimirov (alexander.idkfa.vladimirov at gmail.com):
>> Symlink cannot resemble /dev/kmsg semantics, so symlinking it is wrong.
>
> Hm.  It works fine in my containers, and gives me nice startup messages
> on console.
>
>> Guests probably should not use /dev/kmsg at all.
>> Fixes journald crashes and journal corruption in systemd guests.
>
> Can you show exactly what causes the crashes?
>
> I'm not entirely opposed, since eventually (probably soon) we'll
> (at least conditionally) remove it anyway, when /dev/kmsg can be
> protected by user namespace (or even better be namespaced in
> syslogns).
>
> -serge
>
>
>> ---
>>  src/lxc/conf.c | 30 ------------------------------
>>  1 file changed, 30 deletions(-)
>>
>> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
>> index 4f041dc..85d72c9 100644
>> --- a/src/lxc/conf.c
>> +++ b/src/lxc/conf.c
>> @@ -1313,33 +1313,6 @@ static int setup_console(const struct lxc_rootfs *rootfs,
>>       return setup_ttydir_console(rootfs, console, ttydir);
>>  }
>>
>> -static int setup_kmsg(const struct lxc_rootfs *rootfs,
>> -                    const struct lxc_console *console)
>> -{
>> -     char kpath[MAXPATHLEN];
>> -     int ret;
>> -
>> -     if (!rootfs->path)
>> -             return 0;
>> -     ret = snprintf(kpath, sizeof(kpath), "%s/dev/kmsg", rootfs->mount);
>> -     if (ret < 0 || ret >= sizeof(kpath))
>> -             return -1;
>> -
>> -     ret = unlink(kpath);
>> -     if (ret && errno != ENOENT) {
>> -             SYSERROR("error unlinking %s\n", kpath);
>> -             return -1;
>> -     }
>> -
>> -     ret = symlink("console", kpath);
>> -     if (ret) {
>> -             SYSERROR("failed to create symlink for kmsg");
>> -             return -1;
>> -     }
>> -
>> -     return 0;
>> -}
>> -
>>  int setup_cgroup(const char *name, struct lxc_list *cgroups)
>>  {
>>       struct lxc_list *iterator;
>> @@ -2566,9 +2539,6 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
>>               return -1;
>>       }
>>
>> -     if (setup_kmsg(&lxc_conf->rootfs, &lxc_conf->console))  // don't fail
>> -             ERROR("failed to setup kmsg for '%s'", name);
>> -
>>       if (setup_tty(&lxc_conf->rootfs, &lxc_conf->tty_info, lxc_conf->ttydir)) {
>>               ERROR("failed to setup the ttys for '%s'", name);
>>               return -1;
>> --
>> 1.8.1
>>
>>
>> ------------------------------------------------------------------------------
>> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
>> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
>> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
>> MVPs and experts. ON SALE this month only -- learn more at:
>> http://p.sf.net/sfu/learnmore_123012
>> _______________________________________________
>> Lxc-devel mailing list
>> Lxc-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list