lxc_config_define(cgroup_controller);
lxc_config_define(cgroup_dir);
lxc_config_define(console_logfile);
+lxc_config_define(console_buffer_logfile);
lxc_config_define(console_buffer_size);
lxc_config_define(console_path);
lxc_config_define(environment);
{ "lxc.cap.keep", false, set_config_cap_keep, get_config_cap_keep, clr_config_cap_keep, },
{ "lxc.cgroup.dir", false, set_config_cgroup_dir, get_config_cgroup_dir, clr_config_cgroup_dir, },
{ "lxc.cgroup", false, set_config_cgroup_controller, get_config_cgroup_controller, clr_config_cgroup_controller, },
+ { "lxc.console.buffer.logfile", false, set_config_console_buffer_logfile, get_config_console_buffer_logfile, clr_config_console_buffer_logfile, },
{ "lxc.console.buffer.size", false, set_config_console_buffer_size, get_config_console_buffer_size, clr_config_console_buffer_size, },
{ "lxc.console.logfile", false, set_config_console_logfile, get_config_console_logfile, clr_config_console_logfile, },
{ "lxc.console.path", false, set_config_console_path, get_config_console_path, clr_config_console_path, },
{ "lxc.environment", false, set_config_environment, get_config_environment, clr_config_environment, },
{ "lxc.ephemeral", false, set_config_ephemeral, get_config_ephemeral, clr_config_ephemeral, },
- { "lxc.execute.cmd", false, set_config_execute_cmd, get_config_execute_cmd, clr_config_execute_cmd, },
+ { "lxc.execute.cmd", false, set_config_execute_cmd, get_config_execute_cmd, clr_config_execute_cmd, },
{ "lxc.group", false, set_config_group, get_config_group, clr_config_group, },
{ "lxc.hook.autodev", false, set_config_hooks, get_config_hooks, clr_config_hooks, },
{ "lxc.hook.clone", false, set_config_hooks, get_config_hooks, clr_config_hooks, },
return 0;
}
+static int set_config_console_buffer_logfile(const char *key, const char *value,
+ struct lxc_conf *lxc_conf,
+ void *data)
+{
+ return set_config_path_item(&lxc_conf->console.buffer_log_file, value);
+}
+
int append_unexp_config_line(const char *line, struct lxc_conf *conf)
{
size_t len = conf->unexpanded_len, linelen = strlen(line);
return lxc_get_conf_uint64(c, retv, inlen, c->autodev);
}
+static int get_config_console_buffer_logfile(const char *key, char *retv,
+ int inlen, struct lxc_conf *c,
+ void *data)
+{
+ return lxc_get_conf_str(retv, inlen, c->console.buffer_log_file);
+}
+
static int get_config_seccomp_profile(const char *key, char *retv, int inlen,
struct lxc_conf *c, void *data)
{
return 0;
}
+static inline int clr_config_console_buffer_logfile(const char *key,
+ struct lxc_conf *c,
+ void *data)
+{
+ free(c->console.buffer_log_file);
+ c->console.buffer_log_file = NULL;
+ return 0;
+}
+
static inline int clr_config_seccomp_profile(const char *key,
struct lxc_conf *c, void *data)
{
uint64_t used;
struct lxc_ringbuf *buf = &console->ringbuf;
- if (!console->log_path)
+ if (!console->buffer_log_file)
return 0;
used = lxc_ringbuf_used(buf);
if (used == 0)
return 0;
- fd = lxc_unpriv(open(console->log_path, O_CLOEXEC | O_RDWR | O_CREAT | O_TRUNC, 0600));
+ fd = lxc_unpriv(open(console->buffer_log_file, O_CLOEXEC | O_RDWR | O_CREAT | O_TRUNC, 0600));
if (fd < 0) {
- SYSERROR("Failed to open console log file \"%s\"", console->log_path);
+ SYSERROR("Failed to open console log file \"%s\"", console->buffer_log_file);
return -EIO;
}
- DEBUG("Using \"%s\" as console log file", console->log_path);
+ DEBUG("Using \"%s\" as console log file", console->buffer_log_file);
r_addr = lxc_ringbuf_get_read_addr(buf);
ret = lxc_write_nointr(fd, r_addr, used);
goto err;
}
- if (console->log_path && console->buffer_size <= 0) {
+ if (console->log_path) {
console->log_fd = lxc_unpriv(open(console->log_path, O_CLOEXEC | O_RDWR | O_CREAT | O_APPEND, 0600));
if (console->log_fd < 0) {
SYSERROR("Failed to open console log file \"%s\"", console->log_path);