Internally log messages contain the timestamps relative to the Host boot time, while Container could start much later than the Host boots and the timestamps should be shifted accordingly.
Otherwise "dmesg -H" reports data from the future. https://jira.sw.ru/browse/PSBM-145263 Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com> --- kernel/printk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/printk.c b/kernel/printk.c index 5380594d231f..27221d15590a 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -555,6 +555,7 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv, static ssize_t devkmsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { + struct ve_struct *ve; struct log_state *log = ve_log_state(); struct devkmsg_user *user = file->private_data; struct log *msg; @@ -597,6 +598,13 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, msg = log_from_idx(log, user->idx); ts_usec = msg->ts_nsec; + + /* shift the timestamp on the Container uptime value */ + ve = get_exec_env(); + if (!ve_is_super(ve)) { + ts_usec -= ve->real_start_timespec.tv_sec * NSEC_PER_SEC; + ts_usec -= ve->real_start_timespec.tv_nsec; + } do_div(ts_usec, 1000); /* -- 2.24.3 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel