}
}
+ 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) {
} 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) {
+ char *tmp_path;
+
/* Auto output path */
- alloc_path = utils_get_home_dir();
- if (alloc_path == NULL) {
+ tmp_path = utils_get_home_dir();
+ if (tmp_path == NULL) {
ERR("HOME path not found.\n \
Please specify an output path using -o, --output PATH");
ret = CMD_FATAL;
goto error;
}
- alloc_path = strdup(alloc_path);
-
+ alloc_path = strdup(tmp_path);
+ if (!alloc_path) {
+ PERROR("allocating alloc_path");
+ ret = CMD_FATAL;
+ goto error;
+ }
ret = asprintf(&alloc_url,
"file://%s/" DEFAULT_TRACE_DIR_NAME "/%s",
alloc_path, session_name_date);
}
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. */
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");
}
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);