]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
start: set loglevel correctly
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Dec 2017 23:16:38 +0000 (00:16 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 11:44:28 +0000 (12:44 +0100)
We want the loglevel that the user specified when starting the container
because it overrides the default one set in the config.

Closes #2003.

Reported-by: Felix Abecassis <fabecassis@nvidia.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c

index 1231b42d90edf9d637f920c7b618fc4cd1587c1f..cb275860415435dae859c70c54fffb3cbb43d9a1 100644 (file)
@@ -595,6 +595,7 @@ on_error:
 
 int lxc_init(const char *name, struct lxc_handler *handler)
 {
+       const char *loglevel;
        struct lxc_conf *conf = handler->conf;
 
        lsm_init();
@@ -635,8 +636,9 @@ int lxc_init(const char *name, struct lxc_handler *handler)
        if (setenv("LXC_CGNS_AWARE", "1", 1))
                SYSERROR("Failed to set environment variable LXC_CGNS_AWARE=1.");
 
-       if (setenv("LXC_LOG_LEVEL", lxc_log_priority_to_string(handler->conf->loglevel), 1))
-               SYSERROR("Failed to set environment variable LXC_CGNS_AWARE=1.");
+       loglevel = lxc_log_priority_to_string(lxc_log_get_level());
+       if (setenv("LXC_LOG_LEVEL", loglevel, 1))
+               SYSERROR("Failed to set environment variable LXC_LOG_LEVEL=%s", loglevel);
        /* End of environment variable setup for hooks. */
 
        TRACE("set environment variables");