[lxc-devel] [PATCH] logging: Add lxc_log_options_no_override function

Serge Hallyn serge.hallyn at ubuntu.com
Tue Feb 4 21:53:48 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> In current LXC, loglevel and logfile are write-once functions.
> That behaviour was appropriate when those two were first introduced
> (pre-API) but with current API, one would expect to be able to
> set_config_item those multiple times.
> 
> So instead, introduce lxc_log_options_no_override which when called
> turns those two config keys read-only and have all existing binaries
> which use log_init call that function once they're done setting the
> value requested by the user.

Maybe I'm a bit to frazzled for this right now, but let's consider
the ways loglevel and logfile can be set:

. they can come from command-line to lxc-start etc

. they can come from a container configuration file

(anything else?)

So let's say we have have an api program which does:

	c1 = lxc_container_new("a1", NULL);
	c2 = lxc_container_new("a2", NULL);
	c1.start()

Let's say that c1 says lxc.loglevel=3 and c2 says lxc.loglevel=5.
In the above pathological example c1 will end up running with
lxc.loglevel=5 because we store the loglevel globally.

We don't always have a container available INFO() etc, so we can't
just move loglevel+loginfo into the container.

Perhaps the right thing to do is
. make loglevel and logfile per-thread
. store the lxc.loglevel from config file into c->loglevel, and NOT set
  it globally (in per-thread)
. at lxcapi_create and lxcapi_start, set the global loglevel to the
  c->loglevel (if defined), and reset at end.

-serge


More information about the lxc-devel mailing list