relayd: Extend relayd get configuration command to check for trace format support
[deliverable/lttng-tools.git] / src / bin / lttng-sessiond / cmd.cpp
index be1ab52ab2b315df51cd7ff3dff297acca773096..f975f31e227981589c32d13dd725bdf115d6e3df 100644 (file)
@@ -890,6 +890,28 @@ error:
        return status;
 }
 
+static bool is_trace_format_configuration_supported(
+               uint64_t supported_trace_format, lttng::trace_format_descriptor& trace_format)
+{
+       static const std::unordered_map<enum lttng_trace_format_descriptor_type,
+                       enum lttcomm_relayd_configuration_trace_format_flag>
+                       mapping = {
+                                       {LTTNG_TRACE_FORMAT_DESCRIPTOR_TYPE_CTF_1,
+                                                       LTTCOMM_RELAYD_CONFIGURATION_TRACE_FORMAT_SUPPORTED_CTF1},
+                       };
+
+       auto it = mapping.find(trace_format.type());
+       if (it == mapping.end()) {
+               return false;
+       }
+
+       if (!(supported_trace_format & it->second)) {
+               return false;
+       }
+
+       return true;
+}
+
 /*
  * Send both relayd sockets to a specific consumer and domain.  This is a
  * helper function to facilitate sending the information to the consumer for a
@@ -916,6 +938,7 @@ static lttng_error_code send_consumer_relayd_sockets(const ltt_session& session,
        if (!sock->control_sock_sent) {
                int ret;
                uint64_t result_flags = 0;
+               uint64_t supported_trace_format = 0;
                /* Connect to relayd and make version check if uri is the control. */
                status = create_connect_relayd(&consumer->dst.net.control, &control_sock);
                if (status != LTTNG_OK) {
@@ -926,7 +949,7 @@ static lttng_error_code send_consumer_relayd_sockets(const ltt_session& session,
                consumer->relay_major_version = control_sock->major;
                consumer->relay_minor_version = control_sock->minor;
 
-               ret = relayd_get_configuration(control_sock, 0, &result_flags);
+               ret = relayd_get_configuration(control_sock, 0, result_flags, nullptr);
                if (ret < 0) {
                        ERR("Unable to get relayd configuration");
                        status = LTTNG_ERR_RELAYD_CONNECT_FAIL;
@@ -937,6 +960,13 @@ static lttng_error_code send_consumer_relayd_sockets(const ltt_session& session,
                        consumer->relay_allows_clear = true;
                }
 
+               if (!is_trace_format_configuration_supported(
+                                   supported_trace_format, *session.trace_format)) {
+                       ERR("Relayd does not support the requested trace format");
+                       status = LTTNG_ERR_TRACE_FORMAT_UNSUPPORTED_RELAY_DAEMON;
+                       goto error;
+               }
+
                status = send_consumer_relayd_socket(session.id, &consumer->dst.net.control,
                                consumer, sock, session.name, session.hostname, base_path,
                                session.live_timer, current_chunk_id, session.creation_time,
@@ -999,7 +1029,7 @@ int cmd_setup_relayd(struct ltt_session *session)
        usess = session->ust_session;
        ksess = session->kernel_session;
 
-       ERR("Setting relayd for session %s", session->name);
+       DBG("Setting relayd for session %s", session->name);
 
        rcu_read_lock();
        if (session->current_trace_chunk) {
This page took 0.035644 seconds and 5 git commands to generate.