lttng-tools.git
2 years agoLTTNG-RELAYD(8): document the --fd-pool-size option
Jérémie Galarneau [Thu, 5 Jul 2018 01:28:18 +0000 (21:28 -0400)] 
LTTNG-RELAYD(8): document the --fd-pool-size option

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie8d791d15ba4186dc862d048d20afff7d128cea3

2 years agorelayd: rename fd-cap parameter to fd-pool-size
Jérémie Galarneau [Wed, 27 Nov 2019 06:11:02 +0000 (01:11 -0500)] 
relayd: rename fd-cap parameter to fd-pool-size

Rename the fd-cap parameter and change its default behaviour.
The minimum number of file descriptor is raised to 100 and a
"reserve" amount of 10 fds is allowed to accomodate transient
fd uses that can't be tracked by the relay daemon.

The --fd-pool-size will accept parameters in the
[100, fileno soft limit] interval.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9c7bf344344901b4d6f0d95620210ebda5fd0196

2 years agorelayd: track the live client connections socket
Jérémie Galarneau [Wed, 27 Nov 2019 06:01:28 +0000 (01:01 -0500)] 
relayd: track the live client connections socket

Track all live client connection socket file descritptors through the
fd-tracker. Those file descriptors, being TCP connections, are
unsuspendable.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iacc958b0f8d168d13165e44ec8432ad29ef881f5

2 years agorelayd: track the control and data listener socket
Jérémie Galarneau [Wed, 27 Nov 2019 05:57:08 +0000 (00:57 -0500)] 
relayd: track the control and data listener socket

Create the control and data listener sockets through the create_sock()
wrapper in order to allow the fd tracker to track it as an
unsuspendable file descriptor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I58e66386c195b78a44d88d3592d7b1d75ff091a3

2 years agorelayd: track the live listener socket
Jérémie Galarneau [Wed, 27 Nov 2019 05:42:00 +0000 (00:42 -0500)] 
relayd: track the live listener socket

Create the live listener socket through the create_sock()
wrapper in order to allow the fd tracker to track it as an
unsuspendable file descriptor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I12c831967b0b33aa3d58c2319cdaf0dc3ccda7e3

2 years agorelayd: track stdio output file descriptors
Jérémie Galarneau [Wed, 27 Nov 2019 05:32:24 +0000 (00:32 -0500)] 
relayd: track stdio output file descriptors

Track the stdout and stderr file descriptors through the fd
tracker. These file descriptors are considered unsuspendable
since they can't be re-opened.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibd80fb1ba1b21ee152bae6047a5dd176d1d2c051

2 years agorelayd: track the live viewer worker thread's epoll fd
Jérémie Galarneau [Wed, 27 Nov 2019 05:30:24 +0000 (00:30 -0500)] 
relayd: track the live viewer worker thread's epoll fd

Create the live worker threads' epoll fd through the
fd_tracker_util_poll_create() util. This causes the resulting fd
(in epoll mode) to be tracked by the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I60b386b90e274283c566d94cfd4abcf57e0c1985

2 years agorelayd: track the live listener thread's epoll fd
Jérémie Galarneau [Wed, 27 Nov 2019 05:28:51 +0000 (00:28 -0500)] 
relayd: track the live listener thread's epoll fd

Create the live listener threads' epoll fd through the
fd_tracker_util_poll_create() util. This causes the resulting fd
(in epoll mode) to be tracked by the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If93fe5b1cc85d5d3950941edd47910697727ced9

2 years agorelayd: track the live_conn_pipe with the fd-tracker
Jérémie Galarneau [Wed, 27 Nov 2019 05:23:15 +0000 (00:23 -0500)] 
relayd: track the live_conn_pipe with the fd-tracker

Create the relayd live connection pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I967c2fbecfb5dacfb8c41cad113604bad78dad65

2 years agorelayd: track listener's epoll fd using the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 23:22:29 +0000 (18:22 -0500)] 
relayd: track listener's epoll fd using the fd-tracker

This addresses the bogus fd report mentionned in a previous patch of
this series as the clean-up of the listener thread's epoll fd now
occurs through the fd-tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I56bdc7f0f7c43993e44bcfc220bc09af561ace56

2 years agorelayd: track worker thread's epoll fd using the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 23:14:57 +0000 (18:14 -0500)] 
relayd: track worker thread's epoll fd using the fd-tracker

This commit introduces an fd leak report (bogus) which is caused
by another thread using the same poll initialization functions as
the worker thread.

The fd is cleaned-up by that other thread, but the fd-tracker
is not aware of this, thus causing the report.

This is adressed in a follow-up patch.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I105fddcf3421373f9746c1d8f31016462af2448e

2 years agorelayd: track clients of the health unix socket with the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 23:20:35 +0000 (18:20 -0500)] 
relayd: track clients of the health unix socket with the fd-tracker

accept connections to the health unix socket through a new fd-tracker
wrapper, accept_unix_socket, which allows the fd-tracker to track the
newly-created file descriptor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3d58b7fab15451cae404b13fd5d4b23a7c79988a

2 years agorelayd: track the health quit pipe with the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 22:10:02 +0000 (17:10 -0500)] 
relayd: track the health quit pipe with the fd-tracker

Create the relayd health thread quit pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib82eabc0f152a706ac76a5042af2e3984d7e7f72

2 years agorelayd: track the relay_conn_pipe with the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 22:07:41 +0000 (17:07 -0500)] 
relayd: track the relay_conn_pipe with the fd-tracker

Create the relayd connection pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6ed0d64c973a454de2e50c7cae006fd546299290

2 years agorelayd: track the quit pipe with the fd-tracker
Jérémie Galarneau [Tue, 26 Nov 2019 22:08:52 +0000 (17:08 -0500)] 
relayd: track the quit pipe with the fd-tracker

Create the relayd quit pipe through the
fd_tracker_util_pipe_open_cloexec() function which wraps
utils_create_pipe_cloexec(), but tracks the resulting file descriptor.

The close of the pipe is also performed through the fd tracker.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia2a000030765e8df990e0ea3d35a8bf157630d9f

2 years agorelayd: Don't bypass the fd tracker when closing file descriptors
Jérémie Galarneau [Tue, 26 Nov 2019 20:41:26 +0000 (15:41 -0500)] 
relayd: Don't bypass the fd tracker when closing file descriptors

There is no reason to close all file descriptors at this point in the
relay daemon as we know for a fact that the only open fds are stdout
and stderr. If the relayd was to depend on a library that opens other
file descriptors, it would be unadvisable to perform this kind of bulk
closing of all possible file descriptors.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8ff134094b16dfb6c1aeb875431fdbd4f608eebd

2 years agorelayd: initialize the global fd tracker from fd_cap option
Jérémie Galarneau [Tue, 26 Nov 2019 20:15:33 +0000 (15:15 -0500)] 
relayd: initialize the global fd tracker from fd_cap option

Initialize the relay daemon's global fd tracker from the current
fd-cap configuration. This is in preparation for follow-up patches
which will introduce the tracking of the various file descriptor
backed resources to the relay daemon.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iaabb80f1fb4d24345b750503c90388f94025159d

2 years agorelayd: clean-up: reduce the number of exit paths in main()
Jérémie Galarneau [Wed, 27 Nov 2019 18:20:32 +0000 (13:20 -0500)] 
relayd: clean-up: reduce the number of exit paths in main()

The relay daemons's initialization and teardown relies on a large
number of goto/labels to clean-up on failure to launch.

All of the clean-up can be performed unconditionally by checking for
NULL or uninitialized file descriptors in relayd_cleanup(). This
reduces the number of possible tear-down paths and partly initialized
state to keep track of.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3195caf05b3dd04cc7e9c60dcb322261159fe0df

2 years agorelayd: add fd-cap option to limit the number of opened FDs
Jérémie Galarneau [Tue, 26 Nov 2019 20:08:01 +0000 (15:08 -0500)] 
relayd: add fd-cap option to limit the number of opened FDs

Add an --fd-cap option to the relay daemon in order to allow the
launch of the relay daemon with a maximal number of file descriptors
to be open at any given moment.

When the value of the --fd-cap parameter is left unset, the maximal
number of file descriptors is set to the system's NOFILE soft limit
(see GETRLIMIT(3P)).

A minimal number of file descriptors of 30 is imposed, mainly to
prevent absurd configurations (someone setting 1 fd) which would not
even allow one target to connect and stream traces. This also allows
a bit of leverage to open file descriptors that could be needed by
future changes without "breaking" an existing configuration.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibaf49b25ccf3e3a8013115c9478744ca3646e306

2 years agoFix: use lttng_tracker_id_status enum values
Jonathan Rajotte [Tue, 21 Jan 2020 19:23:07 +0000 (14:23 -0500)] 
Fix: use lttng_tracker_id_status enum values

This is probably a copy paste error. This should not be a problem in any
case since the final values for both enums are the same.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ia1dc173a4eae8b7d9bff35a718c93331b714f5d6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: update context types for Python bindings
Christophe Bedard [Sat, 18 Jan 2020 19:29:49 +0000 (14:29 -0500)] 
Fix: update context types for Python bindings

Fixes: #1214
Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: lttng: placing probe on symbol starting with `_`
Francis Deslauriers [Fri, 17 Jan 2020 17:45:51 +0000 (12:45 -0500)] 
Fix: lttng: placing probe on symbol starting with `_`

Issue
=====
The lttng CLI tool does not parse `--probe` symbol name properly if the
name has an underscore at the beginning.
For example, the following command fails
  lttng enable-event -k --probe _do_fork my_do_fork_event

This happens because the `parse_probe_opts()` function looks if the
first character of the symbol field is an alphabetic character to
determine if a symbol was provided. The problem is that some kernel
symbols such as `_do_fork` start with an underscore.

Solution
========
check if the first character is an alphabetic character OR an
underscore.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3ee6c26641ceee508ee78e895d372c6b09fe90fb
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: build failure with -fno-common
Michael Jeanson [Thu, 16 Jan 2020 19:34:47 +0000 (14:34 -0500)] 
Fix: build failure with -fno-common

GCC 10 will default to building with -fno-common, this inhibits the
linker from merging multiple tentative definitions of a symbol in an
archive.

I'm not sure I understand what happen with the symbols in mi-lttng.h
but a similar issue was adressed in:

  commit 4965f956f3ef47388fb4a1b2f8f504abfe31afe7
  Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
  Date:   Fri May 22 12:53:30 2015 -0400

    Fix: Mark MI and Config string declarations as extern

    This fixes a build issue with GCC 5.1 which would complain about
    these symbols being defined multiple times.

Make sure these symbols are extern and defined only in one compile unit.

For more information, see:
https://gcc.gnu.org/gcc-10/porting_to.html

Change-Id: I139c9695371836cb1011f9ce192080b602ed2fbc
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: Tests: missing stream redirect causes test failure
Francis Deslauriers [Thu, 16 Jan 2020 01:52:39 +0000 (20:52 -0500)] 
Fix: Tests: missing stream redirect causes test failure

The following commit enforced the use of options (instead of arguments)
in the `gen-ust-events` test application:
  commit 6c4a91d639747f260ab46decebc50998ef063712
  Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  Date:   Mon Aug 26 14:22:06 2019 -0400

      tests: gen-ust-events: use options instead of arguments

This makes tests exit (and abort since commit 56d4838) when arguments
are passed to the test application. It currently fails with the
following error:
  ./gen-ust-events -i 32 -w 21 \
    --sync-after-first-event /tmp/allo.hi \
    --sync-before-last-event /tmp/allo.bye /dev/null
  Error: takes long options only.
  zsh: abort (core dumped)  ./gen-ust-events -i 32 -w 21 --sync-after-first-event /tmp/allo.hi

The `/dev/null` at the end of the command line is not associated with an
option so it triggers the sanity check. The `/dev/null` most probably
meant to redirect STDOUT to `/dev/null`.

This commit adds the missing `>` so to overcome the sanity check
problem.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3e4d4066079055a542438a63ef4df5c5c4c080cf
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: automatic enum value overwrites existing error code value
Jonathan Rajotte [Mon, 13 Jan 2020 20:40:15 +0000 (15:40 -0500)] 
Fix: automatic enum value overwrites existing error code value

Automatic enum value are generated using the last value and
incrementing it. Having backward compat assignation before the
LTTNG_ERR_NR would end up overwriting the error string since the
LTTNG_ERR_NR value would be LTTNG_ERR_PID_NOT_TRACKED + 1.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I4076866a28961fa49eed018e8249d2cd72979a84
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agodoc: Fix bind address example for lttng-relayd
Benjamin Poirier [Mon, 6 Jan 2020 05:19:54 +0000 (14:19 +0900)] 
doc: Fix bind address example for lttng-relayd

INADDR_ANY is 0.0.0.0

Fixes: c93eadade277 ("doc/man: use propagated default values in man pages")
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Benjamin Poirier <benjamin.poirier@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6e908adca66b829128ea31cf392bccad3f96d63d

2 years agoBuild fix: dist target builds fails due to missing header file
Jérémie Galarneau [Wed, 15 Jan 2020 00:33:21 +0000 (19:33 -0500)] 
Build fix: dist target builds fails due to missing header file

The path.h compatibility header is not distributed, causing builds
from tarballs to fail. Add it to the SOURCES variable.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib112c6016e9e682545572b8ab01728996c41ed52

2 years agoFix: track-untrack.c: regression of `--all --pid` option ordering
Francis Deslauriers [Tue, 7 Jan 2020 20:34:07 +0000 (15:34 -0500)] 
Fix: track-untrack.c: regression of `--all --pid` option ordering

Background
==========
The `tests/regression/kernel/test_callstack` test uses the PID tracker
to restrict what events end up in the trace. It does that by using the
following lttng command:
  lttng untrack -s $SESSION_NAME --all --pid -k

Issue
=====
A regression was introduced along with the UID tracker patch series that
makes the above command fail silently and return status 1. The bug is in
the argument parsing function that assumes that the tracker option
(`--pid` in this case) would appear before the `--all` option.

Where the above command fails, the one below works as expected:
  lttng untrack -s $SESSION_NAME --pid --all -k

Both ordering are valid and should be accepted.

Fix
===
When parsing the arguments, first record the fact that we encountered the
`--all` flag, and later check to what tracker it applies too.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I85f7a2fa8d6f67056aeff8edf3d12508f5ae0879
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrack-untrack.c: error out on unknown CLI options
Francis Deslauriers [Tue, 7 Jan 2020 23:09:46 +0000 (18:09 -0500)] 
track-untrack.c: error out on unknown CLI options

Issue
=====
At the moment, it's possible to have unknown options in the `track` and
`untrack` commands. They are silently ignored.

For example, the following command line is accepted without problem:
  lttng untrack HELLO -k --all --pid

This was witnessed in the `test_event_tracker` tests. The
`lttng_track()` and `lttng_untrack() functions in `tests/utils/util.sh`
are currently passing the `$1` bash variable of the function to the
`track` and `untrack` througth their "$@" variable.

The commands should not silently accept those unknown options.

Fix
===
1. After looping on all the known options, check if there is any leftover
  options and error out if it's the case.
2. Fix the `utils.sh` functions to that they don't pass the `$1` variable
  to the commands.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I822ba09c8ce1ffa8366c586e760a9257e8078e43
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoAdd test_event_tracker to the TESTS variable
Jérémie Galarneau [Tue, 14 Jan 2020 23:55:41 +0000 (18:55 -0500)] 
Add test_event_tracker to the TESTS variable

test_event_tracker is not run on `make check`. Adding it to the
TESTS variable so that it is picked-up by the TAP runner.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id6dda47ee96e6123b326edb5262e941a41cd591e

2 years agoAdd missing `test_event_tracker` to fast_regression
Francis Deslauriers [Tue, 7 Jan 2020 23:39:52 +0000 (18:39 -0500)] 
Add missing `test_event_tracker` to fast_regression

Those tests currently don't run on the CI because they aren't in any of
the `*_regression` files. This commit fixes that.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I9dfb87cc7b863c678ebc6419d6a39b7b964273d5
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoCleanup: track-untrack.c: declare all `int` on the same line
Francis Deslauriers [Tue, 7 Jan 2020 20:29:26 +0000 (15:29 -0500)] 
Cleanup: track-untrack.c: declare all `int` on the same line

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ic566fe9f33d67f7da750c478c6af0b41ec2a968b
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: relayd: hostname check is too restrictive
Jérémie Galarneau [Tue, 14 Jan 2020 22:08:13 +0000 (17:08 -0500)] 
Fix: relayd: hostname check is too restrictive

The check performed by the relay daemon on hostnames is too
restrictive. Since existing session daemons directly use the hostname
returned by gethostname(), the relay daemon must correctly handle FQDN
hostnames, which may contain dots.

This has been observed on the LTTng CI's RHEL8 nodes which report an
FQDN hostname.

The new function 'is_name_path_safe' is used for both session and host
names. It does not check for every problematic path names (reserved
names on Windows, per-platform illegal characters, etc.) Those
restrictions are assumed to be handled when open() and similar
syscalls fail.

However, the objective of this check is to prevent malicious (or at
least unexpected), but legal, names from being used, namely:
  - names that contain a path separator,
  - empty names,
  - hidden names (starting with a dot).

Ideally, illegal names would be automatically escaped in the future.
This is, however, beyond the scope of this fix.

Fixes #1212

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ieeb8b60d22c27b390b51ef7fb52cea0d0ac0f188

2 years agoCleanup: remove extra whitespace from include directive
Jérémie Galarneau [Tue, 14 Jan 2020 21:51:47 +0000 (16:51 -0500)] 
Cleanup: remove extra whitespace from include directive

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic91f07131aced6857ddbcef46f85c3cc3119f98f

2 years agoFix: skip start trace for app that are already started.
Jonathan Rajotte [Mon, 6 Jan 2020 16:46:21 +0000 (11:46 -0500)] 
Fix: skip start trace for app that are already started.

When using trackers, call to ust_app_global_update
results in a call to ust_app_start_trace even if the ust app
trace was already enabled.

This resulted in error message from the app (-1024) complaining that the
tracing was already active on the app side.

  Error: Error starting tracing for app pid: 329376 (ret: -1024)
  ok 211 - Track command with opts: 0 -u --vpid 329376

A solution to this is to keep the enabled state inside the ua_sess and
skip the start trace if already enabled.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ie4198245627e9f0426948489bc9ce24d8c813b08
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: keep active session state on redundant start command
Jonathan Rajotte [Mon, 6 Jan 2020 18:26:54 +0000 (13:26 -0500)] 
Fix: keep active session state on redundant start command

Steps to reproduce problem:
  lttng create
  lttng enable-event -u -a
  lttng start
  lttng start
  lttng stop

Yield:

  Session auto-20200106-134455 created.
  Traces will be output to /home/joraj/lttng-traces/auto-20200106-134455
  All UST events are enabled in channel channel0
  Tracing started for session auto-20200106-134455
  Warning: Tracing already started for session auto-20200106-134455
  Warning: Tracing already stopped for session auto-20200106-134455

The "warning" on the "lttng stop" command is invalid.

This was introduced by commit

1f4962443 Fix: sessiond: no rotation performed from null chunk to new chunk

For cases where the session is already active, simply skip all the way to
the end without passing via the error handling path.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Iaf26090191d3eb940fa419848df8911758e0a6e3
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: build failures when `--without-lttng-ust`
Francis Deslauriers [Fri, 10 Jan 2020 00:34:16 +0000 (19:34 -0500)] 
Fix: build failures when `--without-lttng-ust`

The `--without-lttng-ust` configure option makes the build to fail due
to 2 bugs
1. Missing object file for session unit tests causes the following errors:
    CCLD     test_session
  ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_track_id':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:712: undefined reference to `lttng_tracker_id_lookup_string'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:723: undefined reference to `lttng_tracker_id_get_list'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:729: undefined reference to `lttng_tracker_list_add'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:810: undefined reference to `lttng_tracker_id_set_list'
  ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_untrack_id':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:826: undefined reference to `lttng_tracker_id_lookup_string'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:836: undefined reference to `lttng_tracker_id_get_list'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:841: undefined reference to `lttng_tracker_list_remove'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:925: undefined reference to `lttng_tracker_id_set_list'
  ../../src/bin/lttng-sessiond/kernel.o: In function `kernel_list_tracker_ids':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/kernel.c:949: undefined reference to `lttng_tracker_id_get_list'
  ../../src/bin/lttng-sessiond/trace-kernel.o: In function `trace_kernel_create_session':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:167: undefined reference to `lttng_tracker_list_create'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:171: undefined reference to `lttng_tracker_list_create'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:175: undefined reference to `lttng_tracker_list_create'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:179: undefined reference to `lttng_tracker_list_create'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:183: undefined reference to `lttng_tracker_list_create'
  ../../src/bin/lttng-sessiond/trace-kernel.o:/home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:187: more undefined references to `lttng_tracker_list_create' follow
  ../../src/bin/lttng-sessiond/trace-kernel.o: In function `trace_kernel_create_session':
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:199: undefined reference to `lttng_tracker_list_destroy'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:200: undefined reference to `lttng_tracker_list_destroy'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:201: undefined reference to `lttng_tracker_list_destroy'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:202: undefined reference to `lttng_tracker_list_destroy'
  /home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:203: undefined reference to `lttng_tracker_list_destroy'
  ../../src/bin/lttng-sessiond/trace-kernel.o:/home/frdeso/projets/lttng/tools/src/bin/lttng-sessiond/trace-kernel.c:204: more undefined references to `lttng_tracker_list_destroy' follow
  collect2: error: ld returned 1 exit status
  Makefile:1062: recipe for target 'test_session' failed
  make[1]: *** [test_session] Error 1
  make[1]: Leaving directory '/home/frdeso/projets/lttng/tools/tests/unit'
  Makefile:1166: recipe for target 'all-recursive' failed
  make: *** [all-recursive] Error 1

2. An extra colon at the end of the `trace_ust_track_id()` stub
function gives this error:
    CC       utils.o
  In file included from ust-app.h:26:0,
                   from lttng-sessiond.h:31,
                   from utils.c:27:
  trace-ust.h:339:1: error: expected identifier or '(' before '{' token
   {
   ^
  trace-ust.h:336:19: warning: 'trace_ust_track_id' declared 'static' but never defined [-Wunused-function]
   static inline int trace_ust_track_id(enum lttng_tracker_type tracker_type,
                     ^~~~~~~~~~~~~~~~~~
  Makefile:729: recipe for target 'utils.o' failed

Both bugs are trivial to fix.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I66c57d206ad0142db057443374d28bbcf16c02f7
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoSync lttng-ust ABI version in ust-abi-internal.h 2.12-pre
Jérémie Galarneau [Fri, 20 Dec 2019 21:26:17 +0000 (16:26 -0500)] 
Sync lttng-ust ABI version in ust-abi-internal.h

Bump LTTNG_UST_ABI_MINOR_VERSION to 1

Increment the minor version of lttng-ust ABI to 1, to take into
account that the "clear" command was added in this release cycle.

This will allow future LTTng-tools versions to check for this
capability.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I472eb11589547a9fa119d061a2c1886371b87f69

2 years agoSync lttng-modules ABI version in internal kernel-ioctl.h
Jérémie Galarneau [Fri, 20 Dec 2019 20:55:27 +0000 (15:55 -0500)] 
Sync lttng-modules ABI version in internal kernel-ioctl.h

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I67eafac24bc8db62831b6bc72497c706ff383a07

2 years agoFix: lttng-clear: invalid free of session name
Jérémie Galarneau [Fri, 20 Dec 2019 06:39:17 +0000 (01:39 -0500)] 
Fix: lttng-clear: invalid free of session name

Valgrind reports an invalid free of session_name when it is sourced
from the popt args. Only free it when it comes from the .lttngrc file.

This also caused spurious core dumps when running the tests on
one of my machines.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I194cd36147a1028aad503b4e5d3ea23732a30bc5

2 years agoFix: initialize var_data to NULL
Jonathan Rajotte [Wed, 20 Nov 2019 21:14:39 +0000 (16:14 -0500)] 
Fix: initialize var_data to NULL

Remove a false-positive from scan-build. Initialization of
var_data_len should have been enough but scan build is not smart
enough to understand this.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I90cb449f3092db432967a3f2ea5eedb0728b8678
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotracker: update API documentation
Jonathan Rajotte [Wed, 20 Nov 2019 20:25:16 +0000 (15:25 -0500)] 
tracker: update API documentation

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I71f02c5cbebe7ed8e19aee6bc0d2af7741ed272f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoCleanup: remove struct lttng_handle from tracker.h
Jonathan Rajotte [Wed, 20 Nov 2019 20:17:49 +0000 (15:17 -0500)] 
Cleanup: remove struct lttng_handle from tracker.h

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I8b9fd5c86200013cbd60c57505621cb851556b01
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoRefactoring: introduce lttng_tracker_ids_serialize
Jonathan Rajotte [Thu, 21 Nov 2019 03:02:09 +0000 (22:02 -0500)] 
Refactoring: introduce lttng_tracker_ids_serialize

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I0d43b85241b7097ac722724d9fef0ca352422495
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoRefactoring: move count to an output parameter
Jonathan Rajotte [Wed, 20 Nov 2019 19:40:22 +0000 (14:40 -0500)] 
Refactoring: move count to an output parameter

This mimics what is done for lttng_rotation_schedules_get_count.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I576d112de4a9bfa258a78cb52b8da8a5f25adefb
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoRefactoring: introduce lttng_tracker_ids data structure
Jonathan Rajotte [Wed, 20 Nov 2019 03:48:00 +0000 (22:48 -0500)] 
Refactoring: introduce lttng_tracker_ids data structure

This data structure is opaque to allow for back-end implementation change
in the future.

For now, only the following functions concerning lttng_tracker_ids are public:
    lttng_list_tracker_ids
    lttng_tracker_ids_get_count
    lttng_tracker_ids_get_at_index
    lttng_tracker_ids_destroy

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Iae1c10d0b578b402ab91378dd49f69f605b316b2
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoRefactoring: use an opaque lttng_tracker_id type
Jonathan Rajotte [Mon, 18 Nov 2019 02:38:21 +0000 (21:38 -0500)] 
Refactoring: use an opaque lttng_tracker_id type

Move the tracker and tracker id related API to tracker.h and
tracker-internal.h.

The use of an opaque object mimics the new API for rotation and trigger
etc.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I00b876c618d7dcb0dd940189e5250c3f3d64c7e0
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: Initialize ret to zero
Jonathan Rajotte [Fri, 8 Nov 2019 21:28:00 +0000 (16:28 -0500)] 
Fix: Initialize ret to zero

For the improbable case that the domain is unknown the return value ret
would not be initialized.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I22ae6b98bbbc4f4fe3e9c28985e2400f7c668525
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoUpdate track/untrack man page
Jonathan Rajotte [Wed, 6 Nov 2019 19:51:22 +0000 (14:51 -0500)] 
Update track/untrack man page

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ie7092993034f2fb71fc3b1fad0ce5a6f61a31493
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoError early on invalid tracker type for UST domain
Jonathan Rajotte [Mon, 4 Nov 2019 22:35:27 +0000 (17:35 -0500)] 
Error early on invalid tracker type for UST domain

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Iea182575c99c1fcf84cb8c313af5904581b5023d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoust-app: remove dead code
Jonathan Rajotte [Thu, 31 Oct 2019 21:20:43 +0000 (17:20 -0400)] 
ust-app: remove dead code

This code path is not possible since all callsite are fenced with a check
to "has_been_started". Hence, a session cannot be active at the same time.

Change-Id: I53785017989ed7afc8755a41428087d988e5ae88
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: Skip uid registry when metadata key value is 0
Jonathan Rajotte [Thu, 9 Aug 2018 21:21:40 +0000 (17:21 -0400)] 
Fix: Skip uid registry when metadata key value is 0

A value of 0 for the metadata key indicates that the metadata channel
was never created/pushed on the consumer side.

This can occur in scenario where a tracker(s) (vuid/vgid/vpid) is present.
The metadata channel might never be created/pushed since no applications
are actually tracing. Still, the uid registry exists due to the order
in which the sessiond received the client commands (create,
enable-channel, lttng track/untrack).

See included test for a complete reproducer.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Id7ef34ebc48333f47db4bdca907cf81911b60d1d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrackers: bump MI version to 4.0
Mathieu Desnoyers [Thu, 5 Jul 2018 15:08:40 +0000 (11:08 -0400)] 
trackers: bump MI version to 4.0

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0a44262016cf90e0629be5cb7d8b5976462c62d9
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotests: test uid/gid/pid/vuid/vgid/vpid trackers
Mathieu Desnoyers [Tue, 10 Jul 2018 18:12:07 +0000 (14:12 -0400)] 
tests: test uid/gid/pid/vuid/vgid/vpid trackers

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1b5ee95efc58a3969066e353cb30eeb3fd8eebb9
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrackers: update list/track/untrack commands
Jonathan Rajotte [Thu, 7 Nov 2019 23:01:06 +0000 (18:01 -0500)] 
trackers: update list/track/untrack commands

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I18e41d0e3c7826596ac0468eb5ef7bcc549c8f98
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrackers: support tracking feature
Jonathan Rajotte [Thu, 7 Nov 2019 21:18:10 +0000 (16:18 -0500)] 
trackers: support tracking feature

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I1629562f4c94947f5dd54a0cee6c0f8f7beb19fe
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrackers: add sessiond tracker list implementation
Mathieu Desnoyers [Thu, 5 Jul 2018 14:31:01 +0000 (10:31 -0400)] 
trackers: add sessiond tracker list implementation

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I28dbeac1f3db2df7e61911249a3250fbc17dc244
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrackers: update lttng-modules tracer ABI
Mathieu Desnoyers [Wed, 4 Jul 2018 20:15:07 +0000 (16:15 -0400)] 
trackers: update lttng-modules tracer ABI

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I27e1e552b13b5a541b43ff250d1d4839e399f1f3
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrackers: introduce new tracker types
Jonathan Rajotte [Thu, 7 Nov 2019 21:16:56 +0000 (16:16 -0500)] 
trackers: introduce new tracker types

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I749915124dbfe7cbe15d889a5dbcb648c17374dc
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrackers: change error code from "pid" to "id"
Mathieu Desnoyers [Wed, 4 Jul 2018 20:11:17 +0000 (16:11 -0400)] 
trackers: change error code from "pid" to "id"

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0ce03b23350a9f0da9d5f00ac3c6d0e824af9a98
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoformat: use AfterCaseLabel: true for switch case
Jonathan Rajotte [Wed, 6 Nov 2019 21:15:37 +0000 (16:15 -0500)] 
format: use AfterCaseLabel: true for switch case

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ib0bb3c222441e7c6afcf7ea5c5c95bbf8413be57
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoFix: sessiond: check for lttng-modules ABI 2.1 rather than 2.8
Jérémie Galarneau [Fri, 20 Dec 2019 03:13:10 +0000 (22:13 -0500)] 
Fix: sessiond: check for lttng-modules ABI 2.1 rather than 2.8

The clear patchset introduces a regression that breaks session
rotations when the kernel domain is used. The 2.8 lttng-modules ABI
does not exist yet.

The packet sequence number functionality was introduced in LTTng 2.8,
which introduced the 2.1 kernel tracer ABI.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ief97e7e25f6f0fcb5b5b97b39abb417c1eb327ec

2 years agoDoc: man page: lttng-relayd LTTNG_RELAYD_DISALLOW_CLEAR env. var.
Mathieu Desnoyers [Fri, 6 Dec 2019 13:31:47 +0000 (14:31 +0100)] 
Doc: man page: lttng-relayd LTTNG_RELAYD_DISALLOW_CLEAR env. var.

Describe the LTTNG_RELAYD_DISALLOW_CLEAR environment variable in the
lttng-relayd(8) man page.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3573d0f220f8aa298935e01f62c89035a1966f77
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoDoc: lttng-clear(8) man page
Jonathan Rajotte [Mon, 11 Feb 2019 17:19:58 +0000 (12:19 -0500)] 
Doc: lttng-clear(8) man page

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I6d981a1e17a2a3fdd20a4c61b8c2216bc6517f3f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotests: mi for clear command
Jonathan Rajotte [Mon, 11 Feb 2019 16:45:27 +0000 (11:45 -0500)] 
tests: mi for clear command

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I769825ce10ce08cc1ae127821982d7ec3b1448ca
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotests: lttng clear command
Jonathan Rajotte [Thu, 14 Feb 2019 02:33:35 +0000 (21:33 -0500)] 
tests: lttng clear command

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I96c837dfd65be76aa8995305e1e17a8b315b22af
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotests: gen-ust-events: abort() on argument error
Mathieu Desnoyers [Fri, 22 Nov 2019 20:00:38 +0000 (15:00 -0500)] 
tests: gen-ust-events: abort() on argument error

Facilitates test transition: quickly identify tests which were not
updated.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idec886cc565c4cb7f1de89e7f3f765c882f4b988
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotests: gen-ust-events: add touch and wait sync points before exit.
Jonathan Rajotte [Thu, 14 Feb 2019 02:22:06 +0000 (21:22 -0500)] 
tests: gen-ust-events: add touch and wait sync points before exit.

Allows an app to linger until the wait file is created and signals that
the app is just before the exit.

This is mostly useful for per-pid tracing where trace buffers are
cleaned on application teardown.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I37db4c118ebc759ce97c5de8901cad7b39ac1e01
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotests: gen-ust-events: use options instead of arguments
Mathieu Desnoyers [Mon, 26 Aug 2019 18:22:06 +0000 (14:22 -0400)] 
tests: gen-ust-events: use options instead of arguments

Remove argument dependency and ease usage of features individually.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I25769754a1ab271cea9b9ff5519f37371fd877dc
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: live: implement support for clear feature
Mathieu Desnoyers [Thu, 12 Dec 2019 18:24:29 +0000 (13:24 -0500)] 
relayd: live: implement support for clear feature

Implement support for clear feature on live side of relayd.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2d8996098abbdcd635757425bfcee405daf1bb13
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: implement support for clear feature
Mathieu Desnoyers [Thu, 12 Dec 2019 18:24:02 +0000 (13:24 -0500)] 
relayd: implement support for clear feature

Implement support for the clear feature on relayd receiving end.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ice56dea0b7f59a4881f28fef84bcb0406e0afca6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: viewer-stream: introduce viewer_stream_close_files and viewer_stream_sync_tra...
Mathieu Desnoyers [Thu, 12 Dec 2019 18:19:36 +0000 (13:19 -0500)] 
relayd: viewer-stream: introduce viewer_stream_close_files and viewer_stream_sync_tracefile_array_tail

Introduce the following viewer helpers for clear:

- viewer_stream_close_files: Allow closing currently open viewer files.

- viewer_stream_sync_tracefile_array_tail: Allow updating the current
  tracefile id and the index sent seqcount based on the current content
  of the tracefile array.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5d2f72868625b00b207c75c202bc514768c35166
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: viewer_session: expose viewer_session_set_trace_chunk_copy symbol
Mathieu Desnoyers [Thu, 12 Dec 2019 18:17:38 +0000 (13:17 -0500)] 
relayd: viewer_session: expose viewer_session_set_trace_chunk_copy symbol

Expose viewer_session_set_trace_chunk_copy() so it can be used from
relayd live.c. Needed for clear feature.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie5892353a13a80481da52f847e691a984e02000f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrace-chunk: implement no-op and delete release commands
Mathieu Desnoyers [Thu, 12 Dec 2019 18:05:15 +0000 (13:05 -0500)] 
trace-chunk: implement no-op and delete release commands

The delete release command is used by clear. The no-op command is used
for implicit session rotations launched by the destroy command.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I49ea666ff77d3e5f6ac4b25977313ea18e10be62
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: document effect of rotated_after_last_stop on clear
Mathieu Desnoyers [Thu, 12 Dec 2019 18:03:43 +0000 (13:03 -0500)] 
sessiond: document effect of rotated_after_last_stop on clear

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I81e758aee375f297647bcf9c9a469f867799358a
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: snapshot: set trace chunk to NULL before closing it
Mathieu Desnoyers [Thu, 12 Dec 2019 17:58:03 +0000 (12:58 -0500)] 
sessiond: snapshot: set trace chunk to NULL before closing it

Operations are expected to happen in this order with the reworked
trace chunk for clear feature.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3d655714c4b40b8563abdadb8cb74067eb7e4b6e
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: return invalid protocol error on close chunk disallowed clear
Mathieu Desnoyers [Thu, 12 Dec 2019 17:53:27 +0000 (12:53 -0500)] 
relayd: return invalid protocol error on close chunk disallowed clear

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic10283d5a9769f01486d3f6df07f54a8d2856699
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: set has rotated only for explicit rotations
Mathieu Desnoyers [Thu, 12 Dec 2019 17:52:24 +0000 (12:52 -0500)] 
relayd: set has rotated only for explicit rotations

Only set session has_rotated for explicit rotations on the trace chunk
close. This ensures has_rotated can distinguish between clear and
explicit rotate.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I97fac1ac2a6edc233bf1889d693f74f2d7936156
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agotrace-chunk: Introduce chunk "path", relayd session "ongoing_rotation", sessiond...
Mathieu Desnoyers [Thu, 12 Dec 2019 17:22:14 +0000 (12:22 -0500)] 
trace-chunk: Introduce chunk "path", relayd session "ongoing_rotation", sessiond session "rotated"

This commit introduces new attributes in 3 different structures because
those are used in surrounding areas of the code.

Introduce a trace chunk path attribute which tracks where the chunk
currently keeps its files.

It allows updating the current chunk location with the "rename"
API without having to rely on changing the chunk name override,
which is an attribute we may want to keep using when we archive
the chunk.

Separating the "path" from the "name override" attribute allows
easy manipulation of the chunk output without having to keep the
name override around in the caller code.

Introduce an "ongoing_rotation" relayd session attribute to allow
live viewers to retry while a rotation is ongoing. This ongoing
rotation attribute is introduced in the same commit as the path
chunk attribute because they are used in a surrounding area of the code.

Introduce a "rotated" sessiond session attribute in this commit
because it is used in a surrounding area of the code. This rotated
attribute tracks whether an explicit rotation has been performed
on the session. It is a preparation step for the clear feature,
which will use this to figure out whether it needs to clear the
"root" output path (no rotation prior to clear") or if it needs
to clear to a new path. Before introduction of the clear feature,
a chunk_id of 0 was used to identify this, but because clear will
increment the chunk id without changing the path, we need to track
this explicitly through the "rotated" session flag.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ifdecc66cb4849f3e5f7476ab7db48d8f7532a6d3
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoconsumer: add extra debug output
Mathieu Desnoyers [Thu, 12 Dec 2019 17:12:22 +0000 (12:12 -0500)] 
consumer: add extra debug output

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9cc81de9c46d5379e288ece625ccfef4fbf8e022
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: add extra debug output
Mathieu Desnoyers [Thu, 12 Dec 2019 17:10:27 +0000 (12:10 -0500)] 
relayd: add extra debug output

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie83470b293e10441357302a0d6e2668522d983ed
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: implement clear command
Mathieu Desnoyers [Tue, 10 Dec 2019 15:55:03 +0000 (10:55 -0500)] 
sessiond: implement clear command

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iaff1df7693858f5c9b24a6c8d1411fd76cc83714
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: add clear notifier
Mathieu Desnoyers [Thu, 12 Dec 2019 16:57:43 +0000 (11:57 -0500)] 
sessiond: add clear notifier

Add a clear notifier array to reply to clients requesting a clear
command.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I422d87b0122b75be47ae5941fed15f09e87460fe
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: introduce cleared_after_last_stop
Mathieu Desnoyers [Thu, 12 Dec 2019 16:55:50 +0000 (11:55 -0500)] 
sessiond: introduce cleared_after_last_stop

Track whether a session was cleared after the last stop, so
additional clear will be effect-less until it is started again.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Icaa86acab20081b436bd55d026ec79a10c56034b
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: implement ust app clear session
Mathieu Desnoyers [Thu, 12 Dec 2019 16:35:02 +0000 (11:35 -0500)] 
sessiond: implement ust app clear session

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9205b25cd18035156485df980104dea5c241542f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: implement kernel clear session
Mathieu Desnoyers [Thu, 12 Dec 2019 16:34:10 +0000 (11:34 -0500)] 
sessiond: implement kernel clear session

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie47c128fc951b206c7ae50933395e9ade9d0012d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: implement consumer clear channel
Mathieu Desnoyers [Thu, 12 Dec 2019 16:31:34 +0000 (11:31 -0500)] 
sessiond: implement consumer clear channel

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1c17a34c23e4c03f94acb99fb822c3bc42faccf5
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoconsumer: implement clear channel
Mathieu Desnoyers [Thu, 12 Dec 2019 16:31:25 +0000 (11:31 -0500)] 
consumer: implement clear channel

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I4eefc1d23b1b781f055790933572c4796375da26
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agocommon trace-chunk: introduce lttng_trace_chunk_get_name_overridden
Mathieu Desnoyers [Thu, 12 Dec 2019 16:38:13 +0000 (11:38 -0500)] 
common trace-chunk: introduce lttng_trace_chunk_get_name_overridden

While it is possible to query whether the name of a chunk is
overridden through lttng_trace_chunk_get_name(), using it requires
a lot of code to deal with an unused name string when all that is needed
is to check whether the name is overridden.

In preparation for the new "path" handling needed for the clear
feature introduce this lttng_trace_chunk_get_name_overridden()
API to allow checking whether name is overridden in a succint way.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ied8bcbb5202826e68a5d6b54130f29f203948794
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agocommon: trace-chunk: track all files within a chunk
Mathieu Desnoyers [Wed, 11 Dec 2019 19:04:16 +0000 (14:04 -0500)] 
common: trace-chunk: track all files within a chunk

Track all files added/removed in a chunk. Required by the clear
feature so all files of a prior chunk can be unlinked, even if
they belong to applications which have already closed their
stream with per-pid UST buffers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I41bf8ac61f9a8ed1e8f206520ef8845a102b1c1e
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: cmd_rotate_session: introduce command argument
Mathieu Desnoyers [Wed, 11 Dec 2019 18:46:11 +0000 (13:46 -0500)] 
sessiond: cmd_rotate_session: introduce command argument

Add a command type argument to cmd_rotate_session().

Change the internal session_close_trace_chunk() API to introduce the
LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION command rather than rely on
a NULL pointer, which facilitates passing of command argument across
cmd_rotate_session.

This introduces the LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE command,
which is required for the clear feature. Its implementation will
follow in a separate commit.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic1d8cbab1f98b93f1f6d27a2c6624ac2780932e2
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: query relayd configuration for availability of clear feature
Mathieu Desnoyers [Wed, 11 Dec 2019 18:31:24 +0000 (13:31 -0500)] 
sessiond: query relayd configuration for availability of clear feature

Query the relayd configuration when connecting to check for availability
of the clear feature.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5827fdc7f92bc9bc87ccf9d1c567057b2c227e2b
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: Implement get_configuration relayd protocol command
Mathieu Desnoyers [Wed, 11 Dec 2019 18:24:49 +0000 (13:24 -0500)] 
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>
2 years agocommon: index and trace-chunk file creation/open API change
Mathieu Desnoyers [Wed, 11 Dec 2019 18:19:13 +0000 (13:19 -0500)] 
common: index and trace-chunk file creation/open API change

An API change to the common libraries is required for the following
functions to accomodate the clear feature:

- lttng_trace_chunk_open_file(),
- lttng_index_file_create_from_trace_chunk(),
- lttng_index_file_create_from_trace_chunk_read_only().

An "expect_no_file" boolean is introduced, allowing specific invocation
to consider a ENOENT errno as an expected condition (and not an error).
This is the case for instance for relayd live viewer_stream_rotate(),
which can fail to open files in the new chunk after a clear with per-pid
buffers. Same goes for viewer_get_next_index() and try_open_index().

Change the lttng_index_file_create_from_trace_chunk_read_only and
lttng_index_file_create_from_trace_chunk to allow them to return
a chunk status, which allows the callers to distinguish between
errors and a "no file" status, and deal with the situation accordingly.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I3c43edca01629488c4e777078db7ffd2e88dc7ea
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agocommon: index: remove redundant separator for empty channel string
Mathieu Desnoyers [Wed, 11 Dec 2019 18:18:00 +0000 (13:18 -0500)] 
common: index: remove redundant separator for empty channel string

Tweak _lttng_index_file_create_from_trace_chunk() to correctly deal with
empty channel_path string, removing redundant "/" separators.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I743917c27e334ad12e145959b3ad3f59f62f1a64
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: refactoring: introduce start/stop_kernel_session
Mathieu Desnoyers [Wed, 11 Dec 2019 16:39:59 +0000 (11:39 -0500)] 
sessiond: refactoring: introduce start/stop_kernel_session

The clear feature will need to stop kernel session as well, so move this
code to its own function rather than duplicate it.

start_kernel_session already exists, but is static. Expose it so it
can be used from a separate compile unit.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I68da1ee2e51105278265866590734c320a9789bd
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond-comm: add clear command support to consumer protocol
Mathieu Desnoyers [Mon, 9 Dec 2019 15:16:14 +0000 (10:16 -0500)] 
sessiond-comm: add clear command support to consumer protocol

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I717012b855bc394bcdb524befb02a5b1ca54621b
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond-comm: Document feature branch specific commands range
Mathieu Desnoyers [Mon, 9 Dec 2019 15:14:27 +0000 (10:14 -0500)] 
sessiond-comm: Document feature branch specific commands range

Reserve a range of numbers for customer feature branches.
It is never meant to be used in the master branch.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib15ffe281c8e040231559e48b76343e67a625f4b
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd: tracefile array: Allow head position to skip ahead
Mathieu Desnoyers [Mon, 9 Dec 2019 15:09:05 +0000 (10:09 -0500)] 
relayd: tracefile array: Allow head position to skip ahead

The clear feature needs to move the head position ahead (jump)
over sequence numbers.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I08482bd13dd748621968c43de7647f9d19670880
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agorelayd tracefile array: add tracefile_array_reset
Mathieu Desnoyers [Mon, 9 Dec 2019 14:56:27 +0000 (09:56 -0500)] 
relayd tracefile array: add tracefile_array_reset

Required by clear feature.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I58893eb3fffbec5d39e7bf11a6d118fe23ec4496
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.07877 seconds and 5 git commands to generate.