The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after ark-5.14 ------> commit 5bfb9c989746962bfaf7a2f63918c3823ee47e82 Author: Vladimir Davydov <vdavydov....@gmail.com> Date: Wed Sep 29 21:33:15 2021 +0300
ve/printk: Introduce ve_printk() https://jira.sw.ru/browse/PSBM-17899 Signed-off-by: Vladimir Davydov <vdavy...@parallels.com> Signed-off-by: Stanislav Kinsburskiy <skinsbur...@virtuozzo.com> +++ ve/printk: Fix printk virtualization ve_printk() corrupts host's dmesg: # dmesg|wc -l 599 # vzctl create 101 # vzctl set 101 --netif_add eth0 --save # vzctl start 101 # vzctl exec 101 'tcpdump -w tcpdump.out -U -n -i eth0 esp' # dmesg|wc -l 2 Add missing parts of prinkt virtualization to fix this. https://jira.sw.ru/browse/PSBM-17899 https://jira.sw.ru/browse/PSBM-105442 Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com> Rebasing to vz9: part of vz8 commit: d63aeb311a64 ("ve/printk: printk virtualization") https://jira.sw.ru/browse/PSBM-133985 Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com> --- include/linux/printk.h | 20 ++++++++++++++++++++ kernel/printk/printk.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/linux/printk.h b/include/linux/printk.h index f178e2e5d7f5..6e14c410a2df 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -70,6 +70,10 @@ extern int console_printk[]; #define minimum_console_loglevel (console_printk[2]) #define default_console_loglevel (console_printk[3]) +#define VE0_LOG 1 +#define VE_LOG 2 +#define VE_LOG_BOTH (VE0_LOG | VE_LOG) + static inline void console_silent(void) { console_loglevel = CONSOLE_LOGLEVEL_SILENT; @@ -176,6 +180,12 @@ int vprintk(const char *fmt, va_list args); asmlinkage __printf(1, 2) __cold int printk(const char *fmt, ...); +asmlinkage __printf(2, 0) +int ve_vprintk(int dst, const char *fmt, va_list args); + +asmlinkage __printf(2, 3) __cold +int ve_printk(int dst, const char *fmt, ...); + struct ve_struct; int ve_log_init(struct ve_struct *ve); void ve_log_destroy(struct ve_struct *ve); @@ -226,6 +236,16 @@ int printk(const char *s, ...) { return 0; } +static inline __printf(2, 0) +int ve_vprintk(int dst, const char *s, va_list args) +{ + return 0; +} +static inline __printf(2, 3) __cold +int ve_printk(int dst, const char *s, ...) +{ + return 0; +} static inline int ve_log_init(struct ve_struct *ve) { diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 7f1bec17866d..f3b5dbd9db6d 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2278,6 +2278,37 @@ int vprintk_default(const char *fmt, va_list args) } EXPORT_SYMBOL_GPL(vprintk_default); +asmlinkage int ve_vprintk(int dst, const char *fmt, va_list args) +{ + va_list args2; + int r = 0; + + va_copy(args2, args); + if (ve_is_super(get_exec_env()) || (dst & VE0_LOG)) + r = vprintk(fmt, args); + if (!ve_is_super(get_exec_env()) && (dst & VE_LOG)) + r = __vprintk(fmt, args2); + + return r; +} + +/* + * Do not use it from scheduler code - can lead to deadlocks. + */ + +asmlinkage int ve_printk(int dst, const char *fmt, ...) +{ + va_list args; + int r; + + va_start(args, fmt); + r = ve_vprintk(dst, fmt, args); + va_end(args); + + return r; +} +EXPORT_SYMBOL(ve_printk); + /** * printk - print a kernel message * @fmt: format string _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel