X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=14da886238cfbfd90f7e33d4dc05c1c740aca049;hb=58f835e108c72cf830c4bc3d5b6abce80ebb0b6c;hp=0596033b1441fda9aaa3ca20e613be5923d4b714;hpb=6fa5fe7cc78bea0b0bba154a0f911d3df530e18f;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 0596033b1..14da88623 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -912,6 +912,10 @@ static enum lttng_error_code add_uri_to_consumer( ret = lttng_strncpy(consumer->dst.session_root_path, uri->dst.path, sizeof(consumer->dst.session_root_path)); + if (ret) { + ret_code = LTTNG_ERR_FATAL; + goto error; + } consumer->type = CONSUMER_DST_LOCAL; break; } @@ -1040,7 +1044,8 @@ static enum lttng_error_code send_consumer_relayd_socket( const char *session_name, const char *hostname, const char *base_path, int session_live_timer, const uint64_t *current_chunk_id, - time_t session_creation_time) + time_t session_creation_time, + bool session_name_contains_creation_time) { int ret; struct lttcomm_relayd_sock *rsock = NULL; @@ -1070,7 +1075,7 @@ static enum lttng_error_code send_consumer_relayd_socket( relayd_uri->stype, session_id, session_name, hostname, base_path, session_live_timer, current_chunk_id, - session_creation_time); + session_creation_time, session_name_contains_creation_time); if (ret < 0) { status = LTTNG_ERR_ENABLE_CONSUMER_FAIL; goto close_sock; @@ -1118,7 +1123,8 @@ static enum lttng_error_code send_consumer_relayd_sockets( unsigned int session_id, struct consumer_output *consumer, struct consumer_socket *sock, const char *session_name, const char *hostname, const char *base_path, int session_live_timer, - const uint64_t *current_chunk_id, time_t session_creation_time) + const uint64_t *current_chunk_id, time_t session_creation_time, + bool session_name_contains_creation_time) { enum lttng_error_code status = LTTNG_OK; @@ -1130,7 +1136,8 @@ static enum lttng_error_code send_consumer_relayd_sockets( status = send_consumer_relayd_socket(session_id, &consumer->dst.net.control, consumer, sock, session_name, hostname, base_path, session_live_timer, - current_chunk_id, session_creation_time); + current_chunk_id, session_creation_time, + session_name_contains_creation_time); if (status != LTTNG_OK) { goto error; } @@ -1141,7 +1148,8 @@ static enum lttng_error_code send_consumer_relayd_sockets( status = send_consumer_relayd_socket(session_id, &consumer->dst.net.data, consumer, sock, session_name, hostname, base_path, session_live_timer, - current_chunk_id, session_creation_time); + current_chunk_id, session_creation_time, + session_name_contains_creation_time); if (status != LTTNG_OK) { goto error; } @@ -1199,7 +1207,8 @@ int cmd_setup_relayd(struct ltt_session *session) session->base_path, session->live_timer, current_chunk_id.is_set ? ¤t_chunk_id.value : NULL, - session->creation_time); + session->creation_time, + session->name_contains_creation_time); pthread_mutex_unlock(socket->lock); if (ret != LTTNG_OK) { goto error; @@ -1224,7 +1233,8 @@ int cmd_setup_relayd(struct ltt_session *session) session->base_path, session->live_timer, current_chunk_id.is_set ? ¤t_chunk_id.value : NULL, - session->creation_time); + session->creation_time, + session->name_contains_creation_time); pthread_mutex_unlock(socket->lock); if (ret != LTTNG_OK) { goto error; @@ -1246,7 +1256,7 @@ error: /* * Start a kernel session by opening all necessary streams. */ -static int start_kernel_session(struct ltt_kernel_session *ksess, int wpipe) +static int start_kernel_session(struct ltt_kernel_session *ksess) { int ret; struct ltt_kernel_channel *kchan; @@ -1298,7 +1308,7 @@ static int start_kernel_session(struct ltt_kernel_session *ksess, int wpipe) } /* Quiescent wait after starting trace */ - kernel_wait_quiescent(wpipe); + kernel_wait_quiescent(); ksess->active = 1; @@ -1330,7 +1340,7 @@ int cmd_disable_channel(struct ltt_session *session, goto error; } - kernel_wait_quiescent(kernel_tracer_fd); + kernel_wait_quiescent(); break; } case LTTNG_DOMAIN_UST: @@ -1388,7 +1398,7 @@ int cmd_track_pid(struct ltt_session *session, enum lttng_domain_type domain, goto error; } - kernel_wait_quiescent(kernel_tracer_fd); + kernel_wait_quiescent(); break; } case LTTNG_DOMAIN_UST: @@ -1439,7 +1449,7 @@ int cmd_untrack_pid(struct ltt_session *session, enum lttng_domain_type domain, goto error; } - kernel_wait_quiescent(kernel_tracer_fd); + kernel_wait_quiescent(); break; } case LTTNG_DOMAIN_UST: @@ -1519,7 +1529,7 @@ int cmd_enable_channel(struct ltt_session *session, switch (domain->type) { case LTTNG_DOMAIN_KERNEL: { - if (kernel_supports_ring_buffer_snapshot_sample_positions(kernel_tracer_fd) != 1) { + if (kernel_supports_ring_buffer_snapshot_sample_positions() != 1) { /* Sampling position of buffer is not supported */ WARN("Kernel tracer does not support buffer monitoring. " "Setting the monitor interval timer to 0 " @@ -1570,7 +1580,7 @@ int cmd_enable_channel(struct ltt_session *session, goto error; } - kernel_wait_quiescent(kernel_tracer_fd); + kernel_wait_quiescent(); break; } case LTTNG_DOMAIN_UST: @@ -1705,7 +1715,7 @@ int cmd_disable_event(struct ltt_session *session, goto error_unlock; } - kernel_wait_quiescent(kernel_tracer_fd); + kernel_wait_quiescent(); break; } case LTTNG_DOMAIN_UST: @@ -2155,7 +2165,7 @@ static int _cmd_enable_event(struct ltt_session *session, goto error; } - kernel_wait_quiescent(kernel_tracer_fd); + kernel_wait_quiescent(); break; } case LTTNG_DOMAIN_UST: @@ -2423,7 +2433,7 @@ ssize_t cmd_list_tracepoints(enum lttng_domain_type domain, switch (domain) { case LTTNG_DOMAIN_KERNEL: - nb_events = kernel_list_events(kernel_tracer_fd, events); + nb_events = kernel_list_events(events); if (nb_events < 0) { ret = LTTNG_ERR_KERN_LIST_FAIL; goto error; @@ -2582,8 +2592,7 @@ int cmd_start_trace(struct ltt_session *session) goto error; } - if (session->output_traces && !session->current_trace_chunk && - session_output_supports_trace_chunks(session)) { + if (session->output_traces && !session->current_trace_chunk) { struct lttng_trace_chunk *trace_chunk; trace_chunk = session_create_new_trace_chunk( @@ -2604,7 +2613,7 @@ int cmd_start_trace(struct ltt_session *session) /* Kernel tracing */ if (ksession != NULL) { DBG("Start kernel tracing session %s", session->name); - ret = start_kernel_session(ksession, kernel_tracer_fd); + ret = start_kernel_session(ksession); if (ret != LTTNG_OK) { goto error; } @@ -2681,13 +2690,14 @@ int cmd_stop_trace(struct ltt_session *session) goto error; } - kernel_wait_quiescent(kernel_tracer_fd); + kernel_wait_quiescent(); /* Flush metadata after stopping (if exists) */ if (ksession->metadata_stream_fd >= 0) { ret = kernel_metadata_flush_buffer(ksession->metadata_stream_fd); if (ret < 0) { ERR("Kernel metadata flush failed"); + error_occurred = true; } } @@ -2696,6 +2706,7 @@ int cmd_stop_trace(struct ltt_session *session) ret = kernel_flush_buffer(kchan); if (ret < 0) { ERR("Kernel flush buffer error"); + error_occurred = true; } } @@ -3193,8 +3204,7 @@ int cmd_destroy_session(struct ltt_session *session, if (reply_context) { reply_context->implicit_rotation_on_destroy = true; } - } else if (session->has_been_started && session->current_trace_chunk && - session_output_supports_trace_chunks(session)) { + } else if (session->has_been_started && session->current_trace_chunk) { /* * The user has not triggered a session rotation. However, to * ensure all data has been consumed, the session is rotated @@ -4289,7 +4299,8 @@ static enum lttng_error_code set_relayd_for_snapshot( base_path, session->live_timer, current_chunk_id.is_set ? ¤t_chunk_id.value : NULL, - session->creation_time); + session->creation_time, + session->name_contains_creation_time); pthread_mutex_unlock(socket->lock); if (status != LTTNG_OK) { rcu_read_unlock(); @@ -4471,6 +4482,8 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, session->kernel_session->consumer; snapshot_kernel_consumer_output = consumer_copy_output(snapshot_output->consumer); + strcpy(snapshot_kernel_consumer_output->chunk_path, + snapshot_chunk_name); ret = consumer_copy_sockets(snapshot_kernel_consumer_output, original_kernel_consumer_output); if (ret < 0) { @@ -4491,6 +4504,8 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, original_ust_consumer_output = session->ust_session->consumer; snapshot_ust_consumer_output = consumer_copy_output(snapshot_output->consumer); + strcpy(snapshot_ust_consumer_output->chunk_path, + snapshot_chunk_name); ret = consumer_copy_sockets(snapshot_ust_consumer_output, original_ust_consumer_output); if (ret < 0) { @@ -4557,7 +4572,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, } if (session_close_trace_chunk( - session, session->current_trace_chunk, NULL)) { + session, session->current_trace_chunk, NULL, NULL)) { /* * Don't goto end; make sure the chunk is closed for the session * to allow future snapshots. @@ -4780,7 +4795,7 @@ int cmd_rotate_session(struct ltt_session *session, } /* Unsupported feature in lttng-relayd before 2.11. */ - if (session->consumer->type == CONSUMER_DST_NET && + if (!quiet_rotation && session->consumer->type == CONSUMER_DST_NET && (session->consumer->relay_major_version == 2 && session->consumer->relay_minor_version < 11)) { cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE_RELAY; @@ -4846,7 +4861,8 @@ int cmd_rotate_session(struct ltt_session *session, quiet_rotation ? NULL : &((enum lttng_trace_chunk_command_type){ - LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED})); + LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED}), + session->last_chunk_path); if (ret) { cmd_ret = LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER; goto error; @@ -4967,6 +4983,16 @@ int cmd_rotate_get_info(struct ltt_session *session, sizeof(info_return->location.local.absolute_path); info_return->location_type = (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL; + fmt_ret = asprintf(&chunk_path, + "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s", + session_get_base_path(session), + session->last_archived_chunk_name); + if (fmt_ret == -1) { + PERROR("Failed to format the path of the last archived trace chunk"); + info_return->status = LTTNG_ROTATION_STATUS_ERROR; + cmd_ret = LTTNG_ERR_UNK; + goto end; + } break; case CONSUMER_DST_NET: current_tracing_path_reply = @@ -4992,20 +5018,17 @@ int cmd_rotate_get_info(struct ltt_session *session, &info_return->location.relay.ports.data); info_return->location_type = (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY; + chunk_path = strdup(session->last_chunk_path); + if (!chunk_path) { + ERR("Failed to allocate the path of the last archived trace chunk"); + info_return->status = LTTNG_ROTATION_STATUS_ERROR; + cmd_ret = LTTNG_ERR_UNK; + goto end; + } break; default: abort(); } - fmt_ret = asprintf(&chunk_path, - "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s", - session_get_base_path(session), - session->last_archived_chunk_name); - if (fmt_ret == -1) { - PERROR("Failed to format the path of the last archived trace chunk"); - info_return->status = LTTNG_ROTATION_STATUS_ERROR; - cmd_ret = LTTNG_ERR_UNK; - goto end; - } fmt_ret = lttng_strncpy(current_tracing_path_reply, chunk_path, current_tracing_path_reply_len);