confile: add lxc.console.rotate

parent 3a784510
......@@ -733,11 +733,37 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</term>
<listitem>
<para>
Specify a path to a file where the console output will
be written.
Specify a path to a file where the console output will be written.
Note that in contrast to the on-disk ringbuffer logfile this file
will keep growing potentially filling up the users disks if not
rotated and deleted. This problem can also be avoided by using the
in-memory ringbuffer options
<option>lxc.console.buffer.size</option> and
<option>lxc.console.buffer.logfile</option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>lxc.console.rotate</option>
</term>
<listitem>
<para>
Whether to rotate the console logfile specified in
<option>lxc.console.logfile</option>. Users can send an API
request to rotate the logfile. Note that the old logfile will have
the same name as the original with the suffix ".1" appended.
Users wishing to prevent the console log file from filling the
disk should rotate the logfile and delete it if unneeded. This
problem can also be avoided by using the in-memory ringbuffer
options <option>lxc.console.buffer.size</option> and
<option>lxc.console.buffer.logfile</option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>lxc.console.path</option>
......
......@@ -150,6 +150,7 @@ struct lxc_console {
char *path;
char *log_path;
int log_fd;
unsigned int log_rotate;
char name[MAXPATHLEN];
struct termios *tios;
struct lxc_tty_state *tty_state;
......
......@@ -83,6 +83,7 @@ lxc_config_define(cap_keep);
lxc_config_define(cgroup_controller);
lxc_config_define(cgroup_dir);
lxc_config_define(console_logfile);
lxc_config_define(console_rotate);
lxc_config_define(console_buffer_logfile);
lxc_config_define(console_buffer_size);
lxc_config_define(console_path);
......@@ -154,6 +155,7 @@ static struct lxc_config_t config[] = {
{ "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.console.rotate", false, set_config_console_rotate, get_config_console_rotate, clr_config_console_rotate, },
{ "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, },
......@@ -1790,6 +1792,23 @@ static int set_config_console_path(const char *key, const char *value,
return set_config_path_item(&lxc_conf->console.path, value);
}
static int set_config_console_rotate(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
if (lxc_config_value_empty(value)) {
lxc_conf->console.log_rotate = 0;
return 0;
}
if (lxc_safe_uint(value, &lxc_conf->console.log_rotate) < 0)
return -1;
if (lxc_conf->console.log_rotate > 1)
return -1;
return 0;
}
static int set_config_console_logfile(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
......@@ -3100,6 +3119,13 @@ static int get_config_console_logfile(const char *key, char *retv, int inlen,
return lxc_get_conf_str(retv, inlen, c->console.log_path);
}
static int get_config_console_rotate(const char *key, char *retv, int inlen,
struct lxc_conf *c, void *data)
{
return lxc_get_conf_int(c, retv, inlen, c->console.log_rotate);
}
static int get_config_console_buffer_size(const char *key, char *retv,
int inlen, struct lxc_conf *c,
void *data)
......@@ -3518,6 +3544,13 @@ static inline int clr_config_console_logfile(const char *key,
return 0;
}
static inline int clr_config_console_rotate(const char *key, struct lxc_conf *c,
void *data)
{
c->console.log_rotate = 0;
return 0;
}
static inline int clr_config_console_buffer_size(const char *key,
struct lxc_conf *c, void *data)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment