[systemd-devel] udevd and "quiet"

Colin Guthrie gmane at colin.guthr.ie
Mon Nov 10 12:48:11 PST 2014


Lennart Poettering wrote on 10/11/14 18:54:
> On Mon, 10.11.14 10:11, Colin Guthrie (gmane at colin.guthr.ie) wrote:
> 
>> Hi,
>>
>> Not sure how long this has been the case, but in a dracut initrd that is
>> NOT using systemd, udevd will print out "starting version 217" even when
>> "quiet" is used on the command line.
> 
> Hmm, that message is printed at LOG_INFO log level. "quiet" should
> normally turn that off, but leave LOG_NOTICE and worse shown.

Well according to:

shared/log.c:880:         * However, "quiet" is only parsed by PID 1!

it seems that "quiet" is only parsed by PID 1, so this shouldn't affect
udevd running on it's own outside of systemd as PID 1 (which can be the
case in dracut - slowly working towards systemd in dracut but haven't
got the time/energy to debug all the crazy disk configurations our
installer lets you imagine up...).

> Are you saying that doesn't work correctly?

It certainly appears not to work for udevd, and looking at the code in
src/udev/udevd.c makes this rather obvious.

Line 1119:
        log_set_target(LOG_TARGET_AUTO);
        log_parse_environment();
        log_open();

        udev_set_log_fn(udev, udev_main_log);
        log_set_max_level(udev_get_log_priority(udev));


So after setting the log level from the environment, we also set it from
udev_get_log_priority() which, since
2004d23a0fcaa6e74631057a2ff75594a038d86e will ultimately return LOG_INFO
if no other factors interfere.

So regardless of SYSTEMD_LOG_LEVEL environment var, the built in log
level will always override it, whether this is LOG_INFO or overridden by
/etc/udev/udev.conf or UDEV_LOG env var.

IMO this should be fixed. Probably the simplest fix that retains
backwards compatibility is this (untested) which honours
SYSTEMD_LOG_LEVEL but still prefers UDEV_LOG:

diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c
index b1649b6..127b85c 100644
--- a/src/libudev/libudev.c
+++ b/src/libudev/libudev.c
@@ -207,6 +207,8 @@ _public_ struct udev *udev_new(void)

         /* environment overrides config */
         env = secure_getenv("UDEV_LOG");
+        if (isempty(env))
+                env = secure_getenv("SYSTEMD_LOG_LEVEL");
         if (env != NULL) {
                 int prio;



But AFAICT all this still doesn't prevent "quiet" on the kernel command
line having zero effect on udevd's default log level :)

So either we teach udevd to parse quiet itself when setting it's default
log level or we simply fix dracut to set UDEV_LOG env var to ensure the
log level is set, as it expects, set to err (it could write a
/etc/udev/udev.conf but env var is easier). I posted such a dracut patch
to the initramfs at vger list earlier today.

http://thread.gmane.org/gmane.linux.kernel.initramfs/3879

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list