Skip to content

Commit

Permalink
confile: namespace lxc.log keys
Browse files Browse the repository at this point in the history
* rename lxc.logfile to lxc.log.file
* renaem lxc.loglevel to lxc.log.level
* rename lxc.syslog to lxc.log.syslog

the legacy keys will be kept around until LXC 3.0 and then will be
removed.

Signed-off-by: 0x0916 <w@laoqinren.net>
  • Loading branch information
0x0916 committed Jun 30, 2017
1 parent 9dcf7b4 commit 46cc906
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 42 deletions.
10 changes: 5 additions & 5 deletions doc/ja/lxc.container.conf.sgml.in
Expand Up @@ -2410,7 +2410,7 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
<variablelist>
<varlistentry>
<term>
<option>lxc.loglevel</option>
<option>lxc.log.level</option>
</term>
<listitem>
<para>
Expand Down Expand Up @@ -2440,7 +2440,7 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
</varlistentry>
<varlistentry>
<term>
<option>lxc.logfile</option>
<option>lxc.log</option>
</term>
<listitem>
<para>
Expand All @@ -2453,17 +2453,17 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
</varlistentry>
<varlistentry>
<term>
<option>lxc.syslog</option>
<option>lxc.log.syslog</option>
</term>
<listitem>
<para>
<!--
Send logging info to syslog. It respects the log level defined in
<command>lxc.loglevel</command>. The argument should be the syslog
<command>lxc.log.level</command>. The argument should be the syslog
facility to use, valid ones are: daemon, local0, local1, local2,
local3, local4, local5, local5, local7.
-->
ログ情報を syslog に送ります。ログレベルとして <command>lxc.loglevel</command> の値を使用します。指定する値は使用する syslog の facility です。有効な値は daemon, local0, local1, local2, local3, local4, local5, local5, local6, local7 のいずれかです。
ログ情報を syslog に送ります。ログレベルとして <command>lxc.log.level</command> の値を使用します。指定する値は使用する syslog の facility です。有効な値は daemon, local0, local1, local2, local3, local4, local5, local5, local6, local7 のいずれかです。
</para>
</listitem>
</varlistentry>
Expand Down
10 changes: 5 additions & 5 deletions doc/ko/lxc.container.conf.sgml.in
Expand Up @@ -2308,7 +2308,7 @@ mknod errno 0
<variablelist>
<varlistentry>
<term>
<option>lxc.loglevel</option>
<option>lxc.log.level</option>
</term>
<listitem>
<para>
Expand Down Expand Up @@ -2338,7 +2338,7 @@ mknod errno 0
</varlistentry>
<varlistentry>
<term>
<option>lxc.logfile</option>
<option>lxc.log</option>
</term>
<listitem>
<para>
Expand All @@ -2351,17 +2351,17 @@ mknod errno 0
</varlistentry>
<varlistentry>
<term>
<option>lxc.syslog</option>
<option>lxc.log.syslog</option>
</term>
<listitem>
<para>
<!--
Send logging info to syslog. It respects the log level defined in
<command>lxc.loglevel</command>. The argument should be the syslog
<command>lxc.log.level</command>. The argument should be the syslog
facility to use, valid ones are: daemon, local0, local1, local2,
local3, local4, local5, local5, local7.
-->
로그정보를 syslog에 보낸다. 로그 수준은 <command>lxc.loglevel</command>로 지정할 수 있다. 인자는 syslog에 정의된 값으로만 지정할 수 있다. 사용 가능한 값은 다음과 같다 : daemon, local0, local1, local2, local3, local4, local5, local5, local7
로그정보를 syslog에 보낸다. 로그 수준은 <command>lxc.log.level</command>로 지정할 수 있다. 인자는 syslog에 정의된 값으로만 지정할 수 있다. 사용 가능한 값은 다음과 같다 : daemon, local0, local1, local2, local3, local4, local5, local5, local7
</para>
</listitem>
</varlistentry>
Expand Down
8 changes: 4 additions & 4 deletions doc/lxc.container.conf.sgml.in
Expand Up @@ -1741,7 +1741,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<variablelist>
<varlistentry>
<term>
<option>lxc.loglevel</option>
<option>lxc.log.level</option>
</term>
<listitem>
<para>
Expand All @@ -1761,7 +1761,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</varlistentry>
<varlistentry>
<term>
<option>lxc.logfile</option>
<option>lxc.log</option>
</term>
<listitem>
<para>
Expand All @@ -1771,12 +1771,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</varlistentry>
<varlistentry>
<term>
<option>lxc.syslog</option>
<option>lxc.log.syslog</option>
</term>
<listitem>
<para>
Send logging info to syslog. It respects the log level defined in
<command>lxc.loglevel</command>. The argument should be the syslog
<command>lxc.log.level</command>. The argument should be the syslog
facility to use, valid ones are: daemon, local0, local1, local2,
local3, local4, local5, local5, local6, local7.
</para>
Expand Down
35 changes: 19 additions & 16 deletions src/lxc/confile.c
Expand Up @@ -83,8 +83,8 @@ lxc_config_define(apparmor_allow_incomplete);
lxc_config_define(selinux_context);
lxc_config_define(cgroup);
lxc_config_define(idmaps);
lxc_config_define(loglevel);
lxc_config_define(logfile);
lxc_config_define(log_level);
lxc_config_define(log_file);
lxc_config_define(mount);
lxc_config_define(mount_auto);
lxc_config_define(fstab);
Expand Down Expand Up @@ -129,7 +129,7 @@ lxc_config_define(init_cmd);
lxc_config_define(init_uid);
lxc_config_define(init_gid);
lxc_config_define(ephemeral);
lxc_config_define(syslog);
lxc_config_define(log_syslog);
lxc_config_define(no_new_privs);
lxc_config_define(prlimit);

Expand All @@ -151,8 +151,6 @@ static struct lxc_config_t config[] = {

{ "lxc.cgroup", set_config_cgroup, get_config_cgroup, clr_config_cgroup, },
{ "lxc.id_map", set_config_idmaps, get_config_idmaps, clr_config_idmaps, },
{ "lxc.loglevel", set_config_loglevel, get_config_loglevel, clr_config_loglevel, },
{ "lxc.logfile", set_config_logfile, get_config_logfile, clr_config_logfile, },
{ "lxc.mount.entry", set_config_mount, get_config_mount, clr_config_mount, },
{ "lxc.mount.auto", set_config_mount_auto, get_config_mount_auto, clr_config_mount_auto, },
{ "lxc.mount", set_config_fstab, get_config_fstab, clr_config_fstab, },
Expand Down Expand Up @@ -227,16 +225,21 @@ static struct lxc_config_t config[] = {
{ "lxc.group", set_config_group, get_config_group, clr_config_group, },
{ "lxc.environment", set_config_environment, get_config_environment, clr_config_environment, },
{ "lxc.ephemeral", set_config_ephemeral, get_config_ephemeral, clr_config_ephemeral, },
{ "lxc.syslog", set_config_syslog, get_config_syslog, clr_config_syslog, },
{ "lxc.no_new_privs", set_config_no_new_privs, get_config_no_new_privs, clr_config_no_new_privs, },

/* REMOVE IN LXC 3.0: legacy keys [START]*/
{ "lxc.syslog", set_config_log_syslog, get_config_log_syslog, clr_config_log_syslog, },
{ "lxc.loglevel", set_config_log_level, get_config_log_level, clr_config_log_level, },
{ "lxc.logfile", set_config_log_file, get_config_log_file, clr_config_log_file, },
{ "lxc.init_cmd", set_config_init_cmd, get_config_init_cmd, clr_config_init_cmd, },
{ "lxc.init_uid", set_config_init_uid, get_config_init_uid, clr_config_init_uid, },
{ "lxc.init_gid", set_config_init_gid, get_config_init_gid, clr_config_init_gid, },
{ "lxc.limit", set_config_limit, get_config_limit, clr_config_limit, },
/* REMOVE IN LXC 3.0: legacy keys [END]*/

{ "lxc.log.syslog", set_config_log_syslog, get_config_log_syslog, clr_config_log_syslog, },
{ "lxc.log.level", set_config_log_level, get_config_log_level, clr_config_log_level, },
{ "lxc.log.file", set_config_log_file, get_config_log_file, clr_config_log_file, },
{ "lxc.init.cmd", set_config_init_cmd, get_config_init_cmd, clr_config_init_cmd, },
{ "lxc.init.uid", set_config_init_uid, get_config_init_uid, clr_config_init_uid, },
{ "lxc.init.gid", set_config_init_gid, get_config_init_gid, clr_config_init_gid, },
Expand Down Expand Up @@ -1327,7 +1330,7 @@ static int set_config_selinux_context(const char *key, const char *value,
return set_config_string_item(&lxc_conf->lsm_se_context, value);
}

static int set_config_logfile(const char *key, const char *value,
static int set_config_log_file(const char *key, const char *value,
struct lxc_conf *c, void *data)
{
int ret;
Expand All @@ -1347,7 +1350,7 @@ static int set_config_logfile(const char *key, const char *value,
return ret;
}

static int set_config_loglevel(const char *key, const char *value,
static int set_config_log_level(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
int newlevel;
Expand Down Expand Up @@ -2677,7 +2680,7 @@ static int set_config_ephemeral(const char *key, const char *value,
return 0;
}

static int set_config_syslog(const char *key, const char *value,
static int set_config_log_syslog(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
int facility;
Expand All @@ -2695,7 +2698,7 @@ static int set_config_syslog(const char *key, const char *value,
/* Parse value. */
facility = lxc_syslog_priority_to_int(value);
if (facility == -EINVAL) {
ERROR("Wrong value for lxc.syslog.");
ERROR("Wrong value for lxc.log.syslog.");
return -1;
}

Expand Down Expand Up @@ -2886,15 +2889,15 @@ static int get_config_idmaps(const char *key, char *retv, int inlen,
return fulllen;
}

static int get_config_loglevel(const char *key, char *retv, int inlen,
static int get_config_log_level(const char *key, char *retv, int inlen,
struct lxc_conf *c, void *data)
{
const char *v;
v = lxc_log_priority_to_string(c->loglevel);
return lxc_get_conf_str(retv, inlen, v);
}

static int get_config_logfile(const char *key, char *retv, int inlen,
static int get_config_log_file(const char *key, char *retv, int inlen,
struct lxc_conf *c, void *data)
{
return lxc_get_conf_str(retv, inlen, c->logfile);
Expand Down Expand Up @@ -3187,7 +3190,7 @@ static int get_config_start(const char *key, char *retv, int inlen,
return -1;
}

static int get_config_syslog(const char *key, char *retv, int inlen,
static int get_config_log_syslog(const char *key, char *retv, int inlen,
struct lxc_conf *c, void *data)
{
return lxc_get_conf_str(retv, inlen, c->syslog);
Expand Down Expand Up @@ -3388,14 +3391,14 @@ static inline int clr_config_idmaps(const char *key, struct lxc_conf *c,
return lxc_clear_idmaps(c);
}

static inline int clr_config_loglevel(const char *key, struct lxc_conf *c,
static inline int clr_config_log_level(const char *key, struct lxc_conf *c,
void *data)
{
c->loglevel = LXC_LOG_LEVEL_NOTSET;
return 0;
}

static inline int clr_config_logfile(const char *key, struct lxc_conf *c,
static inline int clr_config_log_file(const char *key, struct lxc_conf *c,
void *data)
{
free(c->logfile);
Expand Down Expand Up @@ -3554,7 +3557,7 @@ static inline int clr_config_start(const char *key, struct lxc_conf *c,
return 0;
}

static inline int clr_config_syslog(const char *key, struct lxc_conf *c,
static inline int clr_config_log_syslog(const char *key, struct lxc_conf *c,
void *data)
{
free(c->syslog);
Expand Down
8 changes: 4 additions & 4 deletions src/lxc/log.c
Expand Up @@ -463,10 +463,10 @@ extern void lxc_log_close(void)
/*
* This can be called:
* 1. when a program calls lxc_log_init with no logfile parameter (in which
* case the default is used). In this case lxc.logfile can override this.
* case the default is used). In this case lxc.loge can override this.
* 2. when a program calls lxc_log_init with a logfile parameter. In this
* case we don't want lxc.logfile to override this.
* 3. When a lxc.logfile entry is found in config file.
* case we don't want lxc.log to override this.
* 3. When a lxc.log entry is found in config file.
*/
static int __lxc_log_set_file(const char *fname, int create_dirs)
{
Expand Down Expand Up @@ -614,7 +614,7 @@ extern int lxc_log_init(struct lxc_log *log)
}

/*
* This is called when we read a lxc.loglevel entry in a lxc.conf file. This
* This is called when we read a lxc.log.level entry in a lxc.conf file. This
* happens after processing command line arguments, which override the .conf
* settings. So only set the level if previously unset.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/python-lxc/lxc/__init__.py
Expand Up @@ -387,7 +387,7 @@ def set_key(key, value):
new_value = self.get_config_item(key)

# loglevel is special and won't match the string we set
if key == "lxc.loglevel":
if key == "lxc.log.level":
new_value = value

if (isinstance(value, str) and isinstance(new_value, str) and
Expand Down
4 changes: 2 additions & 2 deletions src/tests/concurrent.c
Expand Up @@ -85,8 +85,8 @@ static void do_function(void *arguments)
}

if (debug) {
c->set_config_item(c, "lxc.loglevel", "DEBUG");
c->set_config_item(c, "lxc.logfile", name);
c->set_config_item(c, "lxc.log.level", "DEBUG");
c->set_config_item(c, "lxc.log", name);
}

if (strcmp(args->mode, "create") == 0) {
Expand Down
29 changes: 24 additions & 5 deletions src/tests/parse_config_file.c
Expand Up @@ -431,20 +431,39 @@ int main(int argc, char *argv[])
c->clear_config(c);
c->lxc_conf = NULL;

/* lxc.loglevel */
/* REMOVE IN LXC 3.0
legacy lxc.loglevel key
*/
if (set_get_compare_clear_save_load(c, "lxc.loglevel", "DEBUG", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.loglevel");
goto non_test_error;
}

/* lxc.logfile */
/* REMOVE IN LXC 3.0
legacy lxc.logfile key
*/
if (set_get_compare_clear_save_load(c, "lxc.logfile", "/some/path",
tmpf, true) < 0) {
lxc_error("%s\n", "lxc.logfile");
goto non_test_error;
}


/* lxc.log.level */
if (set_get_compare_clear_save_load(c, "lxc.log.level", "DEBUG", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.log.level");
goto non_test_error;
}

/* lxc.log */
if (set_get_compare_clear_save_load(c, "lxc.log.file", "/some/path",
tmpf, true) < 0) {
lxc_error("%s\n", "lxc.log.file");
goto non_test_error;
}

/* lxc.mount */
if (set_get_compare_clear_save_load(c, "lxc.mount", "/some/path", NULL,
true) < 0) {
Expand Down Expand Up @@ -659,10 +678,10 @@ int main(int argc, char *argv[])
goto non_test_error;
}

/* lxc.syslog */
if (set_get_compare_clear_save_load(c, "lxc.syslog", "local0", tmpf,
/* lxc.log.syslog */
if (set_get_compare_clear_save_load(c, "lxc.log.syslog", "local0", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.syslog");
lxc_error("%s\n", "lxc.log.syslog");
goto non_test_error;
}

Expand Down

0 comments on commit 46cc906

Please sign in to comment.