Add lttng_trace_format::sptr to ltt_session
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.cpp
index 8f2c379584f8710eefd865098278e92aec6db4c8..d5f46188895fa7e7af29d18dddb855677938a274 100644 (file)
@@ -9,6 +9,7 @@
 
 #define _LGPL_SOURCE
 #include <algorithm>
+#include <exception>
 #include <inttypes.h>
 #include <stdio.h>
 #include <sys/stat.h>
@@ -3107,6 +3108,8 @@ enum lttng_error_code cmd_create_session_from_descriptor(
        const char *session_name;
        struct ltt_session *new_session = NULL;
        enum lttng_session_descriptor_status descriptor_status;
+       const lttng_trace_format_descriptor *trace_format_descriptor = NULL;
+       lttng::trace_format_descriptor::uptr trace_format_descriptor_ptr;
 
        session_lock_list();
        if (home_path) {
@@ -3130,7 +3133,25 @@ enum lttng_error_code cmd_create_session_from_descriptor(
                goto end;
        }
 
-       ret_code = session_create(session_name, creds->uid, creds->gid,
+       descriptor_status = lttng_session_descriptor_get_trace_format_descriptor(
+                       descriptor, &trace_format_descriptor);
+       if (descriptor_status != LTTNG_SESSION_DESCRIPTOR_STATUS_OK) {
+               ret_code = LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       try {
+               trace_format_descriptor_ptr =
+                               reinterpret_cast<const lttng::trace_format_descriptor *>(
+                                               trace_format_descriptor)
+                                               ->clone();
+       } catch (std::exception& e) {
+               ERR("%s", e.what());
+               ret_code = LTTNG_ERR_UNK;
+               goto end;
+       }
+
+       ret_code = session_create(session_name, creds->uid, creds->gid, trace_format_descriptor_ptr,
                        &new_session);
        if (ret_code != LTTNG_OK) {
                goto end;
This page took 0.027158 seconds and 5 git commands to generate.