Jérémie Galarneau [Mon, 24 Jun 2019 19:08:36 +0000 (15:08 -0400)]
Docs: misleading documentation of compat_epoll_create
The documentation of compat_epoll_create explicitly mentions that
it can't fail because of a memory allocation error. This is false
as the function allocates an array of struct epoll_event.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 24 Jun 2019 19:07:59 +0000 (15:07 -0400)]
Remove unused ust_sock member of command_ctx
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 18 Jun 2019 18:12:45 +0000 (14:12 -0400)]
Tests: clarify the tap output of the kernel session rotation test
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 18 Jun 2019 18:05:46 +0000 (14:05 -0400)]
Fix: wait for the completion of implicit session rotations
A session that has been rotated within its lifetime will be
rotated during its destruction to rename the last trace chunk.
Currently, the liblttng-ctl library's session destruction function
only waits for the data pending to indicate that all data has
been consumed. This used to be sufficient, but it is now necessary
to wait for the implicit session rotation to complete.
The "wait" variant of the session destruction function will wait
for any implicit session rotation to compete. A new
lttng_destruction_handle class is introduced to allow a client to
wait for the destruction of a session and obtain the location of
the last trace archive produced by the implicit session rotation.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 13 Jun 2019 18:41:48 +0000 (14:41 -0400)]
Fix: don't hide EBADF error subbuffer write
There are _no_ legitimate circumstances where a "EBADF" error should
be considered normal in a multi-threaded program.
This doesn't fix a known problem, but it hid an error while testing a
development branch. It is considered a fix since not logging this
error can make debugging more difficult if this was, in fact, hiding a
problem.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 11 Jun 2019 20:03:22 +0000 (16:03 -0400)]
Tests: don't expect a UST directory after inactive per-PID rotation
The trace archive resulting from the rotation of a session containing
per-PID channels does not result in the creation of te domain
subfolders.
The trace archive is empty if none of the traced domain were active
during the trace chunk's capture.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 11 Jun 2019 09:39:46 +0000 (05:39 -0400)]
Tests: remove check for an empty chunk produced on destruction
Consider the following tracing scenario used by the rotation tests:
- Start tracing
- Rotate
- Stop tracing
- Rotate
- Destroy
The session daemon used to produce 3 trace archives when this sequence
of operations occurred. Of course, the third archive would always be
empty as no events can be produced between a stop and a destroy
operation.
As this behaviour is thankfully no longer present, the chunk
validation logic of the test causes it to fail. This patch removes
this logic.
Moreover, since chunk IDs are now 0-based, the test is adjusted to
check for names accouting for this naming scheme.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 10 Jun 2019 17:31:31 +0000 (13:31 -0400)]
Fix: metadata stream is not marked as quiescent after packet commit
When a metadata stream's wait fd is hung-up or enters an error state,
it is checked for quiescence in lttng_ustconsumer_on_stream_hangup().
If the stream is not quiescent, the current packet is closed through
the flush_buffer operation.
Currently, all commits to metadata streams are done on a packet
basis. The various code paths using the commit_one_metadata_packet
helper all perform a flush directly after the commit. Performing this
flush leaves the stream in a "quiescent" state, but does not mark it
as such.
This results in an extraneous flush being performed in the err/hup
handler, which leaves an empty packet to be consumed. This packet is
then consumed during the execution of the err/hup handler.
This bug results in an empty packet being appended to metadata
streams. This packet is typically ignored by readers, but the fact
that it is written at the time of the destruction of a session
violates the immutability guarantee of the session stop
command. Moreover, following the introduction of trace chunks, this
results in the stream attempting to serialize the empty buffer to its
output file _after_ its trace chunk has been closed, causing an
assertion to hit.
Hence, this fix performs the buffer flush and sets the stream as
quiescent directly in commit_one_metadata_packet().
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 21 Feb 2019 23:59:31 +0000 (18:59 -0500)]
Create stream files relative to a stream's current trace chunk
Create stream (and metadata) files relative to a session's current
trace chunk using the lttng_trace_chunk_open/unlink[...] functions
in the consumer daemons.
Four new commands are added to the sessiond <-> consumerd protocol:
- CREATE_TRACE_CHUNK
Command parameters:
- relayd_id: uint64_t
Unique ìd of the session's associated relay daemon connection
- override_name: optional char[]
Overriden chunk name. This field is not used by the consumer
daemon; it is forwarded to the relay daemon in order to set the
name of a trace chunk's directory when it should not follow the
`<ts begin>-<ts end>-<index>` form used by trace archives (i.e. as
produced by session rotations). This is used to preserve the
existing format of snapshot output directory names.
- sessiond_id: uint64_t
Unique id of the session (from the sessiond's perspective) to
which this trace chunk belongs.
- chunk_id: uint64_t
Unique id the the session's trace chunk.
- credentials: pair of uint32_t uid/gid
Credentials the consumer daemon should use in order to create
files within the trace chunk.
The session daemon maintains the current lttng_trace_chunk of an
ltt_session. When a session that has an output (`output_traces` == 1),
an lttng_trace_chunk is created.
In local tracing modes, the current trace chunk of a session, on the
session daemon's end, holds the ownership of the chunk's output
directory.
The CREATE_TRACE_CHUNK command is used to replicate the session
daemon's current trace chunk in the consumer daemon. This
representation of the current trace chunk has a different role. It
is created in "user" mode. Essentialy, the trace chunk's location
is opaque to the consumer daemon; it receives a directory file
descriptor from which a number of stream files will be created.
The trace chunk registry, as used by the consumer daemon, implicitly
owns the trace chunks on behalf of the session daemon. This is only
needed in the consumer since the consumer has no notion of a session
beyond session IDs being used to identify other objects.
When a channel is created, its session_id and initial chunk_id are
provided. This allows the consumer daemon to retrieve the session's
current trace chunk and associate it with the newly-created
channel. The channel holds a reference to its current trace chunk.
Streams created from a channel also hold a reference to their current
trace chunk, as retrived from their "parent" channel.
The life time of trace chunks in the consumer daemon is cooperatively
managed with the session daemon. This means
session daemon through the LTTNG_CONSUMER_CREATE_TRACE_CHUNK and
LTTNG_CONSUMER_CLOSE_TRACE_CHUNK commands.
- CLOSE_TRACE_CHUNK
[... TODO ...]
This command is used to release the global reference to a
given trace chunk in the consumer daemon. Relasing the consumer
daemon's global reference to the trace chunk leaves only the streams
to hold references until the moment when they are either closed or
they switch-over to another chunk in the event of a session rotation.
- TRACE_CHUNK_EXISTS
[... TODO ...]
- ADD_TRACE_CHUNK_CLOSE_COMMAND
[... TODO ...]
This commit changes a lot of code since it essentialy changes how
files and directories are created.
A number of commands no longer need to specify a `trace_archive_id`
since the CREATE_TRACE_CHUNK and CLOSE_TRACE_CHUNK allow the consumer
daemon to keep track of the current trace chunk of a channel at any
given time.
Creation and ownership of channel sub-directories
---
The path expressed in consumer channel objects is now relative to
the current trace chunk rather than being absolute. For example,
the `pathname` of a consumer channel is now of the form
`ust/1000/64-bit` rather than containing the full output path
`/home/me/lttng-traces/session-[...]/ust/1000/64-bit/`.
The subdirectory of a channel (relative to a trace chunk, e.g.
`ust/1000/64-bit`) is lazily created when a stream's output files are
created.
To do so, the `lttng_consumer_channel` now has a
`most_recent_chunk_id` attribute. When a stream creates its output files
(i.e. at the beginning of a session, or during a session rotation),
the stream's current trace chunk `id` is compared to the channel's
`most_recent_chunk_id`. If it is determined that the channel is
entering a new trace chunk, its channel subdirectory is created
relative to the stream's chunk.
Since this new state is within the `lttng_consumer_channel`, the
channel lock must be held on code paths that may result in the
creation of a new set of output files for a given stream.
Note that as of this commit, there is now a clear ownership boundary
between directories, owned by the session daemon through its trace
chunk, and files, owned by the consumer daemon.
Down-scoping of channel credentials
---
Since files are now created relative to their stream's current trace
chunk (which has credentials set), the fewer sites need access to the
channel's credentials. The only reason credentials are kept as part
of the consumer channel structure is the need to open and unlink UST
shared memory mappings. Since the credentials must only be used for
this purpose, they are now stored as an `LTTNG_OPTIONAL` field,
buffer_credentials, that is only set for UST channels.
Stream files should never need those credentials to be created.
The following commands sessiond <-> consumerd commands have been
removed:
- LTTNG_CONSUMER_ROTATE_RENAME
- LTTNG_CONSUMER_CHECK_ROTATION_PENDING_LOCAL
- LTTNG_CONSUMER_CHECK_ROTATION_PENDING_RELAY
- LTTNG_CONSUMER_MKDIR
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 22 May 2019 20:28:39 +0000 (16:28 -0400)]
Cleanup: remove duplicated code in snapshot record command
The session daemon's snapshot record command contains duplicated
code depending on the configuration of the snapshot output. This
makes it harder to modify the code in a follow-up commit.
Those code paths are made const-correct by the same occasion.
No behaviour change is intended.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 23 May 2019 17:34:37 +0000 (13:34 -0400)]
Fix: run_as_mkdirat returns value of errno
The run_as_mkdirat() function returns the _errno value returned
by the run-as worker instead of returning `ret`. This causes
run_as_mkdirat() to return an error when errno was already set
to a non-zero value by a previous libc/system call.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 15 May 2019 15:37:55 +0000 (11:37 -0400)]
Fix: double close of directory fd in runas worker
The run-as worker implements its mkdirat and mkdirat_recursive commands
on top of the lttng_directory_handle interface. When a directory
handle is created from a directory file descriptor, it assumes the
ownership of this file descriptor and it will release it when
lttng_directory_handle_fini() is invoked.
The runas worker's post-command clean-up closes any file descriptor
received from its client. The command structure's `fd` is set to
`-1` in order to make the received file descriptor invalid and
prevent the double-close.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 11 Mar 2019 21:25:45 +0000 (17:25 -0400)]
relayd: add the sessiond_trace_chunk_registry interface
The sessiond_trace_chunk_registry interface allows the relay
daemon to maintain an association between multiple consumer daemon
connections originating from the same session daemon and a common
trace chunk registry.
This trace chunk registry allows separate, but related, connections
to manipulate the same trace chunk.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sat, 30 Jun 2018 18:51:55 +0000 (14:51 -0400)]
Move index initialization to ctf-index.h
This initialization code is moved to a common header to re-use
it in a follow-up patch.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 10 May 2019 16:41:26 +0000 (12:41 -0400)]
Export utils_stream_file_path outside of common/utils.c
utils_stream_file_name is used by the stream file creation and
unlinking utilities. Those utilities perform actions that
will be performed on a trace chunk in a future commit.
Making this util public allows the reuse of most of the code
of the utilities.
The function is renamed from utils_stream_file_name to
utils_stream_file_path since it returns a path and not a
name.
The function's output parameter is moved to the end of the argument
list to honor the convention used in most of the code base. A length
parameter is added rather than relying on an implicit assumption
that the buffer's length is >= PATH_MAX.
The existing callers' buffer size is changed from PATH_MAX to
the preferred LTTNG_PATH_MAX.
The implementation of the function has been reworked to eliminate
a number of unncessary copies and allocations. It is now simpler,
handles path truncations, and does not duplicate the path separator
if it is already contained in `path_name`.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 9 May 2019 18:10:58 +0000 (14:10 -0400)]
Add file creation/unlinking utils to directory handle
This commit adds file creation and unlinking functions to the
directory handle interface and corresponding run_as wrappers.
This allows the creation and unlinking of files relative to
an existing directory handle using either openat/unlinkat when
directory file descriptors are supported or open/unlink when
they are not.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 5 Mar 2019 03:16:10 +0000 (22:16 -0500)]
relayd: send sessiond uuid and session id as part of create session
Send the sessiond's instance UUID and session id as part of the
relay daemon control protocol's CREATE_SESSION command.
Those attributes will be used to uniquely identify trace chunks
in follow-up commits.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 14 Dec 2018 21:04:44 +0000 (16:04 -0500)]
Transmit sessiond uuid to consumerd on launch
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 12 Mar 2019 20:53:27 +0000 (16:53 -0400)]
Add lttng_uuid_copy() util
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 12 Mar 2019 20:53:00 +0000 (16:53 -0400)]
Add lttng_uuid_is_nil() util
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 11 Mar 2019 21:23:21 +0000 (17:23 -0400)]
Add lttng_uuid_is_equal util to lttng_uuid
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 12 Dec 2018 21:16:26 +0000 (16:16 -0500)]
Add a consumer daemon INIT command
This commit adds an INIT commands which allows the session daemon
to provide its UUID as soon as the consumer daemon is started.
The name of this command is generic since other attributes may
need to be passed at the initialization of a consumer daemon.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 12 Dec 2018 20:39:53 +0000 (15:39 -0500)]
Generate a UUID on lttng-sessiond launch
This commit adds a global sessiond_uuid which can be used to
uniquely identify a session daemon from a relay daemon's
perspective even when it communicates with multiple consumers.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 27 Feb 2019 17:16:29 +0000 (12:16 -0500)]
Remove unneeded creation of the UST domain sub-directory
ust_app_start_trace() always attempts to create its domain
sub-directory after the channel directory has been created. This is
redundant and can be safely removed.
To provide an example, a "domain sub-directory" is:
/home/jgalar/lttng-traces/allo-
20190227-115205/ust
A "channel sub-directory" is, in per-uid buffering mode:
/home/jgalar/lttng-traces/allo-
20190227-115205/ust/uid/1000/64-bit
or, in per-pid buffering mode:
/home/jgalar/lttng-traces/cloe_fafard-
20190227-115609/ust/pid/hello-ust-20186-
20190227-115700
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 6 May 2019 21:14:02 +0000 (17:14 -0400)]
.gitignore: ignore ccls and clangd files
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 26 Feb 2019 03:11:08 +0000 (22:11 -0500)]
Create an initial trace chunk on first start of an ltt_session
Add a current trace chunk to an ltt_session on session start.
The session base output directory is created at that moment and an
handle to it is provided to the session daemon's trace chunk when
it is set in 'owner' mode.
Setting the trace chunk in "owner" mode results in the creation of
the chunk's output directory. In the case, of the first chunk,
the chunk output directory matches the session output directory.
Hence, this has no visible effect.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sun, 5 May 2019 22:47:26 +0000 (18:47 -0400)]
Allow direct access to the dirfd of a directory handle
Serialization functions need access to the dirfd of a directory handle
in order to pass the fd and re-build the directory handle in
another process.
This function should not be used for other purposes. It is
also only available in the 'enable-dirfd' configuration, which
is assumed for the session daemon.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 21 Feb 2019 16:18:24 +0000 (11:18 -0500)]
Create a consumer daemon trace chunk registry on launch
A trace chunk registry is needed by the consumer daemon since there is
no concrete representation of a tracing session object in those
processes.
The trace chunk registry allows the consumer daemon to match
newly-created streams to their current trace chunk. This integration
is performed in a follow-up commit.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 19 Feb 2019 21:44:36 +0000 (16:44 -0500)]
Add the trace chunk and trace chunk registry interfaces
A trace chunk is a set of stream files. It maps to the user-visible
concept of "trace archive chunks" produced following a tracing session
rotation.
The concept of a "chunk" is introduced to make it possible to
associate a group of stream files together, store common
properties (e.g. the epoch, base path, list of files, credentials,
etc.), and perform an action once all files have been closed/released.
The "trace chunk" interface is to be used by the session, consumer,
and relay daemons in different ways, through the OWNER or USER roles.
The lttng_dynamic_pointer_array, lttng_dynamic_array, and optional
utils are added since they are used by the trace chunk implementation.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 17 May 2019 20:03:25 +0000 (16:03 -0400)]
Add a time_to_iso8601_str() utility
time_to_iso8601_str() formats a Unix timestamp to an ISO 8601
compatible string. For now, the only ISO 8601 time format used
in LTTng-tools is the "YYYYmmddTHHMMSS+HHMM" form used by the
session rotation feature.
Since ISO 8601 allows many formats, this functions may need to be
renamed at some point.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 1 May 2019 21:34:34 +0000 (17:34 -0400)]
Add a method to create a directory handle relative to another one
Adds both implementations (dirfd present or not) of the
lttng_directory_handle_init_from_handle method of the
lttng_directory_handle.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 21 May 2019 23:44:30 +0000 (19:44 -0400)]
Maintain a channel-per-session_id hash table in the consumers
Add and maintain an hash table indexed by `session_id` that allows the
consumer daemons to perform actions on a set of channels belonging to
a given session.
This hash table holds no ownership of the channels; it is merely an
"index" to the existing set of channels maintained in the channel_ht.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 1 May 2019 18:35:34 +0000 (14:35 -0400)]
Document lttng_directory_handle_init_from_dirfd
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 1 May 2019 14:50:55 +0000 (10:50 -0400)]
Allow lttng_directory_handle to be moved
Implement a "move" method (akin to C++'s move semantics) which allows
the transfer of the contents/ownership of a stack-allocated directory
handle to another object.
A moved directory handle must no longer be used after the "move"
operation. The original moved handle is invalidated in the hope
of catching erroneous uses of this API quickly.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 24 Apr 2019 19:33:45 +0000 (15:33 -0400)]
Add a copy method to lttng_directory_handle
This method allows the duplication of a directory handle to
existing storage. It duplicates the underlying directory file
descriptor or path, depending on the configured implementation.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 16 May 2019 16:18:10 +0000 (12:18 -0400)]
Remove unused bitfield.h header
There are no users of the bitfield.h header. It was previously
used to list syscalls from a kernel channel in
834978fd, but
this function was removed in
9897fbc9.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 18 Jul 2019 19:51:49 +0000 (15:51 -0400)]
Tests build fix: undefined MAGIC_VALUE macro
The MAGIC_VALUE macro is only defined when the build is configured
in epoll mode. This value should be defined unconditionally as it
is used in both poll and epoll test modes.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 18 Jul 2019 19:49:28 +0000 (15:49 -0400)]
Build fix: undeclared variable in poll compat
No `ipfd` variable exists in the compat_poll_wait function. The
author meant to use `idle_pfd`.
Reported-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Geneviève Bastien [Mon, 17 Jun 2019 16:56:21 +0000 (12:56 -0400)]
Fix: error when listing sessions with no session
lttng_list_sessions() returns a "fatal error" code when
lttng_ctl_ask_sessiond() returns 0. This was interpreted as the
control socket being shutdown unexpectedly. However, it is
(more often) caused by no sessions being available. Given that, it
makes more sense to report that no sessions are available.
More clean-up/refactoring would be needed to report unexpected socket
shutdowns.
Fixes #1188
Signed-off-by: Geneviève Bastien <gbastien@versatic.net>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Thu, 23 May 2019 18:11:35 +0000 (14:11 -0400)]
Update base test for binding
This test is not run for now as it is not part of the test suite.
Use a temporary directory to store trace.
Split in 2 test suite, one for ust and the other for kernel.
Partially fix formatting.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Thu, 23 May 2019 18:02:26 +0000 (14:02 -0400)]
Fix: python binding: expose domain buffer type
On enable_channel the domain buffer type is used to create a temporary
channel. This currently fail for kernel channel since the buffer type is
not exposed at the binding level and default to LTTNG_BUFFER_PER_PID.
Channel for the kernel domain can only be created in LTTNG_BUFFER_GLOBAL
mode.
Exposing the buffer type also allow userpsace channel to use the per uid
buffering scheme.
The current bindings are in a rough state. This is to at least get them
to work with kernel domain.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 25 Apr 2019 22:23:34 +0000 (18:23 -0400)]
Clean-up: correct typo from epoll to poll
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 25 Apr 2019 22:23:33 +0000 (18:23 -0400)]
Clean code base from redundant verification
Remove redundant verification for file descriptors with 0 revents in
code base.
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 25 Apr 2019 22:23:32 +0000 (18:23 -0400)]
Change lttng_poll_wait behaviour of compat-poll to match compat-epoll
This removes the need to verify for idle file descriptors and mitigates
risks of bug due to behaviour mismatch.
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 25 Apr 2019 22:23:31 +0000 (18:23 -0400)]
Fix: hang in thread_rotation when using compat-poll
Add missing verification to prevent a blocking read on an empty fd.
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 25 Apr 2019 22:23:30 +0000 (18:23 -0400)]
Adapt poll layer behaviour to match the epoll layer
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 25 Apr 2019 22:23:29 +0000 (18:23 -0400)]
Change LTTNG_POLL_GETNB behaviour for poll flavor
Modify LTTNG_POLL_GETNB to provide compatibility with the epoll flavor.
Since it is only used after a lttng_poll_wait call with no modification
(add, del, mod) between, this change does not modify the behaviour in
its current usage while ensuring similar API behavior between
compatibility layer implementations.
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 25 Apr 2019 22:23:28 +0000 (18:23 -0400)]
Add Unit test to poll compatibility layer
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 25 Apr 2019 22:23:27 +0000 (18:23 -0400)]
Fix: lttng_poll_mod calls compat_(e)poll_add
lttng_poll_mod should call compat_(e)poll_mod.
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Tue, 30 Apr 2019 23:09:24 +0000 (19:09 -0400)]
Fix: getenv can return null
On system with LANG not defined getenv will return null.
An example of such system is the lava runner used by ci.lttng.org.
https://ci.lttng.org/view/System%20Tests/
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Tue, 30 Apr 2019 18:59:51 +0000 (14:59 -0400)]
Bump LTTNG_UST_ABI to 8.0
See commit
6c737d05 in lttng-ust for the rationale behind this
change.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sun, 28 Apr 2019 22:06:11 +0000 (18:06 -0400)]
Fix: directory handle credentials parameter is not const
There is no reason for the "as user" operations on a directory
handle not to take the credentials as a const parameter. Not
passing credentials as const makes their ownership ambiguous
and makes it harder to write const-correct code.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Geneviève Bastien [Thu, 4 Apr 2019 19:18:07 +0000 (15:18 -0400)]
doc: Add reference to USDT probes
SDT probes are known by most as USDT probes. People may be looking for them
by that name.
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Thu, 28 Mar 2019 19:07:43 +0000 (15:07 -0400)]
Clean-up: Remove double buffer initialisation
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Mon, 1 Apr 2019 20:33:41 +0000 (16:33 -0400)]
Fix: getgrnam is not MT-Safe, use getgrnam_r
Running the test suite under a Yocto musl build resulted in musl
coredump due to double freeing.
We get the following backtraces:
0 a_crash () at ./arch/x86_64/atomic_arch.h:108
1 unmap_chunk (self=<optimized out>) at src/malloc/malloc.c:515
2 free (p=<optimized out>) at src/malloc/malloc.c:526
3 0x00007f46d9dc3849 in __getgrent_a (f=f@entry=0x7f46d9d1f7e0, gr=gr@entry=0x7f46d9e24460 <gr>, line=line@entry=0x7f46d9e26058 <line>, size=size@entry=0x7f46d92db550, mem=mem@entry=0x7f46d9e26050 <mem>, nmem=nmem@entry=0x7f46d92db558, res=0x7f46d92db548) at src/passwd/getgrent_a.c:45
4 0x00007f46d9dc2e6b in __getgr_a (name=0x487242 "tracing", gid=gid@entry=0, gr=gr@entry=0x7f46d9e24460 <gr>, buf=buf@entry=0x7f46d9e26058 <line>, size=size@entry=0x7f46d92db550, mem=mem@entry=0x7f46d9e26050 <mem>, nmem=0x7f46d92db558, res=0x7f46d92db548) at src/passwd/getgr_a.c:30
5 0x00007f46d9dc3733 in getgrnam (name=<optimized out>) at src/passwd/getgrent.c:37
6 0x0000000000460b29 in utils_get_group_id (name=<optimized out>) at ../../../lttng-tools-2.10.6/src/common/utils.c:1241
7 0x000000000044ee69 in thread_manage_health (data=<optimized out>) at ../../../../lttng-tools-2.10.6/src/bin/lttng-sessiond/main.c:4115
8 0x00007f46d9de1541 in start (p=<optimized out>) at src/thread/pthread_create.c:195
9 0x00007f46d9dee661 in __clone () at src/thread/x86_64/clone.s:22
From another run:
0 a_crash () at ./arch/x86_64/atomic_arch.h:108
1 unmap_chunk (self=<optimized out>) at src/malloc/malloc.c:515
2 free (p=<optimized out>) at src/malloc/malloc.c:526
3 0x00007f5abc210849 in __getgrent_a (f=f@entry=0x7f5abc2733e0, gr=gr@entry=0x7f5abc271460 <gr>, line=line@entry=0x7f5abc273058 <line>, size=size@entry=0x7f5abaef5510, mem=mem@entry=0x7f5abc273050 <mem>, nmem=nmem@entry=0x7f5abaef5518, res=0x7f5abaef5508) at src/passwd/getgrent_a.c:45
4 0x00007f5abc20fe6b in __getgr_a (name=0x487242 "tracing", gid=gid@entry=0, gr=gr@entry=0x7f5abc271460 <gr>, buf=buf@entry=0x7f5abc273058 <line>, size=size@entry=0x7f5abaef5510, mem=mem@entry=0x7f5abc273050 <mem>, nmem=0x7f5abaef5518, res=0x7f5abaef5508) at src/passwd/getgr_a.c:30
5 0x00007f5abc210733 in getgrnam (name=<optimized out>) at src/passwd/getgrent.c:37
6 0x0000000000460b29 in utils_get_group_id (name=<optimized out>) at ../../../lttng-tools-2.10.6/src/common/utils.c:1241
7 0x000000000042dee4 in notification_channel_socket_create () at ../../../../lttng-tools-2.10.6/src/bin/lttng-sessiond/notification-thread.c:238
8 init_thread_state (state=0x7f5abaef5560, handle=0x7f5abbf9be40) at ../../../../lttng-tools-2.10.6/src/bin/lttng-sessiond/notification-thread.c:375
9 thread_notification (data=0x7f5abbf9be40) at ../../../../lttng-tools-2.10.6/src/bin/lttng-sessiond/notification-thread.c:495
10 0x00007f5abc22e541 in start (p=<optimized out>) at src/thread/pthread_create.c:195
11 0x00007f5abc23b661 in __clone () at src/thread/x86_64/clone.s:22
The problem was easily reproducible (~6 crash on ~300 runs). A prototype fix
using mutex around the getgrnam yielded no crash in over 1000 runs. This
patch yielded the same results as the prototype fix.
Unfortunately we cannot rely on a mutex in liblttng-ctl since we cannot
enforce the locking for the application using the lib.
Use getgrnam_r instead.
The previous implementation of utils_get_group_id returned the gid of
the root group (0) on error/not found. lttng_check_tracing_group needs
to know if an error/not found occured, returning the root group is not
enough. We now return the gid via the passed parameter. The caller is
responsible for either defaulting to the root group or propagating the
error.
We also do not want to warn when used in liblttng-ctl context. We might
want to move the warning elsewhere in the future. For now, pass a bool
if we need to warn or not.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Tue, 2 Apr 2019 17:41:17 +0000 (13:41 -0400)]
Fix: logging: log_add_time() save/restore errno
The debugging logging macros (e.g. DBG()) are used as printf in the
lttng-tools source files. The printf() implementation does not alter the
errno value, so the fact that log_add_time() (through clock_gettime())
can alter errno is unexpected. For instance, adding a logging statement
for debugging purposes within a function for which errno is expected to
stay unchanged on return will change the behavior between execution with
-vvv and non-verbose.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Wed, 24 Apr 2019 22:56:05 +0000 (18:56 -0400)]
Fix relayd: initialize beacon to -1ULL
The relayd stream beacon_ts_end field is expected to have the value
-1ULL when unset (no beacon has been received since last index).
However, the initial state is wrong. It is left at the value 0, which
indicates that a live beacon has indeed been received (which is untrue),
which in turn causes a live beacon with ctf_stream_id of -1ULL to be
sent to babeltrace, which does not expect it, and fails.
This issue can be triggered with the following scenario:
1) create live session
2) setup UST per-uid buffers tracing
3) start tracing, without any active traced application
4) hook with babeltrace live client to view the trace
5) run a traced application
Step 5) will cause the babeltrace live client to receive a stream_id of
-1ULL, and error out.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Wed, 3 Apr 2019 20:26:45 +0000 (16:26 -0400)]
Fix: relayd: handling of lttng_read errors >= 0
errno is only set when lttng_read returns a negative value. Else, we
need to print a ERR() statement rather than use PERROR().
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Tue, 16 Apr 2019 20:43:48 +0000 (16:43 -0400)]
Harmonize pprint macro across projects
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Tue, 16 Apr 2019 20:43:47 +0000 (16:43 -0400)]
Update the ac_define_dir macro from the autoconf archive
This macro was removed many years ago from the archive because it crosses
the boundary between configure and make time variables. For the moment
update it to the latest released version.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Tue, 16 Apr 2019 20:43:46 +0000 (16:43 -0400)]
Harmonize rw_prog_cxx_works macro across projects
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Tue, 16 Apr 2019 20:43:45 +0000 (16:43 -0400)]
Namespace check_sdt_works custom macro
The ax_ prefix is for macros that are copied from the
Autoconf archive project.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Tue, 16 Apr 2019 20:43:44 +0000 (16:43 -0400)]
Update macros from the autoconf archive
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 24 Apr 2019 20:06:01 +0000 (16:06 -0400)]
Fix: relayd not spawned on default-url live session creation
b178f53e9 introduced a regression that causes the lttng client to
not spawn a relay daemon automatically when a live session is
created using the default url parameters.
This fix re-introduces an equivalent check to restore the
previous behaviour.
Reported-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 24 Apr 2019 20:05:36 +0000 (16:05 -0400)]
Clean-up: remove empty line in lttng create command
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 17 Apr 2019 20:55:27 +0000 (16:55 -0400)]
Add mkdirat utils and runas wrappers
The lttng_directory_handle allows its user to keep a handle to
a directory and to create subdirectories relative to it.
On platforms implementing POSIX.2008, a directory file descriptor
is used to maintain a handle to an existing directory and used
in conjunction with mkdirat() to create subdirectories.
Derelict platforms (such as Solaris 10) use an alternative
implementation which carries the location of the root directory
and builds subdirectory paths on creation.
The existing mkdir utils are re-implemented using this new
interface (using the special AT_FDCWD file descriptor value, when
applicable) to limit code duplication.
The implementation of the directory handle and its users is
automatically selected based on the presence of the dirfd() function,
but can also be explicitly chosen using the --enable/disable-dirfd
configuration option.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 11 Apr 2019 17:54:57 +0000 (13:54 -0400)]
Clean-up: remove commented code from test
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 10 Apr 2019 20:46:35 +0000 (16:46 -0400)]
Fix tests: NULL pointer dereference in ltt_session unit tests
Skip the session destruction test if the target session is not
found. Otherwise, a NULL pointer dereference will occur.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 10 Apr 2019 20:37:42 +0000 (16:37 -0400)]
Fix tests: NULL pointer dereference in ust channel unit tests
The test_create_ust_channel() test case erroneously checks for
a NULL session instead of a channel. This can result in a
NULL pointer dereference on failure to create a ust channel.
The scope of usess is reduced to prevent similar mistakes in the
future. Moving 'dom' has made it obvious that this variable is
unused. Hence, it is removed.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 10 Apr 2019 20:25:20 +0000 (16:25 -0400)]
Fix tests: NULL pointer dereference in ltt_ust_context unit tests
The check for the expected context's type must be skipped when
trace_ust_create_context() fails. Otherwise, a NULL pointer
dereference will occur.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 10 Apr 2019 20:16:43 +0000 (16:16 -0400)]
Fix tests: NULL pointer dereference in ltt_session unit tests
The check for a NULL kernel session must be skipped when
the session_find_by_name() fails to find a session else a NULL
pointer dereference will occur.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 10 Apr 2019 19:28:15 +0000 (15:28 -0400)]
Log the wait-shm's path on shm_open failure
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 8 Apr 2019 19:44:01 +0000 (15:44 -0400)]
Generate session name and default output on sessiond's end
The lttng client currently generates the default session name and
output parameters. This has, over time, resulted in a number of
problems. Notably, it is possible for scripts to create session
too quickly using automatically-generated session names that would
clash since the session's creation timestamp is the only variable part
of a session "automatic" name. Hence, sessions created in the same
second would clash and result in spurious session creation failures.
More importantly, generating session names and outputs on the client
end makes it impossible to reliably differentiate output locations that
were automatically generated vs. those that were explicitly provided.
This causes destinations to be "opaque" to the LTTng daemons as
the subdir, session name, and session's creation timestamp are all
"cooked" as part of the output destination path/subdir. Keeping these
path components separate will make it easier to implement output path
configurations that allow the grouping of session outputs by name, by
host, etc.
Since a session's creation time is used as part of its shm-path, an
accessor to the session's creation time is added to the public API:
lttng_session_get_creation_time(). This creation time attribute can be
accessed when an lttng_session structure is created using the session
listing API.
Note that existing session creation functions are preserved to
maintain the binary compatibility with existing liblttng-ctl users.
The session creation functions are reimplemented on top of this
newly-introduced API. The only function for which compatibility is
dropped is the hidden _lttng_create_session_ext().
Overhaul of path separation
---
Not generating paths on the client-end has uncovered a number
of problems in the path handling of the session daemon, especially
when a network output was used. A lot of code presumed that a
network session would be created with a URL containing a sub-directory
of the form "session_name-timestamp". While this is true for
remote sessions created by the lttng client, a sub-directory is
not required when liblttng-ctl is used directly.
Hence, this commit ensures that session directories are split
as base path, chunk directory, domain directory, application
directory.
A number of changes in this fix ensure that a session's base path
contains everything up to the "session" path element _or_ up to
the user-specified output directory.
For example, creating a local session using default output settings,
the session base output is:
/home/user/lttng-traces/session-timestamp
Creating a remote session using default output settings, the session
base output path is:
/hostname/session-timestamp/
Using custom output directories, whether locally or remotely, causes
the session base path to be set to that custom output directory.
For example, using a local output path of /tmp/my_path will result
in a session base path of the form:
/tmp/my_path
Whereas creating a session with a network output of
net://localhost/my_path will result in a session base path of the
form:
/hostname/my_path
Another problematic element is the subdir of the kernel_session
and ust_session consumer output which in different scenarios
contained chunk names and arbitrary parts of the path hierarchy.
The consumer output subdir has been renamed to 'domain_subdir'
and now only ever contains: "kernel/", "ust/", or "".
Finally, the chunk_path session attribute only contains the name
of the current chunk directory being produced.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 1 Apr 2019 22:03:57 +0000 (18:03 -0400)]
Move completed trace archive chunks to an "archives" sub-folder
Users have expressed the desire to read all completed trace archive
chunks at once. Initialy, the requirement called for users to wait,
using the notification API, for chunks to be made available following
the completion of a rotation. Upon the reception of a rotation
completion notification, which contains the chunk's location, it would
be possible to safely consume the resulting trace archive chunk.
Given that using the notification API was deemed too complex for
certain users, it was decided that the creation of a folder of the
form "<start-time>-<end-time>-<idx>" must guarantee the readability
of its contents. This guarantee is currently not honored for the first
trace archive chunk. This is a known bug which will be addressed
before the release.
This requirement has evolved and it must now be possible for users to
point a reader to a session output directory, after an arbitrary
number of rotations, to consume all completed trace archive chunks
while tracing is ongoing.
To make this possible (and reliable), a reader must have a way to
infer which trace archive chunks are still being produced, and which
have been completed so as to not attempt to consume a trace that
is still being produced.
First, a quick refresher on the hierachy of a session output path.
Before a rotation occurs, a session output path has the following
hierarchy:
my_trace
|__ust
|__[...]
|__kernel
|__[...]
And, after four completed rotations:
my_trace
|__<start-time>-<end-time>-0 <--- completed trace archive chunk
|__<start-time>-<end-time>-1
|__<start-time>-<end-time>-2
|__<start-time>-<end-time>-3
|__<start-time>-4 <--- trace archive being produced
As a consequence of this behaviour, it is not possible to safely point
a CTF reader to a trace output directory without a special
configuration option that would indicate that the reader should ignore
the usual lttng hierarchy ('ust' and 'kernel'). Indeed, it is not
possible to distinguish a completed trace from a trace being produced
before the completion of the first rotation of a session.
Moreover, relying on the format of the name of trace archive chunks to
infer their completeness is awfully restrictive in terms of our
ability to alter the trace archive chunk directory format in the
future.
This format is also not part of any CTF specification document meaning
that implementing this logic in a reference CTF
implementation (babeltrace) is ill-advised. It would be unexpected for
a reader to fail to read a trace simply because it is stored in a
directory of the form <ISO8601-timestamp>-<integer>, which is a
valid trace output directory.
Hence, this commit changes the hierarchy of the trace output directory
so that completed (and safe to read) trace archive chunks are stored
in an "archives" sub-folder under the tracing session output
directory. This results in the following trace output directory
hierarchy:
my_trace
|__archives
| |__<start-time>-<end-time>-0 <--- completed trace archive chunk
| |__<start-time>-<end-time>-1
| |__<start-time>-<end-time>-2
| |__<start-time>-<end-time>-3
|__<start-time>-4 <--- trace archive being produced
Pointing to the "archives" directory requires no LTTng-specific logic
to be implemented in the reader(s) to achieve the users' requirement.
It does require that users wait for the presence of an "archives"
directory in the trace output path.
Reference shell code is provided to implement such a check:
"""
if [ -d ${trace_output_path}/archives ]; then
# invoke reader
fi
"""
Given that a user would have to wait for a first completed chunk to
appear or ensure (in whichever way) that a rotation has occured before
consuming trace archive chunks, this alternative does not seem more
complex.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 10 Apr 2019 03:38:43 +0000 (23:38 -0400)]
Fix: lttng_rotate_session does not handle socket close
lttng_ctl_ask_sessiond may return 0 if the sessiond process is killed
or if its client socket is closed unexpectedly. This causes
lttng_rotate_session to assume a rotation command reply has
been received, resulting in a NULL pointer dereference later on.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Mon, 8 Apr 2019 20:03:17 +0000 (16:03 -0400)]
Fix: hide internal libcommon time utilities
libcommon's time-handling utilities are used by liblttng-ctl.
Like other symbols of libcommon, they must be marked as hidden
to prevent them from being exported as part of the liblttng-ctl
interface.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sun, 7 Apr 2019 18:39:08 +0000 (14:39 -0400)]
lttng: make the configuration file interface const correct
The interface defined in conf.h is not const-correct thus hindering
the use of const-correct code in the CLI client.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Sat, 6 Apr 2019 19:16:38 +0000 (15:16 -0400)]
Fix: command reply message is leaked for variable-len replies
Commands which return a variable-length payload re-setup the
command context using setup_lttng_msg() (and its wrappers).
In doing so, the lttcomm_lttng_msg structure (plus its trailing
variable-length payload) are re-allocated. However, the previous
instance of lttcomm_lttng_msg is leaked.
This is solved by free()-ing the original lttcomm_lttng_msg when
setup_lttng_msg() is used. When it is only used once, a NULL
pointer will be free'd without any effect.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Wed, 20 Mar 2019 21:49:00 +0000 (17:49 -0400)]
Fix: skip test when ust doesn't have perf support
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Mon, 25 Mar 2019 18:49:39 +0000 (14:49 -0400)]
Tests: check for lttng-modules presence
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Tue, 26 Mar 2019 19:53:06 +0000 (15:53 -0400)]
Fix: Properly sanitize input parameter
The lttng client uses the sizeof the containing buffer, defined as
LTTNG_SYMBOL_NAME_LEN, for input string sanitation instead of libc defined
macro NAME_MAX. lttng-enable_channel improperly verified user input
and wrongly discarded valid input in case NAME_MAX was less than the
sizeof the containing buffer for the channel's name.
This patch also fixes potential buffer overflow caused by an improperly
bounded strcpy in the case where NAME_MAX would have been greater than
LTTNG_SYMBOL_NAME_LEN.
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Tue, 19 Mar 2019 20:56:03 +0000 (16:56 -0400)]
Fix tests: link libpause_consumer on liblttng-ctl
This preload test library uses symbols from liblttng-ctl which are
resolved when preloaded by GLIBC but not by MUSL.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Wed, 13 Mar 2019 21:50:55 +0000 (17:50 -0400)]
tap-driver.sh: flush stdout after each test result
This is useful in a CI system where stdout is fully buffered and you
look at the console output to see which test is hanging.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Thu, 28 Mar 2019 15:18:38 +0000 (11:18 -0400)]
Fix tests: snapshot size validation failure runs too many test cases
The snapshot max size test is reported as both passing and failing
when the test case fails.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Tue, 12 Mar 2019 18:30:31 +0000 (14:30 -0400)]
Fix tests: the tree origin can be a symlink itself
Problem:
The base tree is defined as "/tmp/.....XXXXXX".
On systems where "/tmp/" is itself a symlink utils_expand_path will
expand the tree origin itself.
For example on a base core-image-minimal Yocto build /tmp is a symlink
to "/var/tmp", which is a symlink to "/var/volatile".
utils_expand_path will return something like this for the symlink test:
"/var/volative/.....XXXXXX/...." which is the valid result.
Solution:
Simply use realpath on the tree_origin and use this path to perform the
test validation.
This work was performed in the effort to support yocto fully and be able
to run the test suite to detect problem as early as possible.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jonathan Rajotte [Tue, 12 Mar 2019 18:30:30 +0000 (14:30 -0400)]
Fix tests: skip test_getcpu_override on single core systems
There is no value in performing this test on single-core system
since the only valid value for the cpu field is 0.
This test currently fails on single-core systems (i.e yocto runqemu)
on the test_getcpu_override_fail test case.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Fri, 22 Feb 2019 19:33:38 +0000 (14:33 -0500)]
Enforce DL_LIBS value instead of hard coded -ldl
Generated makefiles would ignore DL_LIBS value selected by configure
script and use the hard coded value -ldl. Generated makefiles will
now use DL_LIBS.
Refs: #1165
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Yannick Lamarre [Fri, 22 Feb 2019 19:33:37 +0000 (14:33 -0500)]
Fix: Add POPT_CFLAGS to lttng_CFLAGS
The generated makefile was ignoring POPT_CFLAGS when compiling
lttng, but was adding POPT_LIBS to lttng_LDADD. With this commit,
make now honors both settings for applications and tests.
Fixes: #1165
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Mathieu Desnoyers [Tue, 19 Feb 2019 22:47:49 +0000 (17:47 -0500)]
Fix: consumer snapshot: handle unsigned long overflow
Comparing the consumed iterator and the produced position without
using a difference generates an empty snapshot when the iterator is
before unsigned long overflow and the produced position is after
unsigned long overflow.
This applies to both UST and kernel consumers.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 26 Feb 2019 16:21:14 +0000 (11:21 -0500)]
Clean-up: hide internal kernel_consumer_add_channel() symbol
kernel_consumer_add_channel() is not used outside of
kernel-consumer.c.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 27 Mar 2019 22:36:15 +0000 (18:36 -0400)]
Fix: no-output sessions do not enforce snapshot constraints
A number of scenarios can lead to failures to record snapshots when a
session is created as "no-output" (not snapshot) and has snapshot
outputs added later-on.
These changes prevent a user from adding snapshot outputs after the
creation of a kernel channel that makes use of the 'splice' output
type since those do not allow the capture of snapshots.
Moreover, the output type of kernel channels is overriden when a
snapshot output is present in a session to behave like a snapshot
session would.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 27 Mar 2019 19:42:19 +0000 (15:42 -0400)]
Fix: wrong error code returned by kernel_snapshot_record()
On snapshot error, kernel_snapshot_record() can return
LTTNG_ERR_KERN_CONSUMER_FAIL which means that the kernel consumer
daemon failed to launch. In this path, the appropriate error to
return is LTTNG_ERR_KERN_META_FAIL.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 27 Mar 2019 19:31:13 +0000 (15:31 -0400)]
Clarify incorrect channel output type logging message
Recording a snapshot is only supported for channels that have
an "mmap" output type. Add the channel's name and an explanation
of the error in the consumer daemon's log as the channel's
'output' integral representation is of limited use.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 27 Mar 2019 19:28:54 +0000 (15:28 -0400)]
Mark lttng_kconsumer_snapshot_channel as static
lttng_kconsumer_snapshot_channel() is not used outside of
kernel-consumer.c. It should therefore not be exported outside
of this TU.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 27 Mar 2019 18:12:47 +0000 (14:12 -0400)]
Docs: clarify the meaning of the snapshot_mode flag in ltt_session
The snapshot_mode flag of an ltt_session only affects the default
channel creation attributes. It is not used to prevent the
modification of snapshot outputs.
Since a snapshot session is necessarily in "no-output" mode, it
is redundant to check for this flag in rotation-related commands.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 27 Mar 2019 17:36:06 +0000 (13:36 -0400)]
lttng: clean-up the printout of snapshot outputs
The printout of snapshot outputs, when they are added or listed,
insistently uses "-1" and "0" to indicate that no "max-size"
parameter is specified.
This commit only prints the "max-size" settings when one is
actually specified and changes the spelling of "max-size" to
"max size".
Moreover, the unit (bytes) is printed when a max-size parameter
is specified on a snapshot output.
This changes the output of the listing of snapshot outputs as follows.
Before:
$ lttng snapshot list-output
Snapshot output list for session auto-
20190327-133932
[1] snapshot-1: /home/jgalar/lttng-traces/auto-
20190327-133932 (max-size: 0)
After:
$ lttng snapshot list-output
Snapshot output list for session auto-
20190327-133932
[1] snapshot-1: /home/jgalar/lttng-traces/auto-
20190327-133932
Creating a snapshot output without a max-size no longer indicates
"(max-size: -1)".
Before:
$ lttng snapshot add-output /tmp/keb
Snapshot output successfully added for session auto-
20190327-134055
[1] snapshot-1: /tmp/keb (max-size: -1)
After:
$ lttng snapshot add-output /tmp/keb
Snapshot output successfully added for session auto-
20190327-134055
[1] snapshot-1: /tmp/keb
Max sizes, when specified, are printed in bytes.
Before:
$ lttng snapshot add-output /tmp/keb --max-size=498394
Snapshot output successfully added for session auto-
20190327-134055
[1] snapshot-1: /tmp/keb (max-size: 498394)
After:
$ lttng snapshot add-output /tmp/keb --max-size=498394
Snapshot output successfully added for session auto-
20190327-134055
[1] snapshot-1: /tmp/keb (max size: 498394 bytes)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 26 Mar 2019 23:43:50 +0000 (19:43 -0400)]
lttng: clean-up printout of session output destination
This commit fixes three UX problems with lttng's list command
output.
1) The list command currently repeats the session's output location
twice, e.g.
auto-
20190326-192630 (/home/jgalar/lttng-traces/auto-
20190326-192630) [inactive]
Trace path: /home/jgalar/lttng-traces/auto-
20190326-192630
2) In the case of a snapshot session, the parentheses are empty
and the "Trace path:" line is empty, e.g.
auto-
20190326-192613 () [inactive snapshot]
Trace path:
3) The term "path" is used even though the output may be a
network location, e.g.
auto-
20190326-194856 (tcp4://127.0.0.1:5342/ [data: 5343]) [inactive]
Trace path: tcp4://127.0.0.1:5342/ [data: 5343]
The new output omits the output location in parentheses, doesn't
print the "Trace path" line if no output is specified, and
uses the generic "output" terminology rather than "path".
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 22 Mar 2019 21:51:14 +0000 (17:51 -0400)]
Docs: document the format of the lttng_session path member
Document that the path returned through a session listing operation
is not a path nor standard URL. While a UNIX path will be returned
when a session is configured to trace locally, a liblttng-ctl user
should not expect this field to contain a valid URL when a network
streaming (or live) output destination is configured. The "path"
field will hold a custom-formatted string describing the output.
This is arguably unexepected, but since this is currently the only
way to obtain the destination of an existing session, this format
will not be changed to preserve compatiblity with existing tools
which could rely on this format.
A description of the formating used by the session daemon is
added as part of this patch.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Fri, 22 Mar 2019 20:08:11 +0000 (16:08 -0400)]
Docs: lttng-ctl has no default live timer period
The documentation of liblttng-ctl mentions that a 1 second timer
is used by default.
The library itself (and the session daemon) has no concept of a
default live timer period. The CLI governs this default value.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 26 Mar 2019 15:50:41 +0000 (11:50 -0400)]
Fix: missing include can cause structures to not be packed
A number of files declaring "packed" structures (using the LTTNG_PACKED
macro) do not include common/macros.h, which defines this macro.
This results in structures being used in their "unpacked" form, or
under both packed and unpacked forms, depending on the other files
included at the point of definition and use of these structures.
It is unclear which of the users of these structures were actually
affected by the bug. Most of these structures are used for IPC
over a UNIX socket. In these cases, it is reasonable to assume that
lttng-tools will be rebuilt completely to take this change into
account.
However, the structures declared in common/sessiond-comm/relayd.h are
more worrying as they are part of the relay daemon's network protocol.
Fortunately, adding the following directive to
common/sessiond-comm/relayd.h confirms that the header is included
transitively where those structures are used.
> #ifndef LTTNG_PACKED
> #error Not defined!
> #endif
Instances of this issue were found using the following script.
for file in $(ag -l LTTNG_PACKED); do
ag "#include \<common/macros\.h\>" -l ${file} > /dev/null
if [ $? -ne 0 ]; then
echo "Missing include in" $file
fi
done
Running this script produces the following output (annotated):
Missing include in include/lttng/channel-internal.h
Missing include in include/lttng/condition/buffer-usage-internal.h
Missing include in include/lttng/condition/session-consumed-size-internal.h
Missing include in include/lttng/condition/session-rotation-internal.h
Missing include in src/common/sessiond-comm/sessiond-comm.h
Missing include in src/common/sessiond-comm/relayd.h
Missing include in src/common/sessiond-comm/agent.h
> LTTNG_PACKED mentioned in comments
Missing include in src/common/optional.h
> Unneeded.
Missing include in src/common/macros.h
> lttng-ust-abi.h defines its own version of LTTNG_PACKED
> and is included by lttng-ust-ctl.h
Missing include in src/bin/lttng-sessiond/lttng-ust-ctl.h
Missing include in src/bin/lttng-sessiond/lttng-ust-abi.h
Missing include in src/lib/lttng-ctl/filter/filter-bytecode.h
> False positives (not source files)
Missing include in packed.sh
Missing include in ChangeLog
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
This page took 0.051278 seconds and 4 git commands to generate.