2 * Copyright (C) 2013 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <sys/types.h>
31 #include <common/defaults.h>
32 #include <common/error.h>
33 #include <common/macros.h>
34 #include <common/utils.h>
35 #include <common/compat/getenv.h>
36 #include <lttng/lttng-error.h>
37 #include <libxml/parser.h>
38 #include <libxml/valid.h>
39 #include <libxml/xmlschemas.h>
40 #include <libxml/tree.h>
41 #include <lttng/lttng.h>
42 #include <lttng/snapshot.h>
44 #include "session-config.h"
45 #include "config-internal.h"
47 struct handler_filter_args
{
49 config_entry_handler_cb handler
;
53 struct session_config_validation_ctx
{
54 xmlSchemaParserCtxtPtr parser_ctx
;
56 xmlSchemaValidCtxtPtr schema_validation_ctx
;
59 const char * const config_str_yes
= "yes";
60 const char * const config_str_true
= "true";
61 const char * const config_str_on
= "on";
62 const char * const config_str_no
= "no";
63 const char * const config_str_false
= "false";
64 const char * const config_str_off
= "off";
65 const char * const config_xml_encoding
= "UTF-8";
66 const size_t config_xml_encoding_bytes_per_char
= 2; /* Size of the encoding's largest character */
67 const char * const config_xml_indent_string
= "\t";
68 const char * const config_xml_true
= "true";
69 const char * const config_xml_false
= "false";
71 const char * const config_element_channel
= "channel";
72 const char * const config_element_channels
= "channels";
73 const char * const config_element_domain
= "domain";
74 const char * const config_element_domains
= "domains";
75 const char * const config_element_event
= "event";
76 const char * const config_element_events
= "events";
77 const char * const config_element_context
= "context";
78 const char * const config_element_contexts
= "contexts";
79 const char * const config_element_attributes
= "attributes";
80 const char * const config_element_exclusion
= "exclusion";
81 const char * const config_element_exclusions
= "exclusions";
82 const char * const config_element_function_attributes
= "function_attributes";
83 const char * const config_element_probe_attributes
= "probe_attributes";
84 const char * const config_element_symbol_name
= "symbol_name";
85 const char * const config_element_address
= "address";
86 const char * const config_element_offset
= "offset";
87 const char * const config_element_name
= "name";
88 const char * const config_element_enabled
= "enabled";
89 const char * const config_element_overwrite_mode
= "overwrite_mode";
90 const char * const config_element_subbuf_size
= "subbuffer_size";
91 const char * const config_element_num_subbuf
= "subbuffer_count";
92 const char * const config_element_switch_timer_interval
= "switch_timer_interval";
93 const char * const config_element_read_timer_interval
= "read_timer_interval";
94 const char * const config_element_output
= "output";
95 const char * const config_element_output_type
= "output_type";
96 const char * const config_element_tracefile_size
= "tracefile_size";
97 const char * const config_element_tracefile_count
= "tracefile_count";
98 const char * const config_element_live_timer_interval
= "live_timer_interval";
99 LTTNG_HIDDEN
const char * const config_element_discarded_events
= "discarded_events";
100 LTTNG_HIDDEN
const char * const config_element_lost_packets
= "lost_packets";
101 const char * const config_element_type
= "type";
102 const char * const config_element_buffer_type
= "buffer_type";
103 const char * const config_element_session
= "session";
104 const char * const config_element_sessions
= "sessions";
105 LTTNG_HIDDEN
const char * const config_element_context_perf
= "perf";
106 LTTNG_HIDDEN
const char * const config_element_context_app
= "app";
107 LTTNG_HIDDEN
const char * const config_element_context_app_provider_name
= "provider_name";
108 LTTNG_HIDDEN
const char * const config_element_context_app_ctx_name
= "ctx_name";
109 const char * const config_element_config
= "config";
110 const char * const config_element_started
= "started";
111 const char * const config_element_snapshot_mode
= "snapshot_mode";
112 const char * const config_element_loglevel
= "loglevel";
113 const char * const config_element_loglevel_type
= "loglevel_type";
114 const char * const config_element_filter
= "filter";
115 LTTNG_HIDDEN
const char * const config_element_filter_expression
= "filter_expression";
116 const char * const config_element_snapshot_outputs
= "snapshot_outputs";
117 const char * const config_element_consumer_output
= "consumer_output";
118 const char * const config_element_destination
= "destination";
119 const char * const config_element_path
= "path";
120 const char * const config_element_net_output
= "net_output";
121 const char * const config_element_control_uri
= "control_uri";
122 const char * const config_element_data_uri
= "data_uri";
123 const char * const config_element_max_size
= "max_size";
124 const char * const config_element_pid
= "pid";
125 const char * const config_element_pids
= "pids";
126 const char * const config_element_shared_memory_path
= "shared_memory_path";
127 const char * const config_element_pid_tracker
= "pid_tracker";
128 const char * const config_element_trackers
= "trackers";
129 const char * const config_element_targets
= "targets";
130 const char * const config_element_target_pid
= "pid_target";
131 const char * const config_element_omit_name
= "omit_name";
132 const char * const config_element_omit_output
= "omit_output";
134 const char * const config_domain_type_kernel
= "KERNEL";
135 const char * const config_domain_type_ust
= "UST";
136 const char * const config_domain_type_jul
= "JUL";
137 const char * const config_domain_type_log4j
= "LOG4J";
138 const char * const config_domain_type_python
= "PYTHON";
140 const char * const config_buffer_type_per_pid
= "PER_PID";
141 const char * const config_buffer_type_per_uid
= "PER_UID";
142 const char * const config_buffer_type_global
= "GLOBAL";
144 const char * const config_overwrite_mode_discard
= "DISCARD";
145 const char * const config_overwrite_mode_overwrite
= "OVERWRITE";
147 const char * const config_output_type_splice
= "SPLICE";
148 const char * const config_output_type_mmap
= "MMAP";
150 const char * const config_loglevel_type_all
= "ALL";
151 const char * const config_loglevel_type_range
= "RANGE";
152 const char * const config_loglevel_type_single
= "SINGLE";
154 const char * const config_event_type_all
= "ALL";
155 const char * const config_event_type_tracepoint
= "TRACEPOINT";
156 const char * const config_event_type_probe
= "PROBE";
157 const char * const config_event_type_function
= "FUNCTION";
158 const char * const config_event_type_function_entry
= "FUNCTION_ENTRY";
159 const char * const config_event_type_noop
= "NOOP";
160 const char * const config_event_type_syscall
= "SYSCALL";
161 const char * const config_event_type_kprobe
= "KPROBE";
162 const char * const config_event_type_kretprobe
= "KRETPROBE";
164 const char * const config_event_context_pid
= "PID";
165 const char * const config_event_context_procname
= "PROCNAME";
166 const char * const config_event_context_prio
= "PRIO";
167 const char * const config_event_context_nice
= "NICE";
168 const char * const config_event_context_vpid
= "VPID";
169 const char * const config_event_context_tid
= "TID";
170 const char * const config_event_context_vtid
= "VTID";
171 const char * const config_event_context_ppid
= "PPID";
172 const char * const config_event_context_vppid
= "VPPID";
173 const char * const config_event_context_pthread_id
= "PTHREAD_ID";
174 const char * const config_event_context_hostname
= "HOSTNAME";
175 const char * const config_event_context_ip
= "IP";
176 const char * const config_event_context_perf_thread_counter
= "PERF_THREAD_COUNTER";
177 LTTNG_HIDDEN
const char * const config_event_context_app
= "APP";
178 LTTNG_HIDDEN
const char * const config_event_context_interruptible
= "INTERRUPTIBLE";
179 LTTNG_HIDDEN
const char * const config_event_context_preemptible
= "PREEMPTIBLE";
180 LTTNG_HIDDEN
const char * const config_event_context_need_reschedule
= "NEED_RESCHEDULE";
181 LTTNG_HIDDEN
const char * const config_event_context_migratable
= "MIGRATABLE";
183 /* Deprecated symbols */
184 const char * const config_element_perf
;
186 enum process_event_node_phase
{
191 struct consumer_output
{
198 static int config_entry_handler_filter(struct handler_filter_args
*args
,
199 const char *section
, const char *name
, const char *value
)
202 struct config_entry entry
= { section
, name
, value
};
206 if (!section
|| !name
|| !value
) {
212 if (strcmp(args
->section
, section
)) {
217 ret
= args
->handler(&entry
, args
->user_data
);
223 int config_get_section_entries(const char *override_path
, const char *section
,
224 config_entry_handler_cb handler
, void *user_data
)
228 FILE *config_file
= NULL
;
229 struct handler_filter_args filter
= { section
, handler
, user_data
};
231 /* First, try system-wide conf. file. */
232 path
= DEFAULT_DAEMON_SYSTEM_CONFIGPATH
;
234 config_file
= fopen(path
, "r");
236 DBG("Loading daemon conf file at %s", path
);
238 * Return value is not very important here since error or not, we
239 * continue and try the next possible conf. file.
241 (void) ini_parse_file(config_file
,
242 (ini_entry_handler
) config_entry_handler_filter
,
247 /* Second is the user local configuration. */
248 path
= utils_get_home_dir();
250 char fullpath
[PATH_MAX
];
252 ret
= snprintf(fullpath
, sizeof(fullpath
),
253 DEFAULT_DAEMON_HOME_CONFIGPATH
, path
);
255 PERROR("snprintf user conf. path");
259 config_file
= fopen(fullpath
, "r");
261 DBG("Loading daemon user conf file at %s", path
);
263 * Return value is not very important here since error or not, we
264 * continue and try the next possible conf. file.
266 (void) ini_parse_file(config_file
,
267 (ini_entry_handler
) config_entry_handler_filter
,
273 /* Final path is the one that the user might have provided. */
275 config_file
= fopen(override_path
, "r");
277 DBG("Loading daemon command line conf file at %s", override_path
);
278 (void) ini_parse_file(config_file
,
279 (ini_entry_handler
) config_entry_handler_filter
,
283 ERR("Failed to open daemon configuration file at %s",
290 /* Everything went well. */
298 int config_parse_value(const char *value
)
301 char *endptr
, *lower_str
;
311 v
= strtoul(value
, &endptr
, 10);
312 if (endptr
!= value
) {
317 lower_str
= zmalloc(len
+ 1);
324 for (i
= 0; i
< len
; i
++) {
325 lower_str
[i
] = tolower(value
[i
]);
328 if (!strcmp(lower_str
, config_str_yes
) ||
329 !strcmp(lower_str
, config_str_true
) ||
330 !strcmp(lower_str
, config_str_on
)) {
332 } else if (!strcmp(lower_str
, config_str_no
) ||
333 !strcmp(lower_str
, config_str_false
) ||
334 !strcmp(lower_str
, config_str_off
)) {
346 * Returns a xmlChar string which must be released using xmlFree().
348 static xmlChar
*encode_string(const char *in_str
)
350 xmlChar
*out_str
= NULL
;
351 xmlCharEncodingHandlerPtr handler
;
352 int out_len
, ret
, in_len
;
356 handler
= xmlFindCharEncodingHandler(config_xml_encoding
);
358 ERR("xmlFindCharEncodingHandler return NULL!. Configure issue!");
362 in_len
= strlen(in_str
);
364 * Add 1 byte for the NULL terminted character. The factor 4 here is
365 * used because UTF-8 characters can take up to 4 bytes.
367 out_len
= (in_len
* 4) + 1;
368 out_str
= xmlMalloc(out_len
);
373 ret
= handler
->input(out_str
, &out_len
, (const xmlChar
*) in_str
, &in_len
);
380 /* out_len is now the size of out_str */
381 out_str
[out_len
] = '\0';
387 struct config_writer
*config_writer_create(int fd_output
, int indent
)
390 struct config_writer
*writer
;
391 xmlOutputBufferPtr buffer
;
393 writer
= zmalloc(sizeof(struct config_writer
));
395 PERROR("zmalloc config_writer_create");
399 buffer
= xmlOutputBufferCreateFd(fd_output
, NULL
);
404 writer
->writer
= xmlNewTextWriter(buffer
);
405 ret
= xmlTextWriterStartDocument(writer
->writer
, NULL
,
406 config_xml_encoding
, NULL
);
411 ret
= xmlTextWriterSetIndentString(writer
->writer
,
412 BAD_CAST config_xml_indent_string
);
417 ret
= xmlTextWriterSetIndent(writer
->writer
, indent
);
425 config_writer_destroy(writer
);
430 int config_writer_destroy(struct config_writer
*writer
)
439 if (xmlTextWriterEndDocument(writer
->writer
) < 0) {
440 WARN("Could not close XML document");
444 if (writer
->writer
) {
445 xmlFreeTextWriter(writer
->writer
);
454 int config_writer_open_element(struct config_writer
*writer
,
455 const char *element_name
)
458 xmlChar
*encoded_element_name
;
460 if (!writer
|| !writer
->writer
|| !element_name
|| !element_name
[0]) {
465 encoded_element_name
= encode_string(element_name
);
466 if (!encoded_element_name
) {
471 ret
= xmlTextWriterStartElement(writer
->writer
, encoded_element_name
);
472 xmlFree(encoded_element_name
);
474 return ret
>= 0 ? 0 : ret
;
478 int config_writer_write_attribute(struct config_writer
*writer
,
479 const char *name
, const char *value
)
482 xmlChar
*encoded_name
= NULL
;
483 xmlChar
*encoded_value
= NULL
;
485 if (!writer
|| !writer
->writer
|| !name
|| !name
[0]) {
490 encoded_name
= encode_string(name
);
496 encoded_value
= encode_string(value
);
497 if (!encoded_value
) {
502 ret
= xmlTextWriterWriteAttribute(writer
->writer
, encoded_name
,
505 xmlFree(encoded_name
);
506 xmlFree(encoded_value
);
507 return ret
>= 0 ? 0 : ret
;
511 int config_writer_close_element(struct config_writer
*writer
)
515 if (!writer
|| !writer
->writer
) {
520 ret
= xmlTextWriterEndElement(writer
->writer
);
522 return ret
>= 0 ? 0 : ret
;
526 int config_writer_write_element_unsigned_int(struct config_writer
*writer
,
527 const char *element_name
, uint64_t value
)
530 xmlChar
*encoded_element_name
;
532 if (!writer
|| !writer
->writer
|| !element_name
|| !element_name
[0]) {
537 encoded_element_name
= encode_string(element_name
);
538 if (!encoded_element_name
) {
543 ret
= xmlTextWriterWriteFormatElement(writer
->writer
,
544 encoded_element_name
, "%" PRIu64
, value
);
545 xmlFree(encoded_element_name
);
547 return ret
>= 0 ? 0 : ret
;
551 int config_writer_write_element_signed_int(struct config_writer
*writer
,
552 const char *element_name
, int64_t value
)
555 xmlChar
*encoded_element_name
;
557 if (!writer
|| !writer
->writer
|| !element_name
|| !element_name
[0]) {
562 encoded_element_name
= encode_string(element_name
);
563 if (!encoded_element_name
) {
568 ret
= xmlTextWriterWriteFormatElement(writer
->writer
,
569 encoded_element_name
, "%" PRIi64
, value
);
570 xmlFree(encoded_element_name
);
572 return ret
>= 0 ? 0 : ret
;
576 int config_writer_write_element_bool(struct config_writer
*writer
,
577 const char *element_name
, int value
)
579 return config_writer_write_element_string(writer
, element_name
,
580 value
? config_xml_true
: config_xml_false
);
584 int config_writer_write_element_string(struct config_writer
*writer
,
585 const char *element_name
, const char *value
)
588 xmlChar
*encoded_element_name
= NULL
;
589 xmlChar
*encoded_value
= NULL
;
591 if (!writer
|| !writer
->writer
|| !element_name
|| !element_name
[0] ||
597 encoded_element_name
= encode_string(element_name
);
598 if (!encoded_element_name
) {
603 encoded_value
= encode_string(value
);
604 if (!encoded_value
) {
609 ret
= xmlTextWriterWriteElement(writer
->writer
, encoded_element_name
,
612 xmlFree(encoded_element_name
);
613 xmlFree(encoded_value
);
614 return ret
>= 0 ? 0 : ret
;
618 void xml_error_handler(void *ctx
, const char *format
, ...)
624 va_start(args
, format
);
625 ret
= vasprintf(&errMsg
, format
, args
);
628 ERR("String allocation failed in xml error handler");
632 fprintf(stderr
, "XML Error: %s", errMsg
);
637 void fini_session_config_validation_ctx(
638 struct session_config_validation_ctx
*ctx
)
640 if (ctx
->parser_ctx
) {
641 xmlSchemaFreeParserCtxt(ctx
->parser_ctx
);
645 xmlSchemaFree(ctx
->schema
);
648 if (ctx
->schema_validation_ctx
) {
649 xmlSchemaFreeValidCtxt(ctx
->schema_validation_ctx
);
652 memset(ctx
, 0, sizeof(struct session_config_validation_ctx
));
656 char *get_session_config_xsd_path()
659 const char *base_path
= lttng_secure_getenv(DEFAULT_SESSION_CONFIG_XSD_PATH_ENV
);
660 size_t base_path_len
;
664 base_path
= DEFAULT_SESSION_CONFIG_XSD_PATH
;
667 base_path_len
= strlen(base_path
);
668 max_path_len
= base_path_len
+
669 sizeof(DEFAULT_SESSION_CONFIG_XSD_FILENAME
) + 1;
670 xsd_path
= zmalloc(max_path_len
);
675 strncpy(xsd_path
, base_path
, max_path_len
);
676 if (xsd_path
[base_path_len
- 1] != '/') {
677 xsd_path
[base_path_len
++] = '/';
680 strncpy(xsd_path
+ base_path_len
, DEFAULT_SESSION_CONFIG_XSD_FILENAME
,
681 max_path_len
- base_path_len
);
687 int init_session_config_validation_ctx(
688 struct session_config_validation_ctx
*ctx
)
691 char *xsd_path
= get_session_config_xsd_path();
694 ret
= -LTTNG_ERR_NOMEM
;
698 ctx
->parser_ctx
= xmlSchemaNewParserCtxt(xsd_path
);
699 if (!ctx
->parser_ctx
) {
700 ERR("XSD parser context creation failed");
701 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
704 xmlSchemaSetParserErrors(ctx
->parser_ctx
, xml_error_handler
,
705 xml_error_handler
, NULL
);
707 ctx
->schema
= xmlSchemaParse(ctx
->parser_ctx
);
709 ERR("XSD parsing failed");
710 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
714 ctx
->schema_validation_ctx
= xmlSchemaNewValidCtxt(ctx
->schema
);
715 if (!ctx
->schema_validation_ctx
) {
716 ERR("XSD validation context creation failed");
717 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
721 xmlSchemaSetValidErrors(ctx
->schema_validation_ctx
, xml_error_handler
,
722 xml_error_handler
, NULL
);
727 fini_session_config_validation_ctx(ctx
);
735 int parse_uint(xmlChar
*str
, uint64_t *val
)
745 *val
= strtoull((const char *) str
, &endptr
, 10);
746 if (!endptr
|| *endptr
) {
757 int parse_int(xmlChar
*str
, int64_t *val
)
767 *val
= strtoll((const char *) str
, &endptr
, 10);
768 if (!endptr
|| *endptr
) {
779 int parse_bool(xmlChar
*str
, int *val
)
788 if (!strcmp((const char *) str
, config_xml_true
)) {
790 } else if (!strcmp((const char *) str
, config_xml_false
)) {
793 WARN("Invalid boolean value encoutered (%s).",
802 int get_domain_type(xmlChar
*domain
)
810 if (!strcmp((char *) domain
, config_domain_type_kernel
)) {
811 ret
= LTTNG_DOMAIN_KERNEL
;
812 } else if (!strcmp((char *) domain
, config_domain_type_ust
)) {
813 ret
= LTTNG_DOMAIN_UST
;
814 } else if (!strcmp((char *) domain
, config_domain_type_jul
)) {
815 ret
= LTTNG_DOMAIN_JUL
;
816 } else if (!strcmp((char *) domain
, config_domain_type_log4j
)) {
817 ret
= LTTNG_DOMAIN_LOG4J
;
818 } else if (!strcmp((char *) domain
, config_domain_type_python
)) {
819 ret
= LTTNG_DOMAIN_PYTHON
;
830 int get_buffer_type(xmlChar
*buffer_type
)
838 if (!strcmp((char *) buffer_type
, config_buffer_type_global
)) {
839 ret
= LTTNG_BUFFER_GLOBAL
;
840 } else if (!strcmp((char *) buffer_type
, config_buffer_type_per_uid
)) {
841 ret
= LTTNG_BUFFER_PER_UID
;
842 } else if (!strcmp((char *) buffer_type
, config_buffer_type_per_pid
)) {
843 ret
= LTTNG_BUFFER_PER_PID
;
854 int get_overwrite_mode(xmlChar
*overwrite_mode
)
858 if (!overwrite_mode
) {
862 if (!strcmp((char *) overwrite_mode
, config_overwrite_mode_overwrite
)) {
864 } else if (!strcmp((char *) overwrite_mode
,
865 config_overwrite_mode_discard
)) {
877 int get_output_type(xmlChar
*output_type
)
885 if (!strcmp((char *) output_type
, config_output_type_mmap
)) {
886 ret
= LTTNG_EVENT_MMAP
;
887 } else if (!strcmp((char *) output_type
, config_output_type_splice
)) {
888 ret
= LTTNG_EVENT_SPLICE
;
899 int get_event_type(xmlChar
*event_type
)
907 if (!strcmp((char *) event_type
, config_event_type_all
)) {
908 ret
= LTTNG_EVENT_ALL
;
909 } else if (!strcmp((char *) event_type
, config_event_type_tracepoint
)) {
910 ret
= LTTNG_EVENT_TRACEPOINT
;
911 } else if (!strcmp((char *) event_type
, config_event_type_probe
)) {
912 ret
= LTTNG_EVENT_PROBE
;
913 } else if (!strcmp((char *) event_type
, config_event_type_function
)) {
914 ret
= LTTNG_EVENT_FUNCTION
;
915 } else if (!strcmp((char *) event_type
,
916 config_event_type_function_entry
)) {
917 ret
= LTTNG_EVENT_FUNCTION_ENTRY
;
918 } else if (!strcmp((char *) event_type
, config_event_type_noop
)) {
919 ret
= LTTNG_EVENT_NOOP
;
920 } else if (!strcmp((char *) event_type
, config_event_type_syscall
)) {
921 ret
= LTTNG_EVENT_SYSCALL
;
932 int get_loglevel_type(xmlChar
*loglevel_type
)
936 if (!loglevel_type
) {
940 if (!strcmp((char *) loglevel_type
, config_loglevel_type_all
)) {
941 ret
= LTTNG_EVENT_LOGLEVEL_ALL
;
942 } else if (!strcmp((char *) loglevel_type
,
943 config_loglevel_type_range
)) {
944 ret
= LTTNG_EVENT_LOGLEVEL_RANGE
;
945 } else if (!strcmp((char *) loglevel_type
,
946 config_loglevel_type_single
)) {
947 ret
= LTTNG_EVENT_LOGLEVEL_SINGLE
;
958 * Return the context type or -1 on error.
961 int get_context_type(xmlChar
*context_type
)
969 if (!strcmp((char *) context_type
, config_event_context_pid
)) {
970 ret
= LTTNG_EVENT_CONTEXT_PID
;
971 } else if (!strcmp((char *) context_type
,
972 config_event_context_procname
)) {
973 ret
= LTTNG_EVENT_CONTEXT_PROCNAME
;
974 } else if (!strcmp((char *) context_type
,
975 config_event_context_prio
)) {
976 ret
= LTTNG_EVENT_CONTEXT_PRIO
;
977 } else if (!strcmp((char *) context_type
,
978 config_event_context_nice
)) {
979 ret
= LTTNG_EVENT_CONTEXT_NICE
;
980 } else if (!strcmp((char *) context_type
,
981 config_event_context_vpid
)) {
982 ret
= LTTNG_EVENT_CONTEXT_VPID
;
983 } else if (!strcmp((char *) context_type
,
984 config_event_context_tid
)) {
985 ret
= LTTNG_EVENT_CONTEXT_TID
;
986 } else if (!strcmp((char *) context_type
,
987 config_event_context_vtid
)) {
988 ret
= LTTNG_EVENT_CONTEXT_VTID
;
989 } else if (!strcmp((char *) context_type
,
990 config_event_context_ppid
)) {
991 ret
= LTTNG_EVENT_CONTEXT_PPID
;
992 } else if (!strcmp((char *) context_type
,
993 config_event_context_vppid
)) {
994 ret
= LTTNG_EVENT_CONTEXT_VPPID
;
995 } else if (!strcmp((char *) context_type
,
996 config_event_context_pthread_id
)) {
997 ret
= LTTNG_EVENT_CONTEXT_PTHREAD_ID
;
998 } else if (!strcmp((char *) context_type
,
999 config_event_context_hostname
)) {
1000 ret
= LTTNG_EVENT_CONTEXT_HOSTNAME
;
1001 } else if (!strcmp((char *) context_type
,
1002 config_event_context_ip
)) {
1003 ret
= LTTNG_EVENT_CONTEXT_IP
;
1004 } else if (!strcmp((char *) context_type
,
1005 config_event_context_interruptible
)) {
1006 ret
= LTTNG_EVENT_CONTEXT_INTERRUPTIBLE
;
1007 } else if (!strcmp((char *) context_type
,
1008 config_event_context_preemptible
)) {
1009 ret
= LTTNG_EVENT_CONTEXT_PREEMPTIBLE
;
1010 } else if (!strcmp((char *) context_type
,
1011 config_event_context_need_reschedule
)) {
1012 ret
= LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE
;
1013 } else if (!strcmp((char *) context_type
,
1014 config_event_context_migratable
)) {
1015 ret
= LTTNG_EVENT_CONTEXT_MIGRATABLE
;
1026 int init_domain(xmlNodePtr domain_node
, struct lttng_domain
*domain
)
1031 for (node
= xmlFirstElementChild(domain_node
); node
;
1032 node
= xmlNextElementSibling(node
)) {
1033 if (!strcmp((const char *) node
->name
, config_element_type
)) {
1035 xmlChar
*node_content
= xmlNodeGetContent(node
);
1036 if (!node_content
) {
1037 ret
= -LTTNG_ERR_NOMEM
;
1041 ret
= get_domain_type(node_content
);
1044 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1049 } else if (!strcmp((const char *) node
->name
,
1050 config_element_buffer_type
)) {
1052 xmlChar
*node_content
= xmlNodeGetContent(node
);
1053 if (!node_content
) {
1054 ret
= -LTTNG_ERR_NOMEM
;
1058 ret
= get_buffer_type(node_content
);
1061 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1065 domain
->buf_type
= ret
;
1074 int get_net_output_uris(xmlNodePtr net_output_node
, char **control_uri
,
1079 for (node
= xmlFirstElementChild(net_output_node
); node
;
1080 node
= xmlNextElementSibling(node
)) {
1081 if (!strcmp((const char *) node
->name
, config_element_control_uri
)) {
1083 *control_uri
= (char *) xmlNodeGetContent(node
);
1084 if (!*control_uri
) {
1089 *data_uri
= (char *) xmlNodeGetContent(node
);
1096 return *control_uri
|| *data_uri
? 0 : -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1100 int process_consumer_output(xmlNodePtr consumer_output_node
,
1101 struct consumer_output
*output
)
1108 for (node
= xmlFirstElementChild(consumer_output_node
); node
;
1109 node
= xmlNextElementSibling(node
)) {
1110 if (!strcmp((const char *) node
->name
, config_element_enabled
)) {
1111 xmlChar
*enabled_str
= xmlNodeGetContent(node
);
1115 ret
= -LTTNG_ERR_NOMEM
;
1119 ret
= parse_bool(enabled_str
, &output
->enabled
);
1125 xmlNodePtr output_type_node
;
1128 output_type_node
= xmlFirstElementChild(node
);
1129 if (!output_type_node
) {
1130 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1134 if (!strcmp((const char *) output_type_node
->name
,
1135 config_element_path
)) {
1137 output
->path
= (char *) xmlNodeGetContent(output_type_node
);
1138 if (!output
->path
) {
1139 ret
= -LTTNG_ERR_NOMEM
;
1144 ret
= get_net_output_uris(output_type_node
,
1145 &output
->control_uri
, &output
->data_uri
);
1157 free(output
->control_uri
);
1158 free(output
->data_uri
);
1159 memset(output
, 0, sizeof(struct consumer_output
));
1165 int create_session_net_output(const char *name
, const char *control_uri
,
1166 const char *data_uri
)
1169 struct lttng_handle
*handle
;
1170 const char *uri
= NULL
;
1174 handle
= lttng_create_handle(name
, NULL
);
1176 ret
= -LTTNG_ERR_NOMEM
;
1180 if (!control_uri
|| !data_uri
) {
1181 uri
= control_uri
? control_uri
: data_uri
;
1186 ret
= lttng_set_consumer_url(handle
, control_uri
, data_uri
);
1187 lttng_destroy_handle(handle
);
1193 int create_snapshot_session(const char *session_name
, xmlNodePtr output_node
)
1196 xmlNodePtr node
= NULL
;
1197 xmlNodePtr snapshot_output_list_node
;
1198 xmlNodePtr snapshot_output_node
;
1200 assert(session_name
);
1202 ret
= lttng_create_session_snapshot(session_name
, NULL
);
1211 snapshot_output_list_node
= xmlFirstElementChild(output_node
);
1213 /* Parse and create snapshot outputs */
1215 for (snapshot_output_node
=
1216 xmlFirstElementChild(snapshot_output_list_node
);
1217 snapshot_output_node
; snapshot_output_node
=
1218 xmlNextElementSibling(snapshot_output_node
)) {
1220 uint64_t max_size
= UINT64_MAX
;
1221 struct consumer_output output
= { 0 };
1222 struct lttng_snapshot_output
*snapshot_output
= NULL
;
1224 for (node
= xmlFirstElementChild(snapshot_output_node
); node
;
1225 node
= xmlNextElementSibling(node
)) {
1226 if (!strcmp((const char *) node
->name
,
1227 config_element_name
)) {
1229 name
= (char *) xmlNodeGetContent(node
);
1231 ret
= -LTTNG_ERR_NOMEM
;
1232 goto error_snapshot_output
;
1234 } else if (!strcmp((const char *) node
->name
,
1235 config_element_max_size
)) {
1236 xmlChar
*content
= xmlNodeGetContent(node
);
1240 ret
= -LTTNG_ERR_NOMEM
;
1241 goto error_snapshot_output
;
1243 ret
= parse_uint(content
, &max_size
);
1246 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1247 goto error_snapshot_output
;
1250 /* consumer_output */
1251 ret
= process_consumer_output(node
, &output
);
1253 goto error_snapshot_output
;
1258 snapshot_output
= lttng_snapshot_output_create();
1259 if (!snapshot_output
) {
1260 ret
= -LTTNG_ERR_NOMEM
;
1261 goto error_snapshot_output
;
1264 ret
= lttng_snapshot_output_set_name(name
, snapshot_output
);
1266 goto error_snapshot_output
;
1269 ret
= lttng_snapshot_output_set_size(max_size
, snapshot_output
);
1271 goto error_snapshot_output
;
1275 ret
= lttng_snapshot_output_set_ctrl_url(output
.path
,
1278 goto error_snapshot_output
;
1281 if (output
.control_uri
) {
1282 ret
= lttng_snapshot_output_set_ctrl_url(output
.control_uri
,
1285 goto error_snapshot_output
;
1289 if (output
.data_uri
) {
1290 ret
= lttng_snapshot_output_set_data_url(output
.data_uri
,
1293 goto error_snapshot_output
;
1298 ret
= lttng_snapshot_add_output(session_name
, snapshot_output
);
1299 error_snapshot_output
:
1302 free(output
.control_uri
);
1303 free(output
.data_uri
);
1304 lttng_snapshot_output_destroy(snapshot_output
);
1314 int create_session(const char *name
,
1315 struct lttng_domain
*kernel_domain
,
1316 struct lttng_domain
*ust_domain
,
1317 struct lttng_domain
*jul_domain
,
1318 struct lttng_domain
*log4j_domain
,
1319 xmlNodePtr output_node
,
1320 uint64_t live_timer_interval
)
1323 struct consumer_output output
= { 0 };
1324 xmlNodePtr consumer_output_node
;
1329 consumer_output_node
= xmlFirstElementChild(output_node
);
1330 if (!consumer_output_node
) {
1331 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1335 if (strcmp((const char *) consumer_output_node
->name
,
1336 config_element_consumer_output
)) {
1337 WARN("Invalid output type, expected %s node",
1338 config_element_consumer_output
);
1339 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1343 ret
= process_consumer_output(consumer_output_node
, &output
);
1349 if (live_timer_interval
!= UINT64_MAX
&&
1350 !output
.control_uri
&& !output
.data_uri
) {
1351 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1355 if (output
.control_uri
|| output
.data_uri
) {
1356 /* network destination */
1357 if (live_timer_interval
&& live_timer_interval
!= UINT64_MAX
) {
1359 * URLs are provided for sure since the test above make sure that
1360 * with a live timer the data and control URIs are provided. So,
1361 * NULL is passed here and will be set right after.
1363 ret
= lttng_create_session_live(name
, NULL
, live_timer_interval
);
1365 ret
= lttng_create_session(name
, NULL
);
1371 ret
= create_session_net_output(name
, output
.control_uri
,
1378 /* either local output or no output */
1379 ret
= lttng_create_session(name
, output
.path
);
1386 free(output
.control_uri
);
1387 free(output
.data_uri
);
1391 int process_probe_attribute_node(xmlNodePtr probe_attribute_node
,
1392 struct lttng_event_probe_attr
*attr
)
1396 assert(probe_attribute_node
);
1399 if (!strcmp((const char *) probe_attribute_node
->name
,
1400 config_element_address
)) {
1405 content
= xmlNodeGetContent(probe_attribute_node
);
1407 ret
= -LTTNG_ERR_NOMEM
;
1411 ret
= parse_uint(content
, &addr
);
1414 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1419 } else if (!strcmp((const char *) probe_attribute_node
->name
,
1420 config_element_offset
)) {
1422 uint64_t offset
= 0;
1425 content
= xmlNodeGetContent(probe_attribute_node
);
1427 ret
= -LTTNG_ERR_NOMEM
;
1431 ret
= parse_uint(content
, &offset
);
1434 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1438 attr
->offset
= offset
;
1439 } else if (!strcmp((const char *) probe_attribute_node
->name
,
1440 config_element_symbol_name
)) {
1445 content
= xmlNodeGetContent(probe_attribute_node
);
1447 ret
= -LTTNG_ERR_NOMEM
;
1451 name_len
= strlen((char *) content
);
1452 if (name_len
>= LTTNG_SYMBOL_NAME_LEN
) {
1453 WARN("symbol_name too long.");
1454 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1459 strncpy(attr
->symbol_name
, (const char *) content
, name_len
);
1468 int process_event_node(xmlNodePtr event_node
, struct lttng_handle
*handle
,
1469 const char *channel_name
, const enum process_event_node_phase phase
)
1473 struct lttng_event event
;
1474 char **exclusions
= NULL
;
1475 unsigned long exclusion_count
= 0;
1476 char *filter_expression
= NULL
;
1480 assert(channel_name
);
1482 memset(&event
, 0, sizeof(event
));
1484 /* Initialize default log level which varies by domain */
1485 switch (handle
->domain
.type
)
1487 case LTTNG_DOMAIN_JUL
:
1488 event
.loglevel
= LTTNG_LOGLEVEL_JUL_ALL
;
1490 case LTTNG_DOMAIN_LOG4J
:
1491 event
.loglevel
= LTTNG_LOGLEVEL_LOG4J_ALL
;
1493 case LTTNG_DOMAIN_PYTHON
:
1494 event
.loglevel
= LTTNG_LOGLEVEL_PYTHON_DEBUG
;
1496 case LTTNG_DOMAIN_UST
:
1497 case LTTNG_DOMAIN_KERNEL
:
1498 event
.loglevel
= LTTNG_LOGLEVEL_DEBUG
;
1504 for (node
= xmlFirstElementChild(event_node
); node
;
1505 node
= xmlNextElementSibling(node
)) {
1506 if (!strcmp((const char *) node
->name
, config_element_name
)) {
1511 content
= xmlNodeGetContent(node
);
1513 ret
= -LTTNG_ERR_NOMEM
;
1517 name_len
= strlen((char *) content
);
1518 if (name_len
>= LTTNG_SYMBOL_NAME_LEN
) {
1519 WARN("Channel name too long.");
1520 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1525 strncpy(event
.name
, (const char *) content
, name_len
);
1527 } else if (!strcmp((const char *) node
->name
,
1528 config_element_enabled
)) {
1529 xmlChar
*content
= xmlNodeGetContent(node
);
1533 ret
= -LTTNG_ERR_NOMEM
;
1537 ret
= parse_bool(content
, &event
.enabled
);
1540 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1543 } else if (!strcmp((const char *) node
->name
,
1544 config_element_type
)) {
1545 xmlChar
*content
= xmlNodeGetContent(node
);
1549 ret
= -LTTNG_ERR_NOMEM
;
1553 ret
= get_event_type(content
);
1556 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1561 } else if (!strcmp((const char *) node
->name
,
1562 config_element_loglevel_type
)) {
1563 xmlChar
*content
= xmlNodeGetContent(node
);
1567 ret
= -LTTNG_ERR_NOMEM
;
1571 ret
= get_loglevel_type(content
);
1574 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1578 event
.loglevel_type
= ret
;
1579 } else if (!strcmp((const char *) node
->name
,
1580 config_element_loglevel
)) {
1582 int64_t loglevel
= 0;
1585 content
= xmlNodeGetContent(node
);
1587 ret
= -LTTNG_ERR_NOMEM
;
1591 ret
= parse_int(content
, &loglevel
);
1594 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1598 if (loglevel
> INT_MAX
|| loglevel
< INT_MIN
) {
1599 WARN("loglevel out of range.");
1600 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1604 event
.loglevel
= loglevel
;
1605 } else if (!strcmp((const char *) node
->name
,
1606 config_element_filter
)) {
1608 xmlNodeGetContent(node
);
1612 ret
= -LTTNG_ERR_NOMEM
;
1616 free(filter_expression
);
1617 filter_expression
= strdup((char *) content
);
1619 if (!filter_expression
) {
1620 ret
= -LTTNG_ERR_NOMEM
;
1623 } else if (!strcmp((const char *) node
->name
,
1624 config_element_exclusions
)) {
1625 xmlNodePtr exclusion_node
;
1626 int exclusion_index
= 0;
1631 * Exclusions has already been initialized,
1634 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1638 exclusion_count
= xmlChildElementCount(node
);
1639 if (!exclusion_count
) {
1643 exclusions
= zmalloc(exclusion_count
* sizeof(char *));
1645 exclusion_count
= 0;
1646 ret
= -LTTNG_ERR_NOMEM
;
1650 for (exclusion_node
= xmlFirstElementChild(node
); exclusion_node
;
1651 exclusion_node
= xmlNextElementSibling(exclusion_node
)) {
1653 xmlNodeGetContent(exclusion_node
);
1656 ret
= -LTTNG_ERR_NOMEM
;
1660 exclusions
[exclusion_index
] = strdup((const char *) content
);
1662 if (!exclusions
[exclusion_index
]) {
1663 ret
= -LTTNG_ERR_NOMEM
;
1669 event
.exclusion
= 1;
1670 } else if (!strcmp((const char *) node
->name
,
1671 config_element_attributes
)) {
1672 xmlNodePtr attribute_node
= xmlFirstElementChild(node
);
1675 if (!attribute_node
) {
1676 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1680 if (!strcmp((const char *) node
->name
,
1681 config_element_probe_attributes
)) {
1682 xmlNodePtr probe_attribute_node
;
1684 /* probe_attributes */
1685 for (probe_attribute_node
=
1686 xmlFirstElementChild(attribute_node
); probe_attribute_node
;
1687 probe_attribute_node
= xmlNextElementSibling(
1688 probe_attribute_node
)) {
1690 ret
= process_probe_attribute_node(probe_attribute_node
,
1699 xmlNodePtr symbol_node
= xmlFirstElementChild(attribute_node
);
1701 /* function_attributes */
1702 content
= xmlNodeGetContent(symbol_node
);
1704 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1708 sym_len
= strlen((char *) content
);
1709 if (sym_len
>= LTTNG_SYMBOL_NAME_LEN
) {
1710 WARN("Function name too long.");
1711 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1716 strncpy(event
.attr
.ftrace
.symbol_name
, (char *) content
,
1723 if ((event
.enabled
&& phase
== ENABLE
) || phase
== CREATION
) {
1724 ret
= lttng_enable_event_with_exclusions(handle
, &event
, channel_name
,
1725 filter_expression
, exclusion_count
, exclusions
);
1727 WARN("Enabling event (name:%s) on load failed.", event
.name
);
1728 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1733 for (i
= 0; i
< exclusion_count
; i
++) {
1734 free(exclusions
[i
]);
1738 free(filter_expression
);
1743 int process_events_node(xmlNodePtr events_node
, struct lttng_handle
*handle
,
1744 const char *channel_name
)
1747 struct lttng_event event
;
1750 assert(events_node
);
1752 assert(channel_name
);
1754 for (node
= xmlFirstElementChild(events_node
); node
;
1755 node
= xmlNextElementSibling(node
)) {
1756 ret
= process_event_node(node
, handle
, channel_name
, CREATION
);
1763 * Disable all events to enable only the necessary events.
1764 * Limitations regarding lttng_disable_events and tuple descriptor
1765 * force this approach.
1767 memset(&event
, 0, sizeof(event
));
1768 event
.loglevel
= -1;
1769 event
.type
= LTTNG_EVENT_ALL
;
1770 ret
= lttng_disable_event_ext(handle
, &event
, channel_name
, NULL
);
1775 for (node
= xmlFirstElementChild(events_node
); node
;
1776 node
= xmlNextElementSibling(node
)) {
1777 ret
= process_event_node(node
, handle
, channel_name
, ENABLE
);
1788 int process_channel_attr_node(xmlNodePtr attr_node
,
1789 struct lttng_channel
*channel
, xmlNodePtr
*contexts_node
,
1790 xmlNodePtr
*events_node
)
1796 assert(contexts_node
);
1797 assert(events_node
);
1799 if (!strcmp((const char *) attr_node
->name
, config_element_name
)) {
1804 content
= xmlNodeGetContent(attr_node
);
1806 ret
= -LTTNG_ERR_NOMEM
;
1810 name_len
= strlen((char *) content
);
1811 if (name_len
>= LTTNG_SYMBOL_NAME_LEN
) {
1812 WARN("Channel name too long.");
1813 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1818 strncpy(channel
->name
, (const char *) content
, name_len
);
1820 } else if (!strcmp((const char *) attr_node
->name
,
1821 config_element_enabled
)) {
1826 content
= xmlNodeGetContent(attr_node
);
1828 ret
= -LTTNG_ERR_NOMEM
;
1832 ret
= parse_bool(content
, &enabled
);
1835 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1839 channel
->enabled
= enabled
;
1840 } else if (!strcmp((const char *) attr_node
->name
,
1841 config_element_overwrite_mode
)) {
1844 /* overwrite_mode */
1845 content
= xmlNodeGetContent(attr_node
);
1847 ret
= -LTTNG_ERR_NOMEM
;
1851 ret
= get_overwrite_mode(content
);
1854 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1858 channel
->attr
.overwrite
= ret
;
1859 } else if (!strcmp((const char *) attr_node
->name
,
1860 config_element_subbuf_size
)) {
1863 /* subbuffer_size */
1864 content
= xmlNodeGetContent(attr_node
);
1866 ret
= -LTTNG_ERR_NOMEM
;
1870 ret
= parse_uint(content
, &channel
->attr
.subbuf_size
);
1873 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1876 } else if (!strcmp((const char *) attr_node
->name
,
1877 config_element_num_subbuf
)) {
1880 /* subbuffer_count */
1881 content
= xmlNodeGetContent(attr_node
);
1883 ret
= -LTTNG_ERR_NOMEM
;
1887 ret
= parse_uint(content
, &channel
->attr
.num_subbuf
);
1890 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1893 } else if (!strcmp((const char *) attr_node
->name
,
1894 config_element_switch_timer_interval
)) {
1896 uint64_t switch_timer_interval
= 0;
1898 /* switch_timer_interval */
1899 content
= xmlNodeGetContent(attr_node
);
1901 ret
= -LTTNG_ERR_NOMEM
;
1905 ret
= parse_uint(content
, &switch_timer_interval
);
1908 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1912 if (switch_timer_interval
> UINT_MAX
) {
1913 WARN("switch_timer_interval out of range.");
1914 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1918 channel
->attr
.switch_timer_interval
=
1919 switch_timer_interval
;
1920 } else if (!strcmp((const char *) attr_node
->name
,
1921 config_element_read_timer_interval
)) {
1923 uint64_t read_timer_interval
= 0;
1925 /* read_timer_interval */
1926 content
= xmlNodeGetContent(attr_node
);
1928 ret
= -LTTNG_ERR_NOMEM
;
1932 ret
= parse_uint(content
, &read_timer_interval
);
1935 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1939 if (read_timer_interval
> UINT_MAX
) {
1940 WARN("read_timer_interval out of range.");
1941 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1945 channel
->attr
.read_timer_interval
=
1946 read_timer_interval
;
1947 } else if (!strcmp((const char *) attr_node
->name
,
1948 config_element_output_type
)) {
1952 content
= xmlNodeGetContent(attr_node
);
1954 ret
= -LTTNG_ERR_NOMEM
;
1958 ret
= get_output_type(content
);
1961 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1965 channel
->attr
.output
= ret
;
1966 } else if (!strcmp((const char *) attr_node
->name
,
1967 config_element_tracefile_size
)) {
1970 /* tracefile_size */
1971 content
= xmlNodeGetContent(attr_node
);
1973 ret
= -LTTNG_ERR_NOMEM
;
1977 ret
= parse_uint(content
, &channel
->attr
.tracefile_size
);
1980 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
1983 } else if (!strcmp((const char *) attr_node
->name
,
1984 config_element_tracefile_count
)) {
1987 /* tracefile_count */
1988 content
= xmlNodeGetContent(attr_node
);
1990 ret
= -LTTNG_ERR_NOMEM
;
1994 ret
= parse_uint(content
, &channel
->attr
.tracefile_count
);
1997 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2000 } else if (!strcmp((const char *) attr_node
->name
,
2001 config_element_live_timer_interval
)) {
2003 uint64_t live_timer_interval
= 0;
2005 /* live_timer_interval */
2006 content
= xmlNodeGetContent(attr_node
);
2008 ret
= -LTTNG_ERR_NOMEM
;
2012 ret
= parse_uint(content
, &live_timer_interval
);
2015 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2019 if (live_timer_interval
> UINT_MAX
) {
2020 WARN("live_timer_interval out of range.");
2021 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2025 channel
->attr
.live_timer_interval
=
2026 live_timer_interval
;
2027 } else if (!strcmp((const char *) attr_node
->name
,
2028 config_element_events
)) {
2030 *events_node
= attr_node
;
2033 *contexts_node
= attr_node
;
2041 int process_context_node(xmlNodePtr context_node
,
2042 struct lttng_handle
*handle
, const char *channel_name
)
2045 struct lttng_event_context context
;
2046 xmlNodePtr context_child_node
= xmlFirstElementChild(context_node
);
2049 assert(channel_name
);
2051 if (!context_child_node
) {
2052 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2056 memset(&context
, 0, sizeof(context
));
2058 if (!strcmp((const char *) context_child_node
->name
,
2059 config_element_type
)) {
2061 xmlChar
*content
= xmlNodeGetContent(context_child_node
);
2064 ret
= -LTTNG_ERR_NOMEM
;
2068 ret
= get_context_type(content
);
2071 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2076 } else if (!strcmp((const char *) context_child_node
->name
,
2077 config_element_context_perf
)) {
2079 xmlNodePtr perf_attr_node
;
2081 context
.ctx
= handle
->domain
.type
== LTTNG_DOMAIN_KERNEL
?
2082 LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER
:
2083 LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER
;
2084 for (perf_attr_node
= xmlFirstElementChild(context_child_node
);
2085 perf_attr_node
; perf_attr_node
=
2086 xmlNextElementSibling(perf_attr_node
)) {
2087 if (!strcmp((const char *) perf_attr_node
->name
,
2088 config_element_type
)) {
2093 content
= xmlNodeGetContent(perf_attr_node
);
2095 ret
= -LTTNG_ERR_NOMEM
;
2099 ret
= parse_uint(content
, &type
);
2102 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2106 if (type
> UINT32_MAX
) {
2107 WARN("perf context type out of range.");
2108 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2112 context
.u
.perf_counter
.type
= type
;
2113 } else if (!strcmp((const char *) perf_attr_node
->name
,
2114 config_element_config
)) {
2116 uint64_t config
= 0;
2119 content
= xmlNodeGetContent(perf_attr_node
);
2121 ret
= -LTTNG_ERR_NOMEM
;
2125 ret
= parse_uint(content
, &config
);
2128 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2132 context
.u
.perf_counter
.config
= config
;
2133 } else if (!strcmp((const char *) perf_attr_node
->name
,
2134 config_element_name
)) {
2139 content
= xmlNodeGetContent(perf_attr_node
);
2141 ret
= -LTTNG_ERR_NOMEM
;
2145 name_len
= strlen((char *) content
);
2146 if (name_len
>= LTTNG_SYMBOL_NAME_LEN
) {
2147 WARN("perf context name too long.");
2148 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2153 strncpy(context
.u
.perf_counter
.name
, (const char *) content
,
2158 } else if (!strcmp((const char *) context_child_node
->name
,
2159 config_element_context_app
)) {
2160 /* application context */
2161 xmlNodePtr app_ctx_node
;
2163 context
.ctx
= LTTNG_EVENT_CONTEXT_APP_CONTEXT
;
2164 for (app_ctx_node
= xmlFirstElementChild(context_child_node
);
2165 app_ctx_node
; app_ctx_node
=
2166 xmlNextElementSibling(app_ctx_node
)) {
2168 char **target
= strcmp(
2169 (const char *) app_ctx_node
->name
,
2170 config_element_context_app_provider_name
) == 0 ?
2171 &context
.u
.app_ctx
.provider_name
:
2172 &context
.u
.app_ctx
.ctx_name
;
2174 content
= xmlNodeGetContent(app_ctx_node
);
2176 ret
= -LTTNG_ERR_NOMEM
;
2180 *target
= (char *) content
;
2183 /* Unrecognized context type */
2184 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2188 ret
= lttng_add_context(handle
, &context
, NULL
, channel_name
);
2189 if (context
.ctx
== LTTNG_EVENT_CONTEXT_APP_CONTEXT
) {
2190 free(context
.u
.app_ctx
.provider_name
);
2191 free(context
.u
.app_ctx
.ctx_name
);
2198 int process_contexts_node(xmlNodePtr contexts_node
,
2199 struct lttng_handle
*handle
, const char *channel_name
)
2202 xmlNodePtr context_node
;
2204 for (context_node
= xmlFirstElementChild(contexts_node
); context_node
;
2205 context_node
= xmlNextElementSibling(context_node
)) {
2206 ret
= process_context_node(context_node
, handle
, channel_name
);
2216 int process_pid_tracker_node(xmlNodePtr pid_tracker_node
,
2217 struct lttng_handle
*handle
)
2220 xmlNodePtr targets_node
= NULL
;
2224 assert(pid_tracker_node
);
2225 /* get the targets node */
2226 for (node
= xmlFirstElementChild(pid_tracker_node
); node
;
2227 node
= xmlNextElementSibling(node
)) {
2228 if (!strcmp((const char *) node
->name
,
2229 config_element_targets
)) {
2230 targets_node
= node
;
2235 if (!targets_node
) {
2236 ret
= LTTNG_ERR_INVALID
;
2240 /* Go through all pid_target node */
2241 child
= xmlChildElementCount(targets_node
);
2243 /* The session is explicitly set to target nothing. */
2244 ret
= lttng_untrack_pid(handle
, -1);
2249 for (node
= xmlFirstElementChild(targets_node
); node
;
2250 node
= xmlNextElementSibling(node
)) {
2251 xmlNodePtr pid_target_node
= node
;
2253 /* get pid node and track it */
2254 for (node
= xmlFirstElementChild(pid_target_node
); node
;
2255 node
= xmlNextElementSibling(node
)) {
2256 if (!strcmp((const char *) node
->name
,
2257 config_element_pid
)) {
2259 xmlChar
*content
= NULL
;
2261 content
= xmlNodeGetContent(node
);
2263 ret
= LTTNG_ERR_LOAD_INVALID_CONFIG
;
2267 ret
= parse_int(content
, &pid
);
2270 ret
= LTTNG_ERR_LOAD_INVALID_CONFIG
;
2274 ret
= lttng_track_pid(handle
, (int) pid
);
2280 node
= pid_target_node
;
2289 int process_domain_node(xmlNodePtr domain_node
, const char *session_name
)
2292 struct lttng_domain domain
= { 0 };
2293 struct lttng_handle
*handle
= NULL
;
2294 xmlNodePtr channels_node
= NULL
;
2295 xmlNodePtr trackers_node
= NULL
;
2296 xmlNodePtr pid_tracker_node
= NULL
;
2299 assert(session_name
);
2301 ret
= init_domain(domain_node
, &domain
);
2306 handle
= lttng_create_handle(session_name
, &domain
);
2308 ret
= -LTTNG_ERR_NOMEM
;
2312 /* get the channels node */
2313 for (node
= xmlFirstElementChild(domain_node
); node
;
2314 node
= xmlNextElementSibling(node
)) {
2315 if (!strcmp((const char *) node
->name
,
2316 config_element_channels
)) {
2317 channels_node
= node
;
2322 if (!channels_node
) {
2326 /* create all channels */
2327 for (node
= xmlFirstElementChild(channels_node
); node
;
2328 node
= xmlNextElementSibling(node
)) {
2329 struct lttng_channel channel
;
2330 xmlNodePtr contexts_node
= NULL
;
2331 xmlNodePtr events_node
= NULL
;
2332 xmlNodePtr channel_attr_node
;
2334 memset(&channel
, 0, sizeof(channel
));
2335 lttng_channel_set_default_attr(&domain
, &channel
.attr
);
2337 for (channel_attr_node
= xmlFirstElementChild(node
);
2338 channel_attr_node
; channel_attr_node
=
2339 xmlNextElementSibling(channel_attr_node
)) {
2340 ret
= process_channel_attr_node(channel_attr_node
,
2341 &channel
, &contexts_node
, &events_node
);
2347 ret
= lttng_enable_channel(handle
, &channel
);
2352 ret
= process_events_node(events_node
, handle
, channel
.name
);
2357 ret
= process_contexts_node(contexts_node
, handle
,
2364 /* get the trackers node */
2365 for (node
= xmlFirstElementChild(domain_node
); node
;
2366 node
= xmlNextElementSibling(node
)) {
2367 if (!strcmp((const char *) node
->name
,
2368 config_element_trackers
)) {
2369 trackers_node
= node
;
2374 if (!trackers_node
) {
2378 for (node
= xmlFirstElementChild(trackers_node
); node
;
2379 node
= xmlNextElementSibling(node
)) {
2380 if (!strcmp((const char *)node
->name
,config_element_pid_tracker
)) {
2381 pid_tracker_node
= node
;
2382 ret
= process_pid_tracker_node(pid_tracker_node
, handle
);
2389 if (!pid_tracker_node
) {
2390 lttng_track_pid(handle
, -1);
2394 lttng_destroy_handle(handle
);
2399 int process_session_node(xmlNodePtr session_node
, const char *session_name
,
2402 int ret
, started
= -1, snapshot_mode
= -1;
2403 uint64_t live_timer_interval
= UINT64_MAX
;
2404 xmlChar
*name
= NULL
;
2405 xmlChar
*shm_path
= NULL
;
2406 xmlNodePtr domains_node
= NULL
;
2407 xmlNodePtr output_node
= NULL
;
2409 struct lttng_domain
*kernel_domain
= NULL
;
2410 struct lttng_domain
*ust_domain
= NULL
;
2411 struct lttng_domain
*jul_domain
= NULL
;
2412 struct lttng_domain
*log4j_domain
= NULL
;
2413 struct lttng_domain
*python_domain
= NULL
;
2415 for (node
= xmlFirstElementChild(session_node
); node
;
2416 node
= xmlNextElementSibling(node
)) {
2417 if (!name
&& !strcmp((const char *) node
->name
,
2418 config_element_name
)) {
2420 xmlChar
*node_content
= xmlNodeGetContent(node
);
2421 if (!node_content
) {
2422 ret
= -LTTNG_ERR_NOMEM
;
2426 name
= node_content
;
2427 } else if (!domains_node
&& !strcmp((const char *) node
->name
,
2428 config_element_domains
)) {
2430 domains_node
= node
;
2431 } else if (started
== -1 && !strcmp((const char *) node
->name
,
2432 config_element_started
)) {
2434 xmlChar
*node_content
= xmlNodeGetContent(node
);
2435 if (!node_content
) {
2436 ret
= -LTTNG_ERR_NOMEM
;
2440 ret
= parse_bool(node_content
, &started
);
2443 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2446 } else if (!output_node
&& !strcmp((const char *) node
->name
,
2447 config_element_output
)) {
2450 } else if (!shm_path
&& !strcmp((const char *) node
->name
,
2451 config_element_shared_memory_path
)) {
2452 /* shared memory path */
2453 xmlChar
*node_content
= xmlNodeGetContent(node
);
2454 if (!node_content
) {
2455 ret
= -LTTNG_ERR_NOMEM
;
2459 shm_path
= node_content
;
2461 /* attributes, snapshot_mode or live_timer_interval */
2462 xmlNodePtr attributes_child
=
2463 xmlFirstElementChild(node
);
2465 if (!strcmp((const char *) attributes_child
->name
,
2466 config_element_snapshot_mode
)) {
2468 xmlChar
*snapshot_mode_content
=
2469 xmlNodeGetContent(attributes_child
);
2470 if (!snapshot_mode_content
) {
2471 ret
= -LTTNG_ERR_NOMEM
;
2475 ret
= parse_bool(snapshot_mode_content
, &snapshot_mode
);
2476 free(snapshot_mode_content
);
2478 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2482 /* live_timer_interval */
2483 xmlChar
*timer_interval_content
=
2484 xmlNodeGetContent(attributes_child
);
2485 if (!timer_interval_content
) {
2486 ret
= -LTTNG_ERR_NOMEM
;
2490 ret
= parse_uint(timer_interval_content
, &live_timer_interval
);
2491 free(timer_interval_content
);
2493 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2501 /* Mandatory attribute, as defined in the session XSD */
2502 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2506 if (session_name
&& strcmp((char *) name
, session_name
)) {
2507 /* This is not the session we are looking for */
2508 ret
= -LTTNG_ERR_NO_SESSION
;
2512 /* Init domains to create the session handles */
2513 for (node
= xmlFirstElementChild(domains_node
); node
;
2514 node
= xmlNextElementSibling(node
)) {
2515 struct lttng_domain
*domain
;
2517 domain
= zmalloc(sizeof(*domain
));
2519 ret
= -LTTNG_ERR_NOMEM
;
2523 ret
= init_domain(node
, domain
);
2525 goto domain_init_error
;
2528 switch (domain
->type
) {
2529 case LTTNG_DOMAIN_KERNEL
:
2530 if (kernel_domain
) {
2531 /* Same domain seen twice, invalid! */
2532 goto domain_init_error
;
2534 kernel_domain
= domain
;
2536 case LTTNG_DOMAIN_UST
:
2538 /* Same domain seen twice, invalid! */
2539 goto domain_init_error
;
2541 ust_domain
= domain
;
2543 case LTTNG_DOMAIN_JUL
:
2545 /* Same domain seen twice, invalid! */
2546 goto domain_init_error
;
2548 jul_domain
= domain
;
2550 case LTTNG_DOMAIN_LOG4J
:
2552 /* Same domain seen twice, invalid! */
2553 goto domain_init_error
;
2555 log4j_domain
= domain
;
2557 case LTTNG_DOMAIN_PYTHON
:
2558 if (python_domain
) {
2559 /* Same domain seen twice, invalid! */
2560 goto domain_init_error
;
2562 python_domain
= domain
;
2565 WARN("Invalid domain type");
2566 goto domain_init_error
;
2571 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2576 /* Destroy session if it exists */
2577 ret
= lttng_destroy_session((const char *) name
);
2578 if (ret
&& ret
!= -LTTNG_ERR_SESS_NOT_FOUND
) {
2579 ERR("Failed to destroy existing session.");
2584 /* Create session type depending on output type */
2585 if (snapshot_mode
&& snapshot_mode
!= -1) {
2586 ret
= create_snapshot_session((const char *) name
, output_node
);
2587 } else if (live_timer_interval
&&
2588 live_timer_interval
!= UINT64_MAX
) {
2589 ret
= create_session((const char *) name
, kernel_domain
,
2590 ust_domain
, jul_domain
, log4j_domain
,
2591 output_node
, live_timer_interval
);
2593 /* regular session */
2594 ret
= create_session((const char *) name
, kernel_domain
,
2595 ust_domain
, jul_domain
, log4j_domain
,
2596 output_node
, UINT64_MAX
);
2603 ret
= lttng_set_session_shm_path((const char *) name
,
2604 (const char *) shm_path
);
2610 for (node
= xmlFirstElementChild(domains_node
); node
;
2611 node
= xmlNextElementSibling(node
)) {
2612 ret
= process_domain_node(node
, (const char *) name
);
2619 ret
= lttng_start_tracing((const char *) name
);
2627 ERR("Failed to load session %s: %s", (const char *) name
,
2628 lttng_strerror(ret
));
2629 lttng_destroy_session((const char *) name
);
2633 free(kernel_domain
);
2637 free(python_domain
);
2644 * Return 1 if the given path is readable by the current UID or 0 if not.
2645 * Return -1 if the path is EPERM.
2647 static int validate_file_read_creds(const char *path
)
2653 /* Can we read the file. */
2654 ret
= access(path
, R_OK
);
2658 if (errno
== EACCES
) {
2669 int load_session_from_file(const char *path
, const char *session_name
,
2670 struct session_config_validation_ctx
*validation_ctx
, int override
)
2672 int ret
, session_found
= !session_name
;
2673 xmlDocPtr doc
= NULL
;
2674 xmlNodePtr sessions_node
;
2675 xmlNodePtr session_node
;
2678 assert(validation_ctx
);
2680 ret
= validate_file_read_creds(path
);
2683 ret
= -LTTNG_ERR_EPERM
;
2685 ret
= -LTTNG_ERR_LOAD_SESSION_NOENT
;
2690 doc
= xmlParseFile(path
);
2692 ret
= -LTTNG_ERR_LOAD_IO_FAIL
;
2696 ret
= xmlSchemaValidateDoc(validation_ctx
->schema_validation_ctx
, doc
);
2698 ERR("Session configuration file validation failed");
2699 ret
= -LTTNG_ERR_LOAD_INVALID_CONFIG
;
2703 sessions_node
= xmlDocGetRootElement(doc
);
2704 if (!sessions_node
) {
2708 for (session_node
= xmlFirstElementChild(sessions_node
);
2709 session_node
; session_node
=
2710 xmlNextElementSibling(session_node
)) {
2711 ret
= process_session_node(session_node
,
2712 session_name
, override
);
2713 if (session_name
&& ret
== 0) {
2714 /* Target session found and loaded */
2722 ret
= session_found
? 0 : -LTTNG_ERR_LOAD_SESSION_NOENT
;
2727 /* Allocate dirent as recommended by READDIR(3), NOTES on readdir_r */
2729 struct dirent
*alloc_dirent(const char *path
)
2733 struct dirent
*entry
;
2735 name_max
= pathconf(path
, _PC_NAME_MAX
);
2736 if (name_max
== -1) {
2737 name_max
= PATH_MAX
;
2739 len
= offsetof(struct dirent
, d_name
) + name_max
+ 1;
2740 entry
= zmalloc(len
);
2745 int load_session_from_path(const char *path
, const char *session_name
,
2746 struct session_config_validation_ctx
*validation_ctx
, int override
)
2748 int ret
, session_found
= !session_name
;
2749 DIR *directory
= NULL
;
2752 assert(validation_ctx
);
2754 directory
= opendir(path
);
2758 /* Try the file loading. */
2761 ret
= -LTTNG_ERR_LOAD_SESSION_NOENT
;
2764 ret
= -LTTNG_ERR_LOAD_IO_FAIL
;
2769 struct dirent
*entry
;
2770 struct dirent
*result
;
2771 char *file_path
= NULL
;
2772 size_t path_len
= strlen(path
);
2774 if (path_len
>= PATH_MAX
) {
2775 ret
= -LTTNG_ERR_INVALID
;
2779 entry
= alloc_dirent(path
);
2781 ret
= -LTTNG_ERR_NOMEM
;
2785 file_path
= zmalloc(PATH_MAX
);
2787 ret
= -LTTNG_ERR_NOMEM
;
2792 strncpy(file_path
, path
, path_len
);
2793 if (file_path
[path_len
- 1] != '/') {
2794 file_path
[path_len
++] = '/';
2798 /* Search for *.lttng files */
2799 while (!readdir_r(directory
, entry
, &result
) && result
) {
2800 size_t file_name_len
= strlen(result
->d_name
);
2802 if (file_name_len
<=
2803 sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION
)) {
2807 if (path_len
+ file_name_len
>= PATH_MAX
) {
2811 if (strcmp(DEFAULT_SESSION_CONFIG_FILE_EXTENSION
,
2812 result
->d_name
+ file_name_len
- sizeof(
2813 DEFAULT_SESSION_CONFIG_FILE_EXTENSION
) + 1)) {
2817 strncpy(file_path
+ path_len
, result
->d_name
, file_name_len
);
2818 file_path
[path_len
+ file_name_len
] = '\0';
2820 ret
= load_session_from_file(file_path
, session_name
,
2821 validation_ctx
, override
);
2822 if (session_name
&& !ret
) {
2831 ret
= load_session_from_file(path
, session_name
,
2832 validation_ctx
, override
);
2842 if (closedir(directory
)) {
2847 if (session_found
) {
2855 * Validate that the given path's credentials and the current process have the
2856 * same UID. If so, return 1 else return 0 if it does NOT match.
2858 static int validate_path_creds(const char *path
)
2860 int ret
, uid
= getuid();
2869 ret
= stat(path
, &buf
);
2871 if (errno
!= ENOENT
) {
2874 ret
= -LTTNG_ERR_INVALID
;
2878 if (buf
.st_uid
!= uid
) {
2889 int config_load_session(const char *path
, const char *session_name
,
2890 int override
, unsigned int autoload
)
2893 bool session_loaded
= false;
2894 const char *path_ptr
= NULL
;
2895 struct session_config_validation_ctx validation_ctx
= { 0 };
2897 ret
= init_session_config_validation_ctx(&validation_ctx
);
2904 const char *sys_path
;
2907 home_path
= utils_get_home_dir();
2909 char path
[PATH_MAX
];
2912 * Try user session configuration path. Ignore error here so we can
2913 * continue loading the system wide sessions.
2916 ret
= snprintf(path
, sizeof(path
),
2917 DEFAULT_SESSION_HOME_CONFIGPATH
"/"
2918 DEFAULT_SESSION_CONFIG_AUTOLOAD
, home_path
);
2920 PERROR("snprintf session autoload home config path");
2925 * Credentials are only validated for the autoload in order to
2926 * avoid any user session daemon to try to load kernel sessions
2927 * automatically and failing all the times.
2929 ret
= validate_path_creds(path
);
2934 ret
= snprintf(path
, sizeof(path
),
2935 DEFAULT_SESSION_HOME_CONFIGPATH
, home_path
);
2937 PERROR("snprintf session home config path");
2943 ret
= load_session_from_path(path_ptr
, session_name
,
2944 &validation_ctx
, override
);
2945 if (ret
&& ret
!= -LTTNG_ERR_LOAD_SESSION_NOENT
) {
2949 * Continue even if the session was found since we have to try
2950 * the system wide sessions.
2952 session_loaded
= true;
2956 /* Reset path pointer for the system wide dir. */
2959 /* Try system wide configuration directory. */
2961 sys_path
= DEFAULT_SESSION_SYSTEM_CONFIGPATH
"/"
2962 DEFAULT_SESSION_CONFIG_AUTOLOAD
;
2963 ret
= validate_path_creds(sys_path
);
2965 path_ptr
= sys_path
;
2968 sys_path
= DEFAULT_SESSION_SYSTEM_CONFIGPATH
;
2969 path_ptr
= sys_path
;
2973 ret
= load_session_from_path(path_ptr
, session_name
,
2974 &validation_ctx
, override
);
2976 session_loaded
= true;
2980 ret
= access(path
, F_OK
);
2985 ret
= -LTTNG_ERR_INVALID
;
2986 WARN("Session configuration path does not exist.");
2989 ret
= -LTTNG_ERR_EPERM
;
2992 ret
= -LTTNG_ERR_UNK
;
2998 ret
= load_session_from_path(path
, session_name
,
2999 &validation_ctx
, override
);
3002 fini_session_config_validation_ctx(&validation_ctx
);
3003 if (ret
== -LTTNG_ERR_LOAD_SESSION_NOENT
&& !session_name
&& !path
) {
3005 * Don't report an error if no sessions are found when called
3006 * without a session_name or a search path.
3011 if (session_loaded
&& ret
== -LTTNG_ERR_LOAD_SESSION_NOENT
) {
3012 /* A matching session was found in one of the search paths. */
3019 void __attribute__((destructor
)) session_config_exit(void)