- command_ret = config_load_session(opt_input_path, session_name, opt_force, 0);
- if (command_ret) {
- ERR("%s", lttng_strerror(command_ret));
+ /* Prepare load attributes */
+ session_attr = lttng_load_session_attr_create();
+ if (!session_attr) {
+ ERR("Failed to create load session attributes");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /*
+ * Set the input url
+ * lttng_load_session_attr_set_input_url only suppports absolute path.
+ * Use realpath to resolve any relative path.
+ * */
+ if (opt_input_path) {
+ input_path = realpath(opt_input_path, NULL);
+ if (!input_path) {
+ PERROR("Invalid input path");
+ ret = CMD_ERROR;
+ goto end;
+ }
+ } else {
+ input_path = NULL;
+ }
+
+ ret = lttng_load_session_attr_set_input_url(session_attr,
+ input_path);
+ if (ret) {
+ ERR("Invalid input path");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Set the session name. NULL means all sessions should be loaded */
+ ret = lttng_load_session_attr_set_session_name(session_attr,
+ session_name);
+ if (ret) {
+ ERR("Invalid session name");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Set the overwrite attribute */
+ ret = lttng_load_session_attr_set_overwrite(session_attr, opt_force);
+ if (ret) {
+ ERR("Force argument could not be applied");
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ ret = lttng_load_session(session_attr);
+ if (ret) {
+ ERR("%s", lttng_strerror(ret));