X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fcreate.c;h=3a6886134bdfa276da59ceb97880a687c6fcd513;hb=bb2b749bfdced63e744f660aaab28bc12669b6dc;hp=2e03373266c2ca9c3d10f469bfb5da9ef3a5dfb6;hpb=d73c58020df7ccd20d1edd250b0f00f0d7d25b5b;p=lttng-tools.git diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 2e0337326..3a6886134 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -42,7 +42,6 @@ static char *opt_url; static char *opt_ctrl_url; static char *opt_data_url; static int opt_no_consumer; -static int opt_no_output; static int opt_snapshot; static unsigned int opt_live_timer; static int opt_disable_consumer; @@ -61,7 +60,6 @@ static struct poptOption long_options[] = { {"set-url", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0}, {"ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0}, {"data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0}, - {"no-output", 0, POPT_ARG_VAL, &opt_no_output, 1, 0, 0}, {"no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0}, {"disable-consumer", 0, POPT_ARG_VAL, &opt_disable_consumer, 1, 0, 0}, {"snapshot", 0, POPT_ARG_VAL, &opt_snapshot, 1, 0, 0}, @@ -89,9 +87,8 @@ static void usage(FILE *ofp) fprintf(ofp, " -h, --help Show this help\n"); fprintf(ofp, " --list-options Simple listing of options\n"); fprintf(ofp, " -o, --output PATH Specify output path for traces\n"); - fprintf(ofp, " --no-output Traces will not be outputted\n"); fprintf(ofp, " --snapshot Set the session in snapshot mode.\n"); - fprintf(ofp, " Created in no-output mode and uses the URL,\n"); + fprintf(ofp, " Created without a consumer and uses the URL,\n"); fprintf(ofp, " if one, as the default snapshot output.\n"); fprintf(ofp, " Every channel will be set in overwrite mode\n"); fprintf(ofp, " and with mmap output (splice not supported).\n"); @@ -291,6 +288,12 @@ static int create_session(void) } } + if ((!opt_ctrl_url && opt_data_url) || (opt_ctrl_url && !opt_data_url)) { + ERR("You need both control and data URL."); + ret = CMD_ERROR; + goto error; + } + if (opt_output_path != NULL) { traces_path = utils_expand_path(opt_output_path); if (traces_path == NULL) { @@ -311,6 +314,12 @@ static int create_session(void) } else if (opt_url) { /* Handling URL (-U opt) */ url = opt_url; print_str_url = url; + } else if (opt_data_url && opt_ctrl_url) { + /* + * With both control and data, we'll be setting the consumer URL after + * session creation thus use no URL. + */ + url = NULL; } else if (!opt_no_output) { /* Auto output path */ alloc_path = utils_get_home_dir(); @@ -332,22 +341,14 @@ static int create_session(void) } url = alloc_url; - if (!opt_data_url && !opt_ctrl_url) { - print_str_url = alloc_url + strlen("file://"); - } + print_str_url = alloc_url + strlen("file://"); } else { - /* No output means --no-output or --snapshot mode. */ + /* No output means --snapshot mode. */ url = NULL; } - if ((!opt_ctrl_url && opt_data_url) || (opt_ctrl_url && !opt_data_url)) { - ERR("You need both control and data URL."); - ret = CMD_ERROR; - goto error; - } - + /* Use default live URL if NO url is/are found. */ if ((opt_live_timer && !opt_url) && (opt_live_timer && !opt_data_url)) { - /* Use default live URL if none is found. */ ret = asprintf(&alloc_url, "net://127.0.0.1"); if (ret < 0) { PERROR("asprintf default live URL"); @@ -376,6 +377,17 @@ static int create_session(void) } ret = lttng_create_session_snapshot(session_name, snapshot_url); } else if (opt_live_timer) { + const char *pathname; + + if (opt_relayd_path) { + pathname = opt_relayd_path; + } else { + pathname = INSTALL_BIN_PATH "/lttng-relayd"; + } + if (!opt_url && !opt_data_url && !check_relayd() && + spawn_relayd(pathname, 0) < 0) { + goto error; + } ret = lttng_create_session_live(session_name, url, opt_live_timer); } else { ret = _lttng_create_session_ext(session_name, url, datetime, -1); @@ -501,7 +513,7 @@ int cmd_create(int argc, const char **argv) } if (opt_no_consumer) { - MSG("The option --no-consumer is obsolete. Use --no-output now."); + MSG("The option --no-consumer is obsolete."); ret = CMD_WARNING; goto end; }