History log of /lxc/src/lxc/log.c
Revision Date Author Comments Expand
c70748d1d5d1abf969aa25baca727b74c3a395d8 20-Mar-2017 Christian Brauner <christian.brauner@ubuntu.com>

log: fix lxc_unix_epoch_to_utc() The conversion algorithm used uses a clever trick by letting a year start at 1 March. So we need to add 1 for January and February. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

bfc42ff8c63894834cd73db245459904ef6b94b5 05-Jan-2017 Christian Brauner <christian.brauner@ubuntu.com>

tree-wide: Sic semper assertis! Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

6cd073a250a1d1a16beacaa5cb5e6512d3021482 01-Dec-2016 Stéphane Graber <stgraber@ubuntu.com>

Fix log.c for stable-2.0 logging style Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>

5267c49f0d845b1c5a2e676f7167eaeeb02728b1 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

log: make sure that date is correctly formatted - single digit months, days, hours, minutes, and seconds should always be preceded by a 0. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

8b79a8fec4127c754509d65faae1fe7f09515365 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

tree-wide: random macro cleanups Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

bb1957a5af68b71e01c357541c756a92c3224c90 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

log: annotate lxc_unix_epoch_to_utc() Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

1d3fef81ba303a1fa76c0a3f933d74285d6f8347 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

log: use lxc_unix_epoch_to_utc() This allows us to generate nice timestamps in a thread-safe manner without relying on locale touching functions from any libc. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

2bfafb07323e6111bc8a73d8868f9ab197289ea1 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

log: add lxc_unix_epoch_to_utc() Converts a unix time Epoch given by a struct timespec to a UTC string useable in our logging functions. Maybe expanded to allow for more generic formatting. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

624cec1cf1e69c506144c1b43a755a0b250173d0 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

log: drop all timezone conversion functions Our log functions need to make extra sure that they are thread-safe. We had some problems with that before. This especially involves time-conversion functions. I don't want to find any localtime() or gmtime() functions or relatives in here. Not even localtime_r() or gmtime_r() or relatives. They all fiddle with global variables and locking in various libcs. They cause deadlocks when liblxc is used multi-threaded and no matter how smart you think you are, you __will__ cause trouble using them. (As a short example how this can cause trouble: LXD uses forkstart to fork off a new process that runs the container. At the same time the go runtime LXD relies on does its own multi-threading thing which we can't control. The fork()ing + threading then seems to mess with the locking states in these time functions causing deadlocks.) The current solution is to be good old unix people and use the Epoch as our reference point and simply use the seconds and nanoseconds that have past since then. This relies on clock_gettime() which is explicitly marked MT-Safe with no restrictions! This way, anyone who is really strongly invested in getting the actual time the log entry was created, can just convert it for themselves. Our logging is mostly done for debugging purposes so don't try to make it pretty. Pretty might cost you thread-safety. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

82630da5bf617b78a841cad8df116b15845ec014 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

log: use N/A if getpid() != gettid() when threaded Sample log output: lxc 20161125201943.819 INFO lxc_start - start.c:lxc_check_inherited:243 - Closed inherited fd: 54. --> lxc N/A INFO lxc_monitor - monitor.c:lxc_monitor_sock_name:178 - using monitor sock name lxc/ad055575fe28ddd5//var/lib/lxc lxc 20161125201943.958 DEBUG lxc_commands - commands.c:lxc_cmd_handler:893 - peer has disconnected --> lxc N/A DEBUG lxc_commands - commands.c:lxc_cmd_get_state:579 - 'lxc-test-concurrent-0' is in 'RUNNING' state lxc 20161125201943.960 DEBUG lxc_commands - commands.c:lxc_cmd_handler:893 - peer has disconnected lxc 20161125201944.009 INFO lxc_start - start.c:lxc_check_inherited:243 - Closed inherited fd: 3. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

27e0a15145b9b8756de95b4dbcf5f01ec6dd2986 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

log: fix race localtime_r() can lead to deadlocks because it calls __tzset() and __tzconvert() internally. The deadlock stems from an interaction between these functions and the functions in monitor.c and commands.{c,h}. The latter functions will write to the log independent of the container thread that is currently running. Since the monitor fork()ed it seems to duplicate the mutex states of the time functions mentioned above causing the deadlock. As a short termm fix, I suggest to simply disable receiving the time when monitor.c or command.{c,h} functions are called. This should be ok, since the [lxc monitor] will only emit a few messages and thread-safety is currently more important than beautiful logs. The rest of the log stays the same as it was before. Here is an example output from logs where I printed the pid and tid of the process that is currently writing to the log: lxc 20161125170200.619 INFO lxc_start: 18695-18695: - start.c:lxc_check_inherited:243 - Closed inherited fd: 23. lxc 20161125170200.640 DEBUG lxc_start: 18677-18677: - start.c:__lxc_start:1334 - Not dropping CAP_SYS_BOOT or watching utmp. lxc 20161125170200.640 INFO lxc_cgroup: 18677-18677: - cgroups/cgroup.c:cgroup_init:68 - cgroup driver cgroupfs-ng initing for lxc-test-concurrent-0 ----------> lxc 20150427012246.000 INFO lxc_monitor: 13017-18622: - monitor.c:lxc_monitor_sock_name:178 - using monitor sock name lxc/ad055575fe28ddd5//var/lib/lxc lxc 20161125170200.662 DEBUG lxc_cgfsng: 18677-18677: - cgroups/cgfsng.c:filter_and_set_cpus:478 - No isolated cpus detected. lxc 20161125170200.662 DEBUG lxc_cgfsng: 18677-18677: - cgroups/cgfsng.c:handle_cpuset_hierarchy:648 - "cgroup.clone_children" was already set to "1". Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

31db998489b66029845d3dd5db92147702382a47 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

configure: check whether gettid() is declared Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

5b3214cabc793a51d9cdb0232a699c1530758f5e 01-Dec-2016 Christian Brauner <christian.brauner@ubuntu.com>

log: use thread-safe localtime_r() This fixes a race in liblxc logging which can lead to deadlocks. The reproducer for this issue before this is to simply compile with --enable-tests and then run: lxc-test-concurrent -j 20 -m create,start,stop,destroy -D which should deadlock. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

934ecd08fc4ecc116f6ec16f14a63cd740b392d0 26-Oct-2016 Lans Zhang <jia.zhang@windriver.com>

log: sanity check the returned value from snprintf() The returned value from snprintf() should be checked carefully. This bug can be leveraged to execute arbitrary code through carefully constructing the payload, e.g, lxc-freeze -n `python -c "print 'AAAAAAAA' + 'B'*959"` -P PADPAD -o /tmp/log This command running on Ubuntu 14.04 (x86-64) can cause a segment fault. Signed-off-by: Lans Zhang <jia.zhang@windriver.com>

28e42b622a53a382151b500a8342645b49136cd1 11-May-2016 Tycho Andersen <tycho.andersen@canonical.com>

log: remove duplicate definitons and bump buffer size When writing out the CRIU exec command, we're bumping up against the buffer size limit. Let's increase it so we can avoid: lxc 20160509213229.921 WARN lxc_log - log.c:log_append_logfile:111 - truncated next event from 523 to 512 bytes Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>

d9c9b1808af250ec37379c7f0242941a450aa3af 15-Feb-2016 Serge Hallyn <serge.hallyn@ubuntu.com>

log.c:__lxc_log_set_file: completely close log file when overriding Otherwise after a shortcut on error we could end up trying to write to the closed log fd. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

3f53c691d248434fdb817e615495d9c419af07d1 15-Feb-2016 Serge Hallyn <serge.hallyn@ubuntu.com>

log.c:__lxc_log_set_file: fname cannot be null fname cannot be passed in as NULL by any of its current callers. If it could, then build_dir() would crash as it doesn't check for it. So make sure we are warned if in the future we pass in NULL. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

d16ccca80f1e3416d353e82c2e02a833add054ba 03-Dec-2015 Tycho Andersen <tycho.andersen@canonical.com>

log: use the right size for timestamp formatting v2: get rid of extra debug crap Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

479bba8b318a9a6a5cf79a57461ac5ec226a1560 13-Aug-2015 Michal Grzedzicki <lazy404@gmail.com>

Only use LOGPATH if lxcpath is unset or default Signed-off-by: Michał Grzędzicki <lazy404@gmail.com>

02d25a9ea585a858db477b7966a369c71434fbad 25-May-2015 Stéphane Graber <stgraber@ubuntu.com>

Easy to read tiemstamp in log Signed-off-by: Gyeongmin Kim <gyeongmintwo@gmail.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

858377e4d968c8a7254e22dc7167acf76ac91a48 22-Apr-2015 Serge Hallyn <serge.hallyn@ubuntu.com>

logs: introduce a thread-local 'current' lxc_config (v2) The logging code uses a global log_fd and log_level to direct logging (ERROR(), etc). While the container configuration file allows for lxc.loglevel and lxc.logfile, those are only used at configuration file read time to set the global variables. This works ok in the lxc front-end programs, but becomes a problem with threaded API users. The simplest solution would be to not allow per-container configuration files, but it'd be nice to avoid that. Passing a logfd or lxc_conf into every ERROR/INFO/etc call is "possible", but would be a huge complication as there are many functions, including struct member functions and callbacks, which don't have that info and would need to get it from somewhere. So the approach I'm taking here is to say that all real container work is done inside api calls, and therefore the API calls themselves can set a thread-local variable indicating which log info to use. If unset, then use the global values. The lxc-* programs, when called with a '-o logfile' argument, set a global variable to indicate that the user-specified value should be used. In this patch: If the lxc container configuration specifies a loglevel/logfile, only set the lxc_config's logfd and loglevel according to those, not the global values. Each API call is wrapped to set/unset the current_config. (The few exceptions are calls which do not result in any log actions) Update logfile appender to use the logfile specified in lxc_conf if (a) current_config is set and (b) the lxc-* command did not override it. Changelog (2015-04-21): . always re-set current_config to NULL at end of an API call, rather than storing the previous value. We don't nest API calls. . remove the log_lock stuff which wasn't used . lxc_conf_free: if the config is current_config, set current_config to NULL. (It can't be another thread's current_config, or we wouldn't be freeing it) . lxc_check_inherited: don't close fd if it is the current_config->logfd. Note this is only called when starting a container, so we have no other threads at this point. Changelog (2015-04-22) . Unset the per-container logfd on destroy . . Do so before we rm the containerdir. Otherwise if the logfile is set . to $lxcpath/$name/log, the containerdir won't be fully deleted. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

a16f71a1d10ba626eb87297b0391b03b54de76e9 14-Apr-2015 Serge Hallyn <serge.hallyn@ubuntu.com>

Revert (by hand) "logs: introduce a thread-local 'current' lxc_config" This is hopefully temporary - it works great for lxc itself, but seems to be upsetting golang. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Tested-by: Tycho Andersen <tycho.andersen@canonical.com>

42e56013ea756be668e6c74d3f45c72ee450a527 06-Apr-2015 Serge Hallyn <serge.hallyn@ubuntu.com>

logs: introduce a thread-local 'current' lxc_config The logging code uses a global log_fd and log_level to direct logging (ERROR(), etc). While the container configuration file allows for lxc.loglevel and lxc.logfile, those are only used at configuration file read time to set the global variables. This works ok in the lxc front-end programs, but becomes a problem with threaded API users. The simplest solution would be to not allow per-container configuration files, but it'd be nice to avoid that. Passing a logfd or lxc_conf into every ERROR/INFO/etc call is "possible", but would be a huge complication as there are many functions, including struct member functions and callbacks, which don't have that info and would need to get it from somewhere. So the approach I'm taking here is to say that all real container work is done inside api calls, and therefore the API calls themselves can set a thread-local variable indicating which log info to use. If unset, then use the global values. The lxc-* programs, when called with a '-o logfile' argument, set a global variable to indicate that the user-specified value should be used. In this patch: If the lxc container configuration specifies a loglevel/logfile, only set the lxc_config's logfd and loglevel according to those, not the global values. Each API call is wrapped to set/unset the current_config. (The few exceptions are calls which do not result in any log actions) Update logfile appender to use the logfile specified in lxc_conf if (a) current_config is set and (b) the lxc-* command did not override it. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

ec64264d78d4ed608553842ce9e1f07eeab2a032 05-Dec-2014 Veres Lajos <vlajos@gmail.com>

typofixes - https://github.com/vlajos/misspell_fixer Signed-off-by: Veres Lajos <vlajos@gmail.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

8479c136351f7e369db410368fca784c40e4e4c6 04-Dec-2014 S.Çağlar Onur < <caglar@10ur.org>

rmdir and lxc_unpriv returns non-negative error codes Signed-off-by: S.Çağlar Onur <caglar@10ur.org> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

15bc516ea987be2fa3c085010d2e77a32820769c 29-Sep-2014 Serge Hallyn <serge.hallyn@ubuntu.com>

add file/func/line to debug info Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

01db0197519289988a81ea71a2e99fb3fd24e592 19-Sep-2014 William Dauchy <william@gandi.net>

log: fix quiet mode quiet mode was overriden by the double call of lxc_log_init see lxc_container_new use lxc_log_options_no_override in order to fix this Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: William Dauchy <william@gandi.net>

361e0e3c08fa9f0bb0ff782fc30d52f391ebfaa1 22-Aug-2014 S.Çağlar Onur < <caglar@10ur.org>

use lxcpath as unprivileged containers log directory Signed-off-by: S.Çağlar Onur <caglar@10ur.org> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

36eaa694151aff72a74987034d5f0eeb4261951c 07-Mar-2014 Dwight Engen <dwight.engen@oracle.com>

fix fd leak in test-concurrent Opening a debug log for every thread at every iteration of test-concurrent causes it to quickly run out of fd's because this fd is leaked. Fix this by adding a new api: lxc_log_close(). As Caglar noted, the log handling is in general a bit "interesting" because a logfile can be opened through the per-container api c->set_config_item("lxc.logfile") but lxc_log_fd is now per-thread data. It just so happens in test-concurrent that there is a 1:1 mapping of threads to logfiles. Split out getting debug logs from quiet since I think they are useful separately. If debug is specified, get a log of any mode, not just during start. Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

9f4f402a0ea27e4c66dc868ab3716eaeccaff461 07-Mar-2014 S.Çağlar Onur < <caglar@10ur.org>

add shared lxc_log_fd into TLS Signed-off-by: S.Çağlar Onur <caglar@10ur.org> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

dc5406bbbd6d3a76c367082dcee7941d7cfb0e43 07-Mar-2014 S.Çağlar Onur < <caglar@10ur.org>

put shared variables into thread-local storage This doesn't solve the general design problem of the log.c (eg; some log lines got lost or scattered into multiple files) but at least prevent multithreaded code from crashing. Before this change something like following; sudo src/tests/lxc-test-concurrent -i 10 -j 20 was crashing nearly all the time due to 3afbcc4600a as we started to set lxc.loglevel and lxc.logfile with that commit. Signed-off-by: S.Çağlar Onur <caglar@10ur.org> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

af61c481f5b229f8015eb129c0e19bbd3c992064 12-Feb-2014 Stéphane Graber <stgraber@ubuntu.com>

coverity: Drop dead code Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

74f052ddfb9dc6f1f61b2d4557536c4c84f116c7 07-Feb-2014 Stéphane Graber <stgraber@ubuntu.com>

log: Don't crash when name is NULL This fixes a crash in lxc-autostart following the addition of lxc_log_init as lxc-autostart doesn't use the name property. Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

6edbfc86508fb07d2b8377dce40f36f3032c32a5 05-Feb-2014 Stéphane Graber <stgraber@ubuntu.com>

logging: Add lxc_log_options_no_override function 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. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

ceceea1e967453d513484516aab4593f21cdbd89 15-Jan-2014 Stéphane Graber <stgraber@ubuntu.com>

Disable logpath for unprivileged containers Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

593e84786e2b4709059989bee489deab5c923779 10-Jan-2014 Stéphane Graber <stgraber@ubuntu.com>

Re-organize API for global lxc.conf config Instead of having one function for each possible key in lxc.conf which doesn't really scale and requires an API update for every new key, switch to a generic lxc_get_global_config_item() function which takes a key name as argument. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

dd1d77f91b3eb5b9b02f97d81c6c1c6c29563c03 24-Dec-2013 Andrey Mazo <mazo@telum.ru>

Remove process_lock() except where actually needed Functions like open(), close(), socket(), socketpair(), pipe() and mkdir() are generally thin wrappers around kernel-provided system calls. It's the kernel not libc, who ensures race-free handling of file descriptors. Thus locking around these functions is unnecessary even on somewhat buggy libcs. fopen(), fclose() and other stdio functions may maintain internal lists of open file handles and thus can be prone to race-conditions. Hopefully, most libcs utilize proper locking or other ways to ensure thread-safety of these functions. Bionic used to have non-thread-safe stdio [2] but that must be fixed since android 4.3 [3, 4]. S.Çağlar Onur showed [1] that openpty() (because of nsswitch) is not thread-safe though. So we workaround it by protecting openpty() calls with process_lock()/process_unlock(). Because of the need to guard openpty() with process_lock()/process_unlock(), process_unlock() is still used after fork(). This commit reverts most of 025ed0f3911836b71f498d8368725c77a7e1932a. [1] https://github.com/lxc/lxc/pull/106#issuecomment-31077269 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=687367 [3] https://android.googlesource.com/platform/bionic/+/f582340a6a48588aa50da17e1620e8f91b146941 [4] https://android.googlesource.com/platform/bionic/+/6b3f49a5374305ce9690c3c5ca2aadc90f54c521 Signed-off-by: Andrey Mazo <mazo@telum.ru> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

b12e1cb533be198ee71d9e517ab816617279e537 04-Nov-2013 S.Çağlar Onur < <caglar@10ur.org>

allow setting/getting lxc.loglevel and lxc.logfile via set_config_item/get_config_item API calls Signed-off-by: S.Çağlar Onur <caglar@10ur.org> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

97c94afb5758366f5a49536c97e1dcd34c9760d9 24-Oct-2013 Stéphane Graber <stgraber@ubuntu.com>

Fix build failure on sparc Signed-off-by: Thomas Nemeth <thomas.nemeth@laposte.net> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

025ed0f3911836b71f498d8368725c77a7e1932a 18-Sep-2013 Serge Hallyn <serge.hallyn@ubuntu.com>

make heavier use of process_lock (v2) pthread_mutex_lock() will only return an error if it was set to PTHREAD_MUTEX_ERRORCHECK and we are recursively calling it (and would otherwise have deadlocked). If that's the case then log a message for future debugging and exit. Trying to "recover" is nonsense at that point. process_lock() was held over too long a time in lxcapi_start() in the daemonize case. (note the non-daemonized case still needs a check to enforce that it must NOT be called while threaded). Add process_lock() at least across all open/close/socket() calls. Anything done after a fork() doesn't need the locks as it is no longer threaded - so some open/close/dups()s are not locked for that reason. However, some common functions are called from both threaded and non-threaded contexts. So after doing a fork(), do a possibly-extraneous process_unlock() to make sure that, if we were forked while pthread mutex was held, we aren't deadlocked by nobody. Tested that lp:~serge-hallyn/+junk/lxc-test still works with this patch. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Tested-by: S.Çağlar Onur <caglar@10ur.org> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

250b1eec71b074acdff1c5f6b5a1f0d7d2c20b77 03-Sep-2013 Stéphane Graber <stgraber@ubuntu.com>

licensing: Add missing headers and FSF address Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>

/lxc/autogen.sh /lxc/doc/common_options.sgml.in /lxc/doc/legacy/lxc-ls.sgml.in /lxc/doc/lxc-attach.sgml.in /lxc/doc/lxc-cgroup.sgml.in /lxc/doc/lxc-checkconfig.sgml.in /lxc/doc/lxc-checkpoint.sgml.in /lxc/doc/lxc-clone.sgml.in /lxc/doc/lxc-console.sgml.in /lxc/doc/lxc-create.sgml.in /lxc/doc/lxc-destroy.sgml.in /lxc/doc/lxc-device.sgml.in /lxc/doc/lxc-execute.sgml.in /lxc/doc/lxc-freeze.sgml.in /lxc/doc/lxc-info.sgml.in /lxc/doc/lxc-kill.sgml.in /lxc/doc/lxc-ls.sgml.in /lxc/doc/lxc-monitor.sgml.in /lxc/doc/lxc-netstat.sgml.in /lxc/doc/lxc-ps.sgml.in /lxc/doc/lxc-restart.sgml.in /lxc/doc/lxc-start-ephemeral.sgml.in /lxc/doc/lxc-start.sgml.in /lxc/doc/lxc-stop.sgml.in /lxc/doc/lxc-top.sgml.in /lxc/doc/lxc-unfreeze.sgml.in /lxc/doc/lxc-unshare.sgml.in /lxc/doc/lxc-version.sgml.in /lxc/doc/lxc-wait.sgml.in /lxc/doc/lxc.conf.sgml.in /lxc/doc/lxc.sgml.in /lxc/doc/see_also.sgml.in /lxc/hooks/mountcgroups /lxc/hooks/mountecryptfsroot /lxc/lxc.spec.in /lxc/runapitests.sh /lxc/src/include/getline.c /lxc/src/include/getline.h /lxc/src/include/lxcmntent.c /lxc/src/include/lxcmntent.h /lxc/src/include/openpty.c /lxc/src/include/openpty.h af_unix.c af_unix.h apparmor.c apparmor.h arguments.c arguments.h attach.c attach.h attach_options.h bdev.c bdev.h caps.c caps.h cgroup.c cgroup.h checkpoint.c commands.c commands.h conf.c conf.h confile.c confile.h console.c console.h error.c error.h execute.c freezer.c genl.c genl.h legacy/lxc-ls.in list.c list.h log.c log.h lxc-destroy.in lxc-device lxc-ls lxc-netstat.in lxc-ps.in lxc-start-ephemeral.in lxc.functions.in lxc.h lxc_attach.c lxc_cgroup.c lxc_checkpoint.c lxc_config.c lxc_console.c lxc_execute.c lxc_freeze.c lxc_info.c lxc_init.c lxc_kill.c lxc_monitor.c lxc_monitord.c lxc_restart.c lxc_start.c lxc_stop.c lxc_unfreeze.c lxc_unshare.c lxc_usernsexec.c lxc_wait.c lxccontainer.h lxcseccomp.h lxcutmp.c lxcutmp.h mainloop.c mainloop.h monitor.c monitor.h namespace.c namespace.h network.c network.h nl.c nl.h parse.c parse.h restart.c rtnl.c rtnl.h seccomp.c start.c start.h state.c state.h sync.c sync.h utils.c utils.h version.c version.h /lxc/src/python-lxc/examples/api_test.py /lxc/src/python-lxc/examples/pyconsole-vte.py /lxc/src/python-lxc/examples/pyconsole.py /lxc/src/python-lxc/lxc.c /lxc/src/python-lxc/lxc/__init__.py /lxc/src/python-lxc/setup.py /lxc/src/tests/lxc-test-usernic /lxc/templates/lxc-altlinux.in /lxc/templates/lxc-archlinux.in /lxc/templates/lxc-busybox.in /lxc/templates/lxc-debian.in /lxc/templates/lxc-fedora.in /lxc/templates/lxc-opensuse.in /lxc/templates/lxc-oracle.in /lxc/templates/lxc-sshd.in
fabf7361da4845cd6cf268e0e85c3c6a1c0b0be4 10-Jun-2013 Qiang Huang <h.huangqiang@huawei.com>

lxc-execute: allow lxc-init to log only when we have a valid log level Right now if we use lxc-execute without log level set, we get error: lxc: invalid log priority NOTSET. Because we set log level manually in execute_start(), but didn't check if we have a valid log level or not, so fix it. Signed-off-by: Qiang Huang <h.huangqiang@huawei.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

e0b0b533feed683ce12c94e11174019a5dac64fc 02-May-2013 Dwight Engen <dwight.engen@oracle.com>

allow lxc-init to log when rootfs not given On Mon, 29 Apr 2013 14:44:47 -0500 Serge Hallyn <serge.hallyn@ubuntu.com> wrote: > Quoting Dwight Engen (dwight.engen@oracle.com): > > So I did this, only to realize that lxc-init is passing "none" for > > the file anyway, so it currently doesn't intend to log. This makes > > me think that passing NULL for lxcpath is the right thing to do in > > this patch. If you want me to make it so lxc-init can log, I can do > > that but I think it should be in a different change :) > > That actually would be very useful, but as you say that's a different > feature - thanks. ... and here is said change. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

ee25a44fd389ed450e3d7ef9513eec19668f2de7 30-Apr-2013 Dwight Engen <dwight.engen@oracle.com>

log.c: always use dir when lxcpath is not default Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

ab1bf971d2db43777cbf3892fb887bf71ce7d155 30-Apr-2013 Dwight Engen <dwight.engen@oracle.com>

Create log file in lxcpath for non-system containers On Fri, 26 Apr 2013 10:18:12 -0500 Serge Hallyn <serge.hallyn@ubuntu.com> wrote: > Quoting Dwight Engen (dwight.engen@oracle.com): > > On Fri, 26 Apr 2013 09:37:49 -0500 > > Serge Hallyn <serge.hallyn@ubuntu.com> wrote: > > > > > Quoting Dwight Engen (dwight.engen@oracle.com): > > > > Using lxc configured with --enable-configpath-log, and > > > > specifying a path to the lxc commands with -P, the log file > > > > path is generated with a basename of LOGPATH instead of the > > > > lxcpath. This means for example if you do > > > > > > > > lxc-start -P /tmp/containers -n test01 -l INFO > > > > > > > > your log file will be > > > > > > > > /var/lib/lxc/test01/test01.log > > > > > > > > I was expecting the log to be /tmp/containers/test01/test01.log. > > > > This is particularly confusing if you also have test01 on the > > > > regular lxcpath. The patch below changes the log file path to be > > > > based on lxcpath rather than LOGPATH when lxc is configured with > > > > --enable-configpath-log. > > > > > > > > I think that even in the normal non --enable-configpath-log case > > > > we should consider using lxcpath as the base and not having > > > > LOGPATH at all, as attempting to create the log files > > > > in /var/log is not going to work for regular users on their own > > > > lxcpath. If we want that, I'll update the patch to do that as > > > > well. > > > > > > > > > Perhaps we should do: > > > > > > 1. If lxcpath == default_lxc_path(), then first choice is > > > LOGPATH, second is lxcpath/container.log > > > 2. when opening, if first choice fails, use second choice > > > if there is any. > > > > > > That way 'system' containers will go to /var/log/lxc, as I think > > > they should. Custom-lxcpath containers should never go > > > to /var/log/lxc, since their names could be dups of containers in > > > default_lxc_path(). And if the system is a weird one where > > > default_lxc_path is set up so that an unprivileged user can use > > > it, then we should log into $lxcpath. > > > > That sounds good to me. So these rules would apply in both the > > regular and --enable-configpath-log cases. I updated the patch to try to open the log file according to the choices given above. Along the way I cleaned up log.c a bit, making some things static, grouping external interfaces together, etc... Hopefully that doesn't add too much noise. > > > (Note this patch will trivially conflict with my new lxc_clone.c > > > causing it to fail to build - unfortunate result of timing) > > > > Yeah unfortunately this touches every lxc_log_init() caller. I can > > work on the above logic and re-submit after your new lxc_clone > > stuff goes in. > > No no, I'll just need to remember to update mine. Don't hold up on > mine, this is just the nature of such collaboration :) > > > Did you have any thoughts on the XXX what to pass in for lxcpath in > > lxc_init? Right now it just falls back to LOGPATH. > > No - that's a weird one, since lxc_init runs in the container. If > there were only system containers I'd say always use LOGPATH. > However there are people (apparently :) who use container sharing the > host's rootfs... > > lxc-execute does know the lxcpath. Perhaps we can simply have > src/lxc/execute.c:execute_start() look at handler->conf to see if a > rootfs is set. If rootfs is NOT set, then pass lxcpath along to > lxc-init. Then lxc-init can mostly do the same as the others? (It > doesn't use src/lxc/arguments.c, so you'd have to add lxcpath to > options[] in lxc-init.c) So I did this, only to realize that lxc-init is passing "none" for the file anyway, so it currently doesn't intend to log. This makes me think that passing NULL for lxcpath is the right thing to do in this patch. If you want me to make it so lxc-init can log, I can do that but I think it should be in a different change :) -- Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

e6a19d2683629888175371ed2eeb8a49a7b44873 16-Apr-2013 Dwight Engen <dwight.engen@oracle.com>

fortify: minor cleanups for unused variables, stricter types Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

fbf5de31e3ba14226e30602fb21a50d3cca8db9f 19-Feb-2013 Stéphane Graber <stgraber@ubuntu.com>

Fix typos identified by lintian Lintian spotted those two typos. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

5e1e7aaf1e244405b813c0f9e20db2fc9e7f4d10 28-Jan-2013 Serge Hallyn <serge.hallyn@canonical.com>

use a default per-container logfile Until now, if a lxc-* (i.e. lxc-start) command did not specify a logfile (with -o logfile), the default was effectively 'none'. With this patch, the default becomes a per-container log file. If a container config file specifies 'lxc.logfile', that will override the default. If a '-o logfile' argument is specifed at lxc-start, then that will override both the default and the configuration file entry. Finally, '-o none' can be used to avoid having a logfile at all (in other words, the previous default), and that will override a lxc.logfile entry in the container configuration file. If the user does not have rights to open the default, then 'none' will be used. However, in that case an error will show up on console. (We can work on removing that if it annoys people, but I think it is helpful, at least while we're still ironing this set out) If the user or container configuration file specified a logfile, and the user does not have rights to open the default, then the action will fail. One slight "mis-behavior" which I have not fixed (and may not fix) is that if a lxc.logfile is specified, the default logfile will still get created before we read the configuration file to find out there is a lxc.logfile entry. changelog: Jan 24: add --enable-configpath-log configure option When we log to /var/lib/lxc/$container/$container.log, several things need to be done differently than when we log into /var/log/lxc (for instance). So give it a configure option so we know what to do When the user specifies a logfile, we bail if we can't open it. But when opening the default logfile, the user may not have rights to open it, so in that case ignore it and continue as if using 'none'. When using /var/lib/lxc/$c/$c.log, we use $LOGPATH/$name/$name.log. Otherwise, we use $LOGPATH/$name.log. When using /var/lib/lxc/$c/$c.log, don't try to create the log path /var/lib/lxc/$c. It can only not exist if the container doesn't exist. We don't want to create the directory in that case. When using /var/log/lxc, then we do want to create the path if it does not exist. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

e6cde7418c4e697876f0041b888766ab4732812b 23-Jan-2013 Stéphane Graber <stgraber@ubuntu.com>

Revert "use a default per-container logfile" The logfile changes broke lxc-info and possibly more command line tools. Revert for now until we get those issues addressed. This reverts commit 74476cf144523530022d76cef3a558b0662b592f.

b02bbfacd76a7653a2f985bbefb580a44cbeb562 23-Jan-2013 Stéphane Graber <stgraber@ubuntu.com>

Revert "use a default per-container logfile" The logfile changes broke lxc-info and possibly more command line tools. Revert for now until we get those issues addressed. This reverts commit b8e0503a1d1dbf3a508bf6f34521606ba231b1fe.

b8e0503a1d1dbf3a508bf6f34521606ba231b1fe 22-Jan-2013 Serge Hallyn <serge.hallyn@canonical.com>

use a default per-container logfile log_open: make sure the parent directory for logfiles Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

74476cf144523530022d76cef3a558b0662b592f 22-Jan-2013 Serge Hallyn <serge.hallyn@canonical.com>

use a default per-container logfile [ Thanks to Stéphane and Dwight for the feedback on the previous patch ] Until now, if a lxc-* (i.e. lxc-start) command did not specify a logfile (with -o logfile), the default was effectively 'none'. With this patch, the default becomes $LOGPATH/<container>/<container>.log. LOGPATH is specified at configure time with '--with-log-path='. If unspecified, it is $LXCPATH, so that logs for container r2 will show up at /var/lib/lxc/r2/r2/log. LOGPATH must exist, while lxc will make sure to create $LOGPATH/<name>. As another example, Ubuntu will likely specify --with-log-path=/var/log/lxc (and place /var/log/lxc into debian/lxc.dirs), placing r2's logs in /var/log/lxc/r2/r2.log. If a container config file specifies 'lxc.logfile', that will override the default. If a '-o logfile' argument is specifed at lxc-start, then that will override both the default and the configuration file entry. Finally, '-o none' can be used to avoid having a logfile at all (in other words, the previous default), and that will override a lxc.logfile entry in the container configuration file. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

9ea87d5dedf7b56eb7eeb20b0da2252d9a1087b1 14-Jan-2013 Serge Hallyn <serge.hallyn@ubuntu.com>

remove logfile and loglevel from struct lxc_conf The options are still supported in the lxc configuration file. However they are stored only in local variables in src/lxc/log.c, which can be read using two new functions: int lxc_log_get_level(void); const char *lxc_log_get_file(void); Changelog: jan 14: have lxc_log_init use lxc_log_set_file(), have lxc_log_set_file() take a const char *, and have it keep its own strdup'd copy of the filename. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>

4a85ce2ad0d0b24680712c60a6576713d209b7ad 04-Dec-2012 Serge Hallyn <serge.hallyn@ubuntu.com>

lxc_conf logfile and loglevel support Add 'lxc.logfile' and 'lxc.loglevel' config items. Values provided on the command line override the config items. Have lxccontainer not set a default loglevel and logfile. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>

2312f31b07690c18ce1b910803ef3f6f7e588f05 26-Nov-2012 Dwight Engen <dwight.engen@oracle.com>

Fix fd leak in lxc log lxc_log_init will leak an fd when it is called by a long running program that may call lxc_container_new multiple times. Fix by only opening the log if it is not already open. Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

25df6b78d2d013ee12e63ca80db3e572d89dcd6c 06-Apr-2011 Greg Kurz <gkurz@fr.ibm.com>

lxc: default log appender on stderr The default appender for logs is currently the file one: this make macros from log.h unusable as long as lxc_log_init() hasn't been called. This prevents errors from even being printed on stderr in lxc_caps_init() for example. Let's make stderr the default appender. Signed-off-by: Greg Kurz <gkurz@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

28f602ff477f5e5e924f2b931c6034b7df9e9851 20-Jul-2010 Daniel Lezcano <dlezcano@fr.ibm.com>

fix log appending to any file With the capabilities, the open of the log file can be done on any file, making possible to modifify the content of the file. Let's drop the privilege when opening the file, so we ensure that is no longer possible. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

441e49639508dce2a3fd94dabe5f40fead110ebf 18-May-2009 Michel Normand <normand@fr.ibm.com>

add quiet option This added quiet option allow to disable the reporting via stderr of the lxc error messages. Note that the usage function is still printing in case of error, but will be removed by later patches Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

d737c0749582e05e29a6da8c177cc21515ddb50e 15-May-2009 Michel Normand <normand@fr.ibm.com>

add a default stderror log appender This is adding a stderror log appender that is used as default one. Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

5fd8380be601c9f82708096a90a554d37f07b949 15-May-2009 Michel Normand <normand@fr.ibm.com>

properly handle va_list in log_append functions the support of multiple appenders need to associate one va_list per appender. This is the purpose of this patch to copy the va_list before to call the appender. Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

51cab6315f1500af5105cfbf56cc03b2ceefa0d9 14-May-2009 Michel Normand <normand@fr.ibm.com>

add support of a lxc log file to cli this is adding -o and -l options to all cli of lxc Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

6b9f39176cc9d898d339f8344291b922bfde19a8 26-Apr-2009 Daniel Lezcano <dlezcano@fr.ibm.com>

Revert "make the log fd thread safe" This reverts commit 2c9bd0073f29573181dc16a840c674dacc8a33fd. Pointless and useless right now and certainly wrong as several threads in the library may want to log to the same, to be defined later.

e0b4037dfad4676d977c147426657fc1406efd2f 24-Apr-2009 Daniel Lezcano <daniel.lezcano@free.fr>

add the missing header in the log file License header is missing in the log files. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

eabbb2f0c0cc1c0fe15efef514cc37e4c60725ae 24-Apr-2009 Michel Normand <normand@fr.ibm.com>

locally define O_CLOEXEC this is a required patch to be able to compile lxc on a RedHat 5 update 1 which has such define. This is also required for the F_DUPFD_CLOEXEC define Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

2c9bd0073f29573181dc16a840c674dacc8a33fd 21-Apr-2009 Daniel Lezcano <daniel.lezcano@free.fr>

make the log fd thread safe Add the tls attribute for the global static variables in the logs. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

dcb7355b2fa4bd63c1d015a943b3d54264709083 21-Apr-2009 Cedric Le Goater <legoater@free.fr>

lxc: cleanup log some headers and macros are now redundant Signed-off-by: Cedric Le Goater <legoater@free.fr> Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

cb8c5720bdd14249e66060cda0e0f5d2f95c0ecd 21-Apr-2009 Cedric Le Goater <legoater@free.fr>

lxc: introduce log4c style logging lxc_log_init() should be called in each main() of a command to define the default log priority and log file. Signed-off-by: Cedric Le Goater <legoater@free.fr> Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>

731cc33fb7e75085e4281f295c6c9d806f8d3ad5 30-Mar-2009 Daniel Lezcano <daniel.lezcano@free.fr>

cleanup log.h Rename lxc_log.h to log.h Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>