The commit is pushed to "branch-rh7-3.10.0-1160.83.1.vz7.194.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after rh7-3.10.0-1160.83.1.vz7.194.2 ------> commit e20414197aef5bbf92f706eddc2998a7127dd5cc Author: Konstantin Khorenko <khore...@virtuozzo.com> Date: Thu Feb 2 20:01:42 2023 +0300
kmsg: Virtualize timestamps in /dev/ksmg output 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> Acked-by: Alexander Atanasov <alexander.atana...@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); /* _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel