Force usage of assert() condition when NDEBUG is defined Reuse the BT2 approach to force the usage of the assertion condition even when assert() are removed by the NDEBUG define. See `BT_USE_EXPR()` macro and documentation in Babeltrace commit[0]: commit 1778c2a4134647150b199b2b57130817144446b0 Author: Philippe Proulx <eeppeliteloop@gmail.com> Date: Tue Apr 21 11:15:42 2020 -0400 lib: assign a unique ID to each pre/postcond. and report it on failure 0: https://github.com/efficios/babeltrace/commit/1778c2a4134647150b199b2b57130817144446b0 Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I3844b6ae7e95952d90033898397ac936540b785c
Fix: backward relayd: path contains a leading "ust" folder Observed issue ============== test_output_path_relayd[lttng-tools-2.13-lttng-tools-2.10-uid] from the lttng-ivc fails on path validation for the resulting trace. Here lttng-sessiond is 2.13 and lttng-relayd is 2.10 Traces are generated and the following hierarchy is found in the lttng-relayd trace folder. lttng_home └── lttng-traces * └── ust └── joraj-alpa ├── auto-20210113-165054 │ └── ust │ └── uid Note the extra "ust" (*) in the hierarchy. The tests expects: lttng_home └── lttng-traces └── joraj-alpa ├── auto-20210113-165054 │ └── ust │ └── uid Cause ===== Introduced by: 5da88b0f58d7f838068037ea449ddfb25d3e85ad [1] relayd_add_stream now suffixes the domain_name to the pathname. This is only necessary for cases where the corresponding lttng-relayd version is greater than 2.10. In other cases, modification of pathname is not necessary. Solution ======== Perform domain suffixing only for relayd > 2.10. Known drawbacks ========= None. References ========== [1] https://github.com/lttng/lttng-tools/commit/5da88b0f58d7f838068037ea449ddfb25d3e85ad Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: Iaca4667074aaf7f4f20b50ddb4778fbc02156b5a
Clean-up: relayd: missing space in debug statement Missing space in rotation debug statement results in logs of the form: [...] Rotate stream 1at sequence number 4 [...] Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com> Change-Id: I7f950224f52164d30f896d0b2bcc59304f842cf1
Move to kernel style SPDX license identifiers The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. See https://spdx.org/ids-how for details. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Change-Id: I62e7038e191a061286abcef5550b58f5ee67149d Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
relayd: Implement get_configuration relayd protocol command Introduce a "GET_CONFIGURATION" command to the relayd protocol. This allows checking whether the relay daemon allows the clear command or not. A 64-bit set of flags are returned, and it can be extended in the future with a variable length payload. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I33a03d09871f1c0c248d5514451c533ffd773979 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Send ust and kernel domain directory handle to consumer Send a directory handle to ust/ and kernel/ subdirectories of the chunk to the consumer daemon, and alter the paths sent to consumer so they do not include the domain subdir. This will facilitate implementation of the clear command when no rotation has been performed. The clear command will need to move the ust/ and kernel/ directories to a "deleted" temporary directory while the consumer is still actively using those directories. Making sure that the consumer uses a handle on those subdirectories only ensures that the consumer will not observe any transient state when those directories are moved. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I2357ad702f810561c4d11405edc3ef204fc6c455 Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: relayd: Dereference before null check Coverity report: CID 1405858 (#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking base_path suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Reported-by: Coverity (1405858) Dereference before null check Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Cleanup: relayd: Logically dead code Coverity report: CID 1404935 (#1 of 1): Logically dead code (DEADCODE)dead_error_line: Execution cannot reach the expression 0UL inside this statement: base_path_len = (base_path Reported-by: Coverity (1404935) Logically dead code Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: chunk state is not set when relayd does not support trace chunks Being explicit here enforces that for a lttng-relayd that does not support chunks, the queried chunk will never exist. This caused a lttng destroy command to hang during backward compatibility testing with older lttng-relayd. Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
relayd protocol: reply path for close chunk and create session 2.11 Since the relay daemon is expected to be able to move the target destination of the trace, reply the chunk and session path so session can have relevant data rather than guessing their location. The session daemon now use this information to send the path back to the client for rotation and destroy commands, as well as for rotation completion notifications. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: streaming and snapshot backward compat for relayd < 2.11 Fix backward compatibility of session daemon 2.11 with relayd versions prior to 2.11. Session daemon and consumer daemon 2.11 use the "chunk" object to represent the current output directory. However, both sessiond and consumerd need to ensure they do not send chunk and rotation commands to a relayd older than 2.11, and tweak the stream paths accordingly. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
relayd comm: add base path to create session Add base path and session_name_contains_creation_time flag to session creation 2.11 message. Use it to ensure the "auto-<ts>" session names don't get duplicate timestamps for their output paths. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fix: honor base path for network URIs Starting from 2.11, the following use-case stopped working as expected: lttng create --set-url=net://localhost/my/path/custom lttng enable-event -u -a lttng start [ run app ] The output trace is expected in the following directory on the relayd (no timestamp suffix): $LTTNG_HOME/lttng-traces/[hostname]/my/path/custom Add the base_path information to the session object in the session daemon, extracted from the network URI, and pass that information to the relay daemon through the create session (2.11) command. It also fixes the use-case: lttng create --snapshot --set-url=net://localhost/my/path/custom lttng enable-event -u -a lttng start [ run app ] lttng snapshot record which is expected to record the snapshot under: $LTTNG_HOME/lttng-traces/[hostname]/my/path/custom/snapshot-[N]-[timestamp] Similar situation for: lttng create --snapshot lttng enable-event -u -a lttng start [ run app ] lttng snapshot record net://localhost/my/path/custom which is expected to record the snapshot under: $LTTNG_HOME/lttng-traces/[hostname]/my/path/custom/snapshot-[N]-[timestamp] Note that specifying the base_path on the snapshot record command overrides the base path specified at create. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
relayd: open live viewer files from the current stream's trace chunk Since relay_streams' paths are now relative to a session's trace chunk, file operations performed by the live protocol handler must occur through a trace chunk. Note that viewer streams hold a reference to the current trace chunk of their corresponding relay stream. This is fine right now as no session rotations may occur during the lifetime of a live session. If this was allowed, this would be a problem since a session rotation would not complete until all live viewer streams release their reference to the trace chunk. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
relayd: implement file and session rotation on top of trace chunks Implement the file and session rotation functionality on top of the trace chunk API. This ensures that a relay_stream and lttng_index_file are always explicitly associated to a trace chunk and hold a reference to it as long as their underlying files are contained within a given trace chunk. A number of relay_stream specific functions are moved to stream.c as "methods" of the relay_stream interface in order to make use of internal relay_stream helpers. As part of this clean-up/move of the relay_stream code, raw payload buffer handling has been replaced to use the lttng_buffer_view interface which provides implicit bounds checking of the payload buffers. The stream rotation has been modified to reference a "new chunk id" which is the ID of the trace chunk to which streams should rotate "into". The command has also been modified to apply on a set of streams. This is done in order to limit the number of commands on the control socket. Conversely, all path names have been removed from the command's payload. The index file implementation now acquires a reference to the trace chunk from which it is created. This affects the consumer daemon as this code is shared with the relay daemon. This ensures that a chunk is not released (and its close command executed, if any) before all file descriptors related to it have been closed. Respecting this guarantee is very important as the upcoming fd-cache will remove the guarantee that an "fd" to a given file is always held open. Moreover, close commands can rename a trace chunk's folders which would cause files to be created in the wrong folder if they are not properly created through the trace chunk. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
relayd: create stream files relative to a session's trace chunk Like to the consumer daemon, the relay daemon now creates its stream files through the lttng_trace_chunk interface. This requires changes across the session daemon and relay daemon. The changes to the relay daemon mainly target the file creation. In the session daemon, the snapshot command has been heavily modified to fully initialize the ltt_session's ust and kernel consumer_outputs _before_ the snapshot trace chunk is created. This way, the session is setup in the same way a regular network streaming session would be, a temporary trace chunk is created to contain the snapshot's content, the actual snapshot is taken, and the session's original consumer_outputs are restored. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Send session creation time to relay daemon when supported A recent commit changed the way the creation timestamp was added to a session's output path; the session creation timestamp is now (2.11+) sampled at creation time and formatted when the session's output directory is created. The 2.11+ version of the session and stream creation commands allow the relay daemon to use all components of the path independently to format an output path rather than relying on the session daemon peer to format it ahead of time. In order to maintain the timestamped session folder name created by previous versions, the relay daemon now receives the session's creation timestamp and formats it rather than relying on it being "cooked" into the transmitted session name. Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>