This follows the same logic as ve_printk: 1) In VE0 we always print to host-log, independent of dst. 2) In VEX we print to host-log if dst is VE0_LOG and to ve-log if dst is VE_LOG.
Will use it in next patch in the ve_netdev_printk() helper for printing network device information. https://virtuozzo.atlassian.net/browse/VSTOR-106826 Signed-off-by: Pavel Tikhomirov <[email protected]> --- drivers/base/core.c | 30 ++++++++++++++++++++++++++++++ include/linux/dev_printk.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 048ff98dbdfd8..687ea49661fb3 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4958,6 +4958,36 @@ int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...) } EXPORT_SYMBOL(dev_printk_emit); +static int ve_dev_vprintk_emit(int level, const struct device *dev, const char *fmt, + va_list args) +{ + struct dev_printk_info dev_info; + + set_dev_info(dev, &dev_info); + + return ve_vprintk_emit(0, level, &dev_info, fmt, args); +} + +int ve_dev_printk_emit(int dst, int level, const struct device *dev, const char *fmt, ...) +{ + va_list args, args2; + int r; + + va_start(args, fmt); + va_copy(args2, args); + + if (ve_is_super(get_exec_env()) || (dst & VE0_LOG)) + r = dev_vprintk_emit(level, dev, fmt, args); + if (!ve_is_super(get_exec_env()) && (dst & VE_LOG)) + r = ve_dev_vprintk_emit(level, dev, fmt, args2); + + va_end(args2); + va_end(args); + + return r; +} +EXPORT_SYMBOL(ve_dev_printk_emit); + static void __dev_printk(const char *level, const struct device *dev, struct va_format *vaf) { diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h index ca32b5bb28eb5..f9ab1dc1545be 100644 --- a/include/linux/dev_printk.h +++ b/include/linux/dev_printk.h @@ -36,6 +36,8 @@ int dev_vprintk_emit(int level, const struct device *dev, const char *fmt, va_list args); __printf(3, 4) __cold int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...); +__printf(4, 5) __cold +int ve_dev_printk_emit(int dst, int level, const struct device *dev, const char *fmt, ...); __printf(3, 4) __cold void _dev_printk(const char *level, const struct device *dev, -- 2.51.0 _______________________________________________ Devel mailing list [email protected] https://lists.openvz.org/mailman/listinfo/devel
