diff --git a/doc/lxc.container.conf.sgml.in b/doc/lxc.container.conf.sgml.in
index f44072148..43227d8df 100644
--- a/doc/lxc.container.conf.sgml.in
+++ b/doc/lxc.container.conf.sgml.in
@@ -860,26 +860,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-
-
-
-
- Setting this option instructs liblxc to write the in-memory
- ringbuffer to disk. For performance reasons liblxc will only write
- the in-memory ringbuffer to disk when requested. Note that the this
- option is only used by liblxc when
- is set.
-
- By default liblxc will dump the contents of the in-memory ringbuffer
- to disk when the container terminates. This allows users to diagnose
- boot failures when the container crashed before an API request to
- retrieve the in-memory ringbuffer could be sent or handled.
-
-
-
-
diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index 37443c0d0..92363fa87 100644
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -934,7 +934,6 @@ int lxc_cmd_console_log(const char *name, const char *lxcpath,
data.clear = log->clear;
data.read = log->read;
data.read_max = *log->read_max;
- data.write_logfile = log->write_logfile;
cmd.req.cmd = LXC_CMD_CONSOLE_LOG;
cmd.req.data = &data;
@@ -968,7 +967,6 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
struct lxc_cmd_rsp rsp;
uint64_t buffer_size = handler->conf->console.buffer_size;
const struct lxc_cmd_console_log *log = req->data;
- struct lxc_console *console = &handler->conf->console;
struct lxc_ringbuf *buf = &handler->conf->console.ringbuf;
rsp.ret = -EFAULT;
@@ -991,45 +989,12 @@ static int lxc_cmd_console_log_callback(int fd, struct lxc_cmd_req *req,
if (log->read && (buf->r_off == buf->w_off))
goto out;
- if (log->write_logfile && rsp.datalen > 0) {
- rsp.ret = -ENOENT;
- if (!console->buffer_log_file)
- goto out;
-
- rsp.ret = lxc_console_write_ringbuffer(console);
- if (rsp.ret < 0)
- goto out;
- }
-
rsp.ret = 0;
- if (log->clear) {
+ if (log->clear)
/* clear the ringbuffer */
lxc_ringbuf_clear(buf);
-
- /* truncate the ringbuffer log file */
- if (console->buffer_log_file) {
- rsp.ret = -ENOENT;
- if (!file_exists(console->buffer_log_file))
- goto out;
-
- /* be very certain things are kosher */
- rsp.ret = -EBADF;
- if (console->buffer_log_file_fd < 0)
- goto out;
-
- rsp.ret = lxc_unpriv(ftruncate(console->buffer_log_file_fd, 0));
- if (rsp.ret < 0) {
- ERROR("%s - Failed to truncate console "
- "ringbuffer log file \"%s\"",
- strerror(errno), console->buffer_log_file);
- goto out;
- }
- }
-
- rsp.ret = lxc_console_rotate_log_file(console);
- } else if (rsp.datalen > 0) {
+ else if (rsp.datalen > 0)
lxc_ringbuf_move_read_addr(buf, rsp.datalen);
- }
out:
return lxc_cmd_rsp_send(fd, &rsp);
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index e6d385c2c..e1cca7597 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2609,8 +2609,6 @@ struct lxc_conf *lxc_conf_init(void)
new->loglevel = LXC_LOG_LEVEL_NOTSET;
new->personality = -1;
new->autodev = 1;
- new->console.buffer_log_file = NULL;
- new->console.buffer_log_file_fd = -1;
new->console.buffer_size = 0;
new->console.log_path = NULL;
new->console.log_fd = -1;
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index 7bbb3fdfc..d554b5f24 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -193,12 +193,6 @@ struct lxc_console {
/* size of the ringbuffer */
uint64_t buffer_size;
- /* path to the log file for the ringbuffer */
- char *buffer_log_file;
-
- /* fd to the log file for the ringbuffer */
- int buffer_log_file_fd;
-
/* the in-memory ringbuffer */
struct lxc_ringbuf ringbuf;
};
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index b1e2192c6..a7fef897d 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -82,7 +82,6 @@ lxc_config_define(cap_keep);
lxc_config_define(cgroup_controller);
lxc_config_define(cgroup2_controller);
lxc_config_define(cgroup_dir);
-lxc_config_define(console_buffer_logfile);
lxc_config_define(console_buffer_size);
lxc_config_define(console_logfile);
lxc_config_define(console_path);
@@ -156,7 +155,6 @@ static struct lxc_config_t config[] = {
{ "lxc.cgroup2", set_config_cgroup2_controller, get_config_cgroup2_controller, clr_config_cgroup2_controller, },
{ "lxc.cgroup.dir", set_config_cgroup_dir, get_config_cgroup_dir, clr_config_cgroup_dir, },
{ "lxc.cgroup", set_config_cgroup_controller, get_config_cgroup_controller, clr_config_cgroup_controller, },
- { "lxc.console.buffer.logfile", set_config_console_buffer_logfile, get_config_console_buffer_logfile, clr_config_console_buffer_logfile, },
{ "lxc.console.buffer.size", set_config_console_buffer_size, get_config_console_buffer_size, clr_config_console_buffer_size, },
{ "lxc.console.logfile", set_config_console_logfile, get_config_console_logfile, clr_config_console_logfile, },
{ "lxc.console.path", set_config_console_path, get_config_console_path, clr_config_console_path, },
@@ -2010,13 +2008,6 @@ static int set_config_console_size(const char *key, const char *value,
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);
@@ -3354,13 +3345,6 @@ static int get_config_console_size(const char *key, char *retv, int inlen,
}
-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)
{
@@ -3903,15 +3887,6 @@ static inline int clr_config_console_size(const char *key, struct lxc_conf *c,
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)
{
diff --git a/src/lxc/console.c b/src/lxc/console.c
index b4f13f38a..21be155ef 100644
--- a/src/lxc/console.c
+++ b/src/lxc/console.c
@@ -705,36 +705,10 @@ out:
return ret;
}
-int lxc_console_write_ringbuffer(struct lxc_console *console)
-{
- char *r_addr;
- ssize_t ret;
- uint64_t used;
- struct lxc_ringbuf *buf = &console->ringbuf;
-
- if (!console->buffer_log_file)
- return 0;
-
- used = lxc_ringbuf_used(buf);
- if (used == 0)
- return 0;
-
- r_addr = lxc_ringbuf_get_read_addr(buf);
- ret = lxc_write_nointr(console->buffer_log_file_fd, r_addr, used);
- if (ret < 0)
- return -EIO;
-
- return 0;
-}
-
void lxc_console_delete(struct lxc_console *console)
{
int ret;
- ret = lxc_console_write_ringbuffer(console);
- if (ret < 0)
- WARN("Failed to write console log to disk");
-
if (console->tios && console->peer >= 0) {
ret = tcsetattr(console->peer, TCSAFLUSH, console->tios);
if (ret < 0)
@@ -758,31 +732,6 @@ void lxc_console_delete(struct lxc_console *console)
if (console->log_fd >= 0)
close(console->log_fd);
console->log_fd = -1;
-
- if (console->buffer_log_file_fd >= 0)
- close(console->buffer_log_file_fd);
- console->buffer_log_file_fd = -1;
-}
-
-/* This is the console ringbuffer log file. Please note that the console
- * ringbuffer log file is (implementation wise not content wise) independent of
- * the console log file.
- */
-static int lxc_console_create_ringbuf_log_file(struct lxc_console *console)
-{
- if (!console->buffer_log_file)
- return 0;
-
- console->buffer_log_file_fd = lxc_unpriv(open(console->buffer_log_file,
- O_CLOEXEC | O_RDWR | O_CREAT | O_TRUNC, 0600));
- if (console->buffer_log_file_fd < 0) {
- SYSERROR("Failed to open console ringbuffer log file \"%s\"",
- console->buffer_log_file);
- return -EIO;
- }
-
- DEBUG("Using \"%s\" as console ringbuffer log file", console->buffer_log_file);
- return 0;
}
/**
@@ -912,11 +861,6 @@ int lxc_console_create(struct lxc_conf *conf)
if (ret < 0)
goto err;
- /* create console ringbuffer log file */
- ret = lxc_console_create_ringbuf_log_file(console);
- if (ret < 0)
- goto err;
-
return 0;
err:
@@ -1166,13 +1110,11 @@ void lxc_pty_init(struct lxc_console *pty)
pty->master = -EBADF;
pty->peer = -EBADF;
pty->log_fd = -EBADF;
- pty->buffer_log_file_fd = -EBADF;
lxc_pty_info_init(&pty->peerpty);
}
void lxc_pty_conf_free(struct lxc_console *console)
{
- free(console->buffer_log_file);
free(console->log_path);
free(console->path);
if (console->buffer_size > 0 && console->ringbuf.addr)
diff --git a/src/lxc/console.h b/src/lxc/console.h
index a385ed1f7..e6e323ed0 100644
--- a/src/lxc/console.h
+++ b/src/lxc/console.h
@@ -227,7 +227,6 @@ extern int lxc_console_cb_signal_fd(int fd, uint32_t events, void *cbdata,
*/
extern void lxc_console_signal_fini(struct lxc_tty_state *ts);
-extern int lxc_console_write_ringbuffer(struct lxc_console *console);
extern int lxc_console_create_log_file(struct lxc_console *console);
extern int lxc_console_cb_con(int fd, uint32_t events, void *data,
struct lxc_epoll_descr *descr);
diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h
index 47baed604..7bbac2f06 100644
--- a/src/lxc/lxccontainer.h
+++ b/src/lxc/lxccontainer.h
@@ -967,12 +967,6 @@ struct lxc_console_log {
* "data" is invalid.
*/
char *data;
-
- /* If a console log file was specified this flag indicates whether the
- * contents of the ringbuffer should be written to the logfile when a
- * request is sent to the ringbuffer.
- */
- bool write_logfile;
};
/*!
diff --git a/src/tests/console_log.c b/src/tests/console_log.c
index 3949b14e1..1e875086b 100644
--- a/src/tests/console_log.c
+++ b/src/tests/console_log.c
@@ -36,10 +36,8 @@
int main(int argc, char *argv[])
{
- int logfd, ret;
- char buf[4096 + 1];
- ssize_t bytes;
- struct stat st_buffer_log_file, st_log_file, st_log_file_old;
+ int ret;
+ struct stat st_log_file;
struct lxc_container *c;
struct lxc_console_log log;
bool do_unlink = false;
@@ -62,12 +60,6 @@ int main(int argc, char *argv[])
goto on_error_put;
}
- /* Set ringbuffer log file. */
- if (!c->set_config_item(c, "lxc.console.buffer.logfile", "/tmp/console-buffer-log.log")) {
- lxc_error("%s\n", "Failed to set config item \"lxc.console.buffer.logfile\"");
- goto on_error_put;
- }
-
/* Set console log file. */
if (!c->set_config_item(c, "lxc.console.logfile", "/tmp/console-log.log")) {
lxc_error("%s\n", "Failed to set config item \"lxc.console.logfile\"");
@@ -108,7 +100,6 @@ int main(int argc, char *argv[])
log.clear = false;
log.read_max = &(uint64_t){0};
log.read = true;
- log.write_logfile = false;
ret = c->console_log(c, &log);
if (ret < 0) {
@@ -126,7 +117,6 @@ int main(int argc, char *argv[])
/* Clear the console ringbuffer. */
log.read_max = &(uint64_t){0};
log.read = false;
- log.write_logfile = false;
log.clear = true;
ret = c->console_log(c, &log);
if (ret < 0) {
@@ -156,58 +146,6 @@ int main(int argc, char *argv[])
/* Leave some time for the container to write something to the log. */
sleep(2);
- log.read_max = &(uint64_t){0};
- log.read = true;
- log.write_logfile = true;
- log.clear = false;
- ret = c->console_log(c, &log);
- if (ret < 0) {
- lxc_error("%s - Failed to retrieve console log \n", strerror(-ret));
- goto on_error_stop;
- } else {
- lxc_debug("Retrieved %" PRIu64
- " bytes from console log. Contents are \"%s\"\n",
- *log.read_max, log.data);
- }
-
- logfd = open("/tmp/console-buffer-log.log", O_RDONLY);
- if (logfd < 0) {
- lxc_error("%s - Failed to open console ringbuffer log file "
- "\"/tmp/console-buffer-log.log\"\n", strerror(errno));
- goto on_error_stop;
- }
-
- bytes = lxc_read_nointr(logfd, buf, 4096 + 1);
- close(logfd);
- if (bytes < 0 || ((uint64_t)bytes != *log.read_max)) {
- lxc_error("%s - Failed to read console ringbuffer log file "
- "\"/tmp/console-buffer-log.log\"\n", strerror(errno));
- goto on_error_stop;
- }
-
- ret = stat("/tmp/console-buffer-log.log", &st_buffer_log_file);
- if (ret < 0) {
- lxc_error("%s - Failed to stat on-disk logfile\n", strerror(errno));
- goto on_error_stop;
- }
-
- if ((uint64_t)st_buffer_log_file.st_size != *log.read_max) {
- lxc_error("On-disk logfile size and used ringbuffer size do "
- "not match: %" PRIu64 " != %" PRIu64 "\n",
- (uint64_t)st_buffer_log_file.st_size, *log.read_max);
- goto on_error_stop;
- }
-
- if (memcmp(log.data, buf, *log.read_max)) {
- lxc_error("%s - Contents of in-memory ringbuffer and on-disk "
- "logfile do not match\n", strerror(errno));
- goto on_error_stop;
- } else {
- lxc_debug("Retrieved %" PRIu64 " bytes from console log and "
- "console ringbuffer log file. Contents are: \"%s\" - "
- "\"%s\"\n", *log.read_max, log.data, buf);
- }
-
ret = stat("/tmp/console-log.log", &st_log_file);
if (ret < 0) {
lxc_error("%s - Failed to stat on-disk logfile\n", strerror(errno));
@@ -233,59 +171,6 @@ int main(int argc, char *argv[])
/* Leave some time for the container to write something to the log. */
sleep(2);
- /* The console log file size must be greater than the console log file
- * size since we append to the latter and we truncated the former
- * already.
- */
- if (st_log_file.st_size <= st_buffer_log_file.st_size) {
- lxc_error("%s - Console log file size was smaller than the "
- "console buffer log file size: %zu < %zu\n",
- strerror(errno), (size_t)st_log_file.st_size,
- (size_t)st_buffer_log_file.st_size);
- goto on_error_stop;
- } else {
- lxc_debug("Console log file size is %zu bytes and console "
- "buffer log file size is %zu bytes\n",
- (size_t)st_log_file.st_size,
- (size_t)st_buffer_log_file.st_size);
- }
-
- ret = stat("/tmp/console-log.log", &st_log_file);
- if (ret < 0) {
- lxc_error("%s - Failed to stat on-disk logfile\n", strerror(errno));
- goto on_error_stop;
- }
-
- log.read_max = &(uint64_t){0};
- log.read = false;
- log.write_logfile = false;
- log.clear = true;
- ret = c->console_log(c, &log);
- if (ret < 0) {
- lxc_error("%s - Failed to retrieve console log \n", strerror(-ret));
- goto on_error_stop;
- }
-
- /* There should now be a rotated log file called
- * "/tmp/console-log.log.1"
- */
- ret = stat("/tmp/console-log.log.1", &st_log_file_old);
- if (ret < 0) {
- lxc_error("%s - Failed to stat on-disk logfile\n", strerror(errno));
- goto on_error_stop;
- }
-
- /* The rotated log file should have the same size as before the
- * rotation.
- */
- if (st_log_file.st_size != st_log_file_old.st_size) {
- lxc_error("%s - Console log file size changed during log "
- "rotation: %zu != %zu\n",
- strerror(errno), (size_t)st_log_file.st_size,
- (size_t)st_log_file_old.st_size);
- goto on_error_stop;
- }
-
fret = 0;
on_error_stop: