[Devel] [PATCH RHEL7 COMMIT] ve/printk: add ve_log_printk() for log in !current->task_ve
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jan 20 07:49:45 PST 2017
The commit is pushed to "branch-rh7-3.10.0-514.6.1.vz7.28.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.6.1.vz7.28.2
------>
commit 48477a16267e71d9794497feb58e8170a3c7c9fe
Author: Dmitry Safonov <dsafonov at virtuozzo.com>
Date: Fri Jan 20 19:49:45 2017 +0400
ve/printk: add ve_log_printk() for log in !current->task_ve
Patchset description:
iptables LOG in CT
With these patches, iptables LOG is printed into CT's dmesg buffer.
Yet it doesn't show in /var/log/messages and I believe the reason
is the absence of /dev/kmsg in CT (and rsyslog doesn't do redirection
for log entries thou). Dev kmsg is virtualized, so looks like nothing
prevents adding it to libvzctl list of devtmpfs devices:
https://github.com/OpenVZ/libvzctl/blob/55ebf21b03d408f0faaaecaab08b74eb2dce0e70/lib/env.c#L614
Also it should fix follow-log for `dmesg -w`.
These patches make iptables LOG visible in CT's `dmesg`.
Dmitry Safonov (3):
ve/printk: add ve_log_printk() for log in !current->task_ve
netfilter: rectify nflog inside CT
netfilter: rectify ebtlog inside CT
==========================
This patch description:
In some places we want to log into non-current VE.
So here is ve_log_printk(), which prints message from any printk-valid
context to other VE's buffer.
This changes current behavior a little as erstwhile we've logged only
into current VE's buffer, but looking at __vprintk_emit()'s locks it
should be safe (but still little dangerous as it introduces new, untested
previously call-path).
https://jira.sw.ru/browse/PSBM-54183
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
include/linux/printk.h | 7 +++++++
kernel/printk.c | 16 ++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index d93fbfe..fc35b47 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -135,6 +135,8 @@ int ve_printk(int dst, const char *fmt, ...);
int ve_log_init(struct ve_struct *ve);
void ve_log_destroy(struct ve_struct *ve);
+asmlinkage __printf(2, 3) __cold
+int ve_log_printk(struct ve_struct *ve, const char *s, ...);
/*
* Special printk facility for scheduler/timekeeping use only, _DO_NOT_USE_ !
@@ -194,6 +196,11 @@ static inline
void ve_log_destroy(struct ve_struct *ve)
{
}
+static inline __printf(2, 3) __cold
+int ve_log_printk(struct ve_struct *ve, const char *s, ...)
+{
+ return 0;
+}
static inline __printf(1, 2) __cold
int printk_deferred(const char *s, ...)
{
diff --git a/kernel/printk.c b/kernel/printk.c
index a332be1..47cddb3 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1900,6 +1900,22 @@ asmlinkage int ve_printk(int dst, const char *fmt, ...)
}
EXPORT_SYMBOL(ve_printk);
+asmlinkage int ve_log_printk(struct ve_struct *ve, const char *fmt, ...)
+{
+ struct log_state *log = &init_log_state;
+ va_list args;
+ int r;
+
+ if (likely(ve && ve->log_state))
+ log = ve->log_state;
+
+ va_start(args, fmt);
+ r = __vprintk_emit(log, 0, -1, NULL, 0, fmt, args);
+ va_end(args);
+
+ return r;
+}
+EXPORT_SYMBOL(ve_log_printk);
/**
* printk - print a kernel message
* @fmt: format string
More information about the Devel
mailing list