sessiond: lttng: Add command to check kernel tracer status
authorKienan Stewart <kstewart@efficios.com>
Wed, 22 Nov 2023 21:28:01 +0000 (16:28 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 28 Feb 2024 15:38:54 +0000 (10:38 -0500)
commit49cddecdbb1e042877ca3855b177ade68151030f
tree6476969a287acac929b6032e8637ca4ddf0e0731
parentc1896e2d809e0d32d2d9b8a840755de6d5d70eaf
sessiond: lttng: Add command to check kernel tracer status

Issue observed
--------------

When `lttng enable-channel --kernel` fails, little feedback is
available to user to help them to understand the cause.

Eg.

```
Error: Channel asdf: Kernel tracer not available (session auto-20231123-092621)
```

Solution
--------

The semantic status of the kernel tracer is tracked and persisted in
the session daemon (through `init_kernel_tracer` and
`cleanup_tracer_tracer`.

A new client command `lttng_kernel_tracer_status` is added to request
the current value of the `kernel_tracer_status`. The `lttng` client
uses this command after enabling a kernel-domain channel fails to
provide the user with a more specific cause of the failure.

Eg.

```
Error: Channel asdf: Kernel tracer not available (session auto-20231123-092621)
        Missing one or more required kernel modules
        Consult lttng-sessiond logs for more information
```

The kernel tracer status is tracked with an enum defined in
`include/lttng/kernel.h` to avoid passing potentially different errno values
or locale-dependant strings between the LTTng client and session
daemon.

Loading modules and checking signatures can fail with a number of
different errno values. For example:

C.f. https://gitlab.com/linux-kernel/stable/-/blob/master/kernel/module/signing.c#L70

 * `EKEYREJECTED`
 * Any other error code

C.f. https://gitlab.com/linux-kernel/stable/-/blob/master/Documentation/security/keys/core.rst

 * `EKEYREVOKED`
 * `EKEYEXPIRED`
 * `ENOKEY`
 * Others, such as `ENOMEM`

Known drawbacks
---------------

None.

Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2ae4b188f0110a472200c2511439b9e3e600527d
13 files changed:
include/Makefile.am
include/lttng/kernel.h [new file with mode: 0644]
include/lttng/lttng.h
src/bin/lttng-sessiond/client.cpp
src/bin/lttng-sessiond/cmd.cpp
src/bin/lttng-sessiond/cmd.hpp
src/bin/lttng-sessiond/kernel.cpp
src/bin/lttng-sessiond/kernel.hpp
src/bin/lttng-sessiond/modprobe.cpp
src/bin/lttng/commands/enable_channels.cpp
src/common/sessiond-comm/sessiond-comm.hpp
src/lib/lttng-ctl/liblttng-ctl.sym
src/lib/lttng-ctl/lttng-ctl.cpp
This page took 0.027073 seconds and 4 git commands to generate.