Container support for lttng-logger
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 17 lines · ----- On Dec 19, 2017, at 3:55 PM, Stéphane Graber [email protected] wrote:
This adds a new
/dev/lttng-loggerinterface to make it easy for containers to write to the lttng logger.root@vm10:~/lttng-modules# ls -lh /dev/lttng-logger crw-rw-rw- 1 root root 10, 54 Dec 19 20:39 /dev/lttng-logger root@vm10:~/lttng-modules# ls -lh /proc/lttng-logger -rw-rw-rw- 1 root root 0 Dec 19 20:39 /proc/lttng-loggerroot@vm10:~/lttng-modules# lxc config device add test lttng unix-char path=/dev/lttng-logger Device lttng added to testroot@vm10:~/lttng-modules# echo host-dev > /dev/lttng-logger root@vm10:~/lttng-modules# echo host-proc > /proc/lttng-logger root@vm10:~/lttng-modules# lxc exec test bash root@test:~# echo container-dev > /dev/lttng-logger
Quoted 6 lines
[20:42:56.627719300] (+?.?????????) vm10
lttng_logger: {cpu_id= 4 }, {_msg_length= 9, msg = "host-dev" }
[20:42:58.145960910] (+1.518241610) vm10lttng_logger: {cpu_id= 4 }, {_msg_length= 10, msg = "host-proc" }
[20:43:01.123842390] (+2.977881480) vm10lttng_logger: {cpu_id= 3 }, {_msg_length= 14, msg = "container-dev" }
It's great! The code looks good. The only thing missing before I can merge this is adding tests under the lttng-tools tests/ directory.
Thanks,
Mathieu
Quoted 10 lines
Stéphane Graber (1):
Add a new/dev/lttng-loggerinterface
probes/lttng.c| 26 ++++++++++++++++++++++++--1 file changed, 24 insertions(+), 2 deletions(-)--
2.14.1
Signature · 7 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 1/1 Add a new /dev/lttng-logger interface
In reply to a message not in the archiveThis is identical to /proc/lttng-logger but has the advantage of working from within containers when the path is made accessible to them.
--- probes/lttng.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
probes/lttng.c +24 -2
@@ -28,6 +28,7 @@#include <linux/proc_fs.h> #include <linux/slab.h> #include <linux/mm.h> +#include <linux/miscdevice.h> #include <wrapper/vmalloc.h> #include <lttng-events.h>
@@ -105,19 +106,37 @@ static const struct file_operations lttng_logger_operations = { .write = lttng_logger_write, }; +static struct miscdevice logger_dev = { + .minor =MISC_DYNAMIC_MINOR , + .name ="lttng-logger" , + .mode =0666 , + .fops = <tng_logger_operations +}; +int __init lttng_logger_init (void ) {int ret =0 ;wrapper_vmalloc_sync_all (); + +/* /dev/lttng-logger */ + ret =misc_register (&logger_dev); +if (ret) { +printk (KERN_ERR "Error creating LTTng logger device\n" ); + goto error; + } + +/* /proc/lttng-logger */ lttng_logger_dentry =proc_create_data (LTTNG_LOGGER_FILE ,S_IRUGO |S_IWUGO ,NULL , <tng_logger_operations,NULL );if (!lttng_logger_dentry) { -printk (KERN_ERR "Error creating LTTng logger file\n" ); +printk (KERN_ERR "Error creating LTTng logger proc file\n" ); ret = -ENOMEM ; - goto error; + goto error_proc; } + +/* Init */ ret =__lttng_events_init__lttng ();if (ret) goto error_events;
@@ -125,6 +144,8 @@ int __init lttng_logger_init(void) error_events:remove_proc_entry ("lttng-logger" ,NULL ); +error_proc: +misc_deregister (&logger_dev); error:return ret; }
@@ -134,4 +155,5 @@ void lttng_logger_exit(void)__lttng_events_exit__lttng ();if (lttng_logger_dentry)remove_proc_entry ("lttng-logger" ,NULL ); +misc_deregister (&logger_dev); }
Signature · 6 lines
2.14.1 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mathieu Desnoyers
AppliedRe: [PATCH lttng-modules] Add a new /dev/lttng-logger interface
Merged into master branch of lttng-modules, thanks!
Mathieu
Quoted 80 lines · ----- On Dec 19, 2017, at 3:55 PM, Stéphane Graber [email protected] wrote:
This is identical to
/proc/lttng-loggerbut has the advantage of working from within containers when the path is made accessible to them.Fixes #1145Signed-off-by Stéphane Graber <[email protected]>---
probes/lttng.c| 26 ++++++++++++++++++++++++--1 file changed, 24 insertions(+), 2 deletions(-)probes/lttng.c +21
-2@@ -28,6 +28,7 @@#include <linux/proc_fs.h> #include <linux/slab.h> #include <linux/mm.h> +#include <linux/miscdevice.h> #include <wrapper/vmalloc.h> #include <lttng-events.h> @@ -105,19 +106,37 @@ static const struct file_operations lttng_logger_operations = { .write = lttng_logger_write, }; +static struct miscdevice logger_dev = { + .minor =MISC_DYNAMIC_MINOR , + .name ="lttng-logger" , + .mode =0666 , + .fops = <tng_logger_operations +}; +int __init lttng_logger_init (void ) {int ret =0 ;wrapper_vmalloc_sync_all (); + +/* /dev/lttng-logger */ + ret =misc_register (&logger_dev); +if (ret) { +printk (KERN_ERR "Error creating LTTng logger device\n" ); + goto error; + } + +/* /proc/lttng-logger */ lttng_logger_dentry =proc_create_data (LTTNG_LOGGER_FILE ,S_IRUGO |S_IWUGO ,NULL , <tng_logger_operations,NULL );if (!lttng_logger_dentry) { -printk (KERN_ERR "Error creating LTTng logger file\n" ); +printk (KERN_ERR "Error creating LTTng logger proc file\n" ); ret = -ENOMEM ; - goto error; + goto error_proc; } + +/* Init */ ret =__lttng_events_init__lttng ();if (ret)goto error_events;probes/lttng.c +0
-0@@ -125,6 +144,8 @@ int __init lttng_logger_init(void)
error_events:remove_proc_entry("lttng-logger", NULL);probes/lttng.c +2
-0+error_proc: +misc_deregister (&logger_dev);error:
return ret; }probes/lttng.c +1
-1@@ -134,4 +155,5 @@ void lttng_logger_exit(void)__lttng_events_exit__lttng ();if (lttng_logger_dentry)remove_proc_entry ("lttng-logger" ,NULL ); +misc_deregister (&logger_dev); } --2.14.1
Signature · 7 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev