From: Jonathan Rajotte Date: Fri, 7 Oct 2016 16:03:34 +0000 (-0400) Subject: load: introduce --override-name X-Git-Tag: v2.9.0-rc1~6 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e1f481f68598431b2b9eca264a2ec0c7f5aea686;p=lttng-tools.git load: introduce --override-name The --override-name option allow users to override the name of the session to be loaded using the command-line. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- diff --git a/doc/man/lttng-load.1.txt b/doc/man/lttng-load.1.txt index 6c565329b..10f893e53 100644 --- a/doc/man/lttng-load.1.txt +++ b/doc/man/lttng-load.1.txt @@ -11,7 +11,7 @@ SYNOPSIS -------- [verse] *lttng* ['linkgenoptions:(GENERAL OPTIONS)'] *load* [option:--force] [option:--input-path='PATH'] - [option:--override-url='URL'] ['SESSION'] + [option:--override-url='URL'] [option:--override-name='NAME'] ['SESSION'] DESCRIPTION @@ -63,6 +63,10 @@ option:--override-url:: dependant on the type of session(s) to be loaded. Refer to (1)lttng-create for the accepted URL format. +option:--override-name:: + Set the session name to NAME. This option is invalid in combination with + the --all option. + By default, existing tracing sessions are not overwritten when loading: the command fails. The option:--force option can be used to allow this. diff --git a/src/bin/lttng/commands/load.c b/src/bin/lttng/commands/load.c index 8fa718ed5..630dccd3b 100644 --- a/src/bin/lttng/commands/load.c +++ b/src/bin/lttng/commands/load.c @@ -31,6 +31,7 @@ static char *opt_input_path; static char *opt_override_url; +static char *opt_override_session_name; static int opt_force; static int opt_load_all; @@ -47,12 +48,13 @@ static struct mi_writer *writer; static struct poptOption load_opts[] = { /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ - {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, - {"all", 'a', POPT_ARG_NONE, 0, OPT_ALL, 0, 0}, - {"input-path", 'i', POPT_ARG_STRING, &opt_input_path, 0, 0, 0}, - {"force", 'f', POPT_ARG_NONE, 0, OPT_FORCE, 0, 0}, - {"override-url",'U', POPT_ARG_STRING, &opt_override_url, 0, 0, 0}, - {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, + {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, + {"all", 'a', POPT_ARG_NONE, 0, OPT_ALL, 0, 0}, + {"input-path", 'i', POPT_ARG_STRING, &opt_input_path, 0, 0, 0}, + {"force", 'f', POPT_ARG_NONE, 0, OPT_FORCE, 0, 0}, + {"override-url", 0, POPT_ARG_STRING, &opt_override_url, 0, 0, 0}, + {"override-name", 0, POPT_ARG_STRING, &opt_override_session_name, 0, 0, 0}, + {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, {0, 0, 0, 0, 0, 0, 0} }; @@ -258,6 +260,21 @@ int cmd_load(int argc, const char **argv) } } + if (opt_override_session_name) { + if (opt_load_all) { + ERR("Options --all and --override-name cannot be used simultaneously"); + ret = CMD_ERROR; + goto end; + } + ret = lttng_load_session_attr_set_override_session_name(session_attr, + opt_override_session_name); + if (ret) { + ERR("Failed to set session name override"); + ret = CMD_ERROR; + goto end; + } + } + ret = lttng_load_session(session_attr); if (ret) { ERR("%s", lttng_strerror(ret));