[lxc-devel] [lxc/master] start: set loglevel correctly

brauner on Github lxc-bot at linuxcontainers.org
Tue Dec 5 23:18:34 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 568 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171205/ea0600c0/attachment.bin>
-------------- next part --------------
From 9c24e367bbf4715444748865933a68a1954ec0e3 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 6 Dec 2017 00:16:38 +0100
Subject: [PATCH] start: set loglevel correctly

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 at nvidia.com>
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/start.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index a6bb80325..00510ce21 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -572,6 +572,7 @@ struct lxc_handler *lxc_init_handler(const char *name, struct lxc_conf *conf,
 
 int lxc_init(const char *name, struct lxc_handler *handler)
 {
+	char *loglevel;
 	struct lxc_conf *conf = handler->conf;
 
 	lsm_init();
@@ -612,8 +613,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");


More information about the lxc-devel mailing list