diff mbox series

[RFC,lttng-tools,v2] Fix: path of snapshots with a relay and default URI

Message ID 1504116402-16327-1-git-send-email-jdesfossez@efficios.com
State Accepted, archived
Delegated to: Jérémie Galarneau
Headers show
Series [RFC,lttng-tools,v2] Fix: path of snapshots with a relay and default URI | expand

Commit Message

Julien Desfossez Aug. 30, 2017, 6:06 p.m. UTC
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
stored.

After parsing the URI provided by the user, we now check if a custom
name was provided or copy the session name there. This is the same
operation performed in _lttng_create_session_ext.

Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
---
 src/lib/lttng-ctl/lttng-ctl.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Jérémie Galarneau Nov. 14, 2017, 12:26 a.m. UTC | #1
Merged, thanks!

Jérémie

On 30 August 2017 at 14:06, Julien Desfossez <jdesfossez at efficios.com> wrote:
> 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
> stored.
>
> After parsing the URI provided by the user, we now check if a custom
> name was provided or copy the session name there. This is the same
> operation performed in _lttng_create_session_ext.
>
> Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
> ---
>  src/lib/lttng-ctl/lttng-ctl.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c
> index a1e10f2..3db9b89 100644
> --- a/src/lib/lttng-ctl/lttng-ctl.c
> +++ b/src/lib/lttng-ctl/lttng-ctl.c
> @@ -2485,9 +2485,22 @@ int lttng_create_session_snapshot(const char *name, const char *snapshot_url)
>
>         lsm.u.uri.size = size;
>
> +       /*
> +        * If the user does not specify a custom subdir, use the session name.
> +        */
> +       if (size > 0 && uris[0].dtype != LTTNG_DST_PATH && strlen(uris[0].subdir) == 0) {
> +               ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s", name);
> +               if (ret < 0) {
> +                       PERROR("snprintf uri subdir");
> +                       ret = -LTTNG_ERR_FATAL;
> +                       goto error;
> +               }
> +       }
> +
>         ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, uris,
>                         sizeof(struct lttng_uri) * size, NULL);
>
> +error:
>         free(uris);
>         return ret;
>  }
> --
> 2.7.4
>
diff mbox series

Patch

diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c
index a1e10f2..3db9b89 100644
--- a/src/lib/lttng-ctl/lttng-ctl.c
+++ b/src/lib/lttng-ctl/lttng-ctl.c
@@ -2485,9 +2485,22 @@  int lttng_create_session_snapshot(const char *name, const char *snapshot_url)
 
 	lsm.u.uri.size = size;
 
+	/*
+	 * If the user does not specify a custom subdir, use the session name.
+	 */
+	if (size > 0 && uris[0].dtype != LTTNG_DST_PATH && strlen(uris[0].subdir) == 0) {
+		ret = snprintf(uris[0].subdir, sizeof(uris[0].subdir), "%s", name);
+		if (ret < 0) {
+			PERROR("snprintf uri subdir");
+			ret = -LTTNG_ERR_FATAL;
+			goto error;
+		}
+	}
+
 	ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, uris,
 			sizeof(struct lttng_uri) * size, NULL);
 
+error:
 	free(uris);
 	return ret;
 }