goto error;
}
}
+
end:
free(uris);
return descriptor;
goto end;
}
+static int trace_format_check(struct lttng_session_descriptor& descriptor)
+{
+ int ret = 0;
+ enum lttng_error_code ret_code;
+ const lttng_trace_format_descriptor *trace_format_descriptor = nullptr;
+ enum lttng_session_descriptor_status status;
+ std::string destination;
+
+ status = lttng_session_descriptor_get_trace_format_descriptor(
+ &descriptor, &trace_format_descriptor);
+ if (status != LTTNG_SESSION_DESCRIPTOR_STATUS_OK) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ /*
+ * Only check kernel domain since only the kernel tracer can lag behind
+ * in term of feature.
+ */
+
+ ret_code = lttng_domain_supports_trace_format(lttng_session_daemon_command_endpoint,
+ LTTNG_DOMAIN_KERNEL, trace_format_descriptor);
+ if (ret_code == LTTNG_ERR_TRACE_FORMAT_UNSUPPORTED_KERNEL_TRACER) {
+ WARN("%s", lttng_strerror(ret_code));
+ } else if (ret_code == LTTNG_ERR_KERN_NA || ret_code == LTTNG_ERR_NEED_ROOT_SESSIOND) {
+ /*
+ * Not an error, kernel tracers is simply not available at that
+ * time. Next operation will fail as necessary.
+ */
+ DBG("Kernel tracer not available for trace format support check");
+ } else if (ret_code != LTTNG_OK) {
+ ERR("Failed to validate trace format support: %s", lttng_strerror(ret_code));
+ ret = -1;
+ goto end;
+ }
+
+ if (opt_output_path) {
+ char *tmp = utils_expand_path(opt_output_path);
+ if (!tmp) {
+ ret = -1;
+ goto end;
+ }
+ destination = tmp;
+ free(tmp);
+ } else if (opt_url || opt_ctrl_url) {
+ destination = opt_ctrl_url ? opt_ctrl_url : opt_url;
+ } else if (opt_live_timer) {
+ destination = "tcp://127.0.0.1";
+ }
+
+ if (!destination.empty()) {
+ ret_code = lttng_destination_supports_trace_format(
+ lttng_session_daemon_command_endpoint, destination.c_str(),
+ trace_format_descriptor);
+ if (ret_code == LTTNG_ERR_TRACE_FORMAT_UNSUPPORTED_RELAY_DAEMON) {
+ WARN("%s", lttng_strerror(ret_code));
+ } else if (ret_code == LTTNG_ERR_RELAYD_CONNECT_FAIL) {
+ DBG("Could not validate trace format support: %s",
+ lttng_strerror(ret_code));
+ } else if (ret_code != LTTNG_OK) {
+ ERR("Failed to validate trace format support: %s",
+ lttng_strerror(ret_code));
+ ret = -1;
+ goto end;
+ }
+ }
+
+end:
+ return ret;
+}
+
/*
* Create a tracing session.
* If no name is specified, a default name is generated.
ret = CMD_ERROR;
goto error;
}
+
ret_code = lttng_create_session_ext(session_descriptor);
if (ret_code != LTTNG_OK) {
ERR("%s", lttng_strerror(-ret_code));
goto error;
}
+ ret = trace_format_check(*session_descriptor);
+ if (ret < 0) {
+ ret = CMD_ERROR;
+ goto error;
+ }
+
descriptor_status = lttng_session_descriptor_get_session_name(
- session_descriptor, &created_session_name);
+ session_descriptor, &created_session_name);
if (descriptor_status != LTTNG_SESSION_DESCRIPTOR_STATUS_OK) {
ERR("Failed to obtain created session name");
ret = CMD_ERROR;