[lttng-dev] [PATCH lttng-tools] Fix: path of snapshots with a relay and default URI

Julien Desfossez jdesfossez at efficios.com
Tue Aug 29 15:13:02 UTC 2017

When recording a snapshot to a relay without custom URI (ex:
net://localhost vs net://localhost/custom), the snapshots end up being
stored in ~/lttng-traces/<hostname>/snapshot-XXX instead of being inside
the <session-name> folder like on local snapshots. We would expect the
path to be: ~/lttng-traces/<hostname>/<session-name>/snapshot-XXX

So there is a discrepancy between the local and remote behaviour. This
behaviour has been there since at least v2.6, maybe earlier.

Moreover, there is nothing that informs the user about the default
snapshot name, so it is not possible to know where a snapshot has been

The subdir variable when using a relay is the path on the relay (after
~/lttng-traces/). We then prepend the hostname and append the
domain-specific name (/kernel or /ust). A lot of counter-intuitive
manipulations, but this ends up being the correct path. A patch to
simplify this is on its way later.

Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
 src/bin/lttng-sessiond/cmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c
index a295059..c91d649 100644
--- a/src/bin/lttng-sessiond/cmd.c
+++ b/src/bin/lttng-sessiond/cmd.c
@@ -2635,6 +2635,12 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris,
 		session->output_traces = 1;
 	} else {
+		/*
+		 * For snapshots to a relay with the default session name,
+		 * we have to store the session name here since it becomes the
+		 * base of the path and we only append to this path afterwards.
+		 */
+		snprintf(session->consumer->subdir, PATH_MAX, "%s", name);
 		session->output_traces = 0;
 		DBG2("Session %s created with no output", session->name);

More information about the lttng-dev mailing list