From 2bba9e532ca1910822005ff7f67400a2e871467c Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 1 May 2013 15:18:50 -0400 Subject: [PATCH] Support flight recorder mode for a session This adds the --no-output option to the lttng UI which will flag a session to not set an output destination meaning that tracing will be in overwrite mode in the buffers. This is also the only way for now to snapshot a session, it's to put it in no output mode. Signed-off-by: David Goulet --- src/bin/lttng-sessiond/cmd.c | 19 +-- src/bin/lttng-sessiond/consumer.c | 8 +- src/bin/lttng-sessiond/consumer.h | 6 +- src/bin/lttng-sessiond/kernel-consumer.c | 137 ++++++++++--------- src/bin/lttng-sessiond/kernel-consumer.h | 10 +- src/bin/lttng-sessiond/main.c | 6 +- src/bin/lttng-sessiond/trace-kernel.h | 2 + src/bin/lttng-sessiond/trace-ust.h | 2 + src/bin/lttng-sessiond/ust-app.c | 1 + src/bin/lttng-sessiond/ust-app.h | 2 + src/bin/lttng-sessiond/ust-consumer.c | 3 +- src/bin/lttng/commands/create.c | 12 +- src/common/consumer.c | 4 +- src/common/consumer.h | 9 +- src/common/kernel-consumer/kernel-consumer.c | 13 +- src/common/sessiond-comm/sessiond-comm.h | 4 + src/common/ust-consumer/ust-consumer.c | 8 +- src/lib/lttng-ctl/lttng-ctl.c | 2 +- 18 files changed, 154 insertions(+), 94 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 6f7c71d05..211fc5a34 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1681,12 +1681,7 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris, struct ltt_session *session; assert(name); - - /* No URIs is not possible. */ - if (uris == NULL) { - ret = LTTNG_ERR_SESSION_FAIL; - goto session_error; - } + assert(creds); /* * Verify if the session already exist @@ -1725,9 +1720,15 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris, goto consumer_error; } - ret = cmd_set_consumer_uri(0, session, nb_uri, uris); - if (ret != LTTNG_OK) { - goto consumer_error; + if (uris) { + ret = cmd_set_consumer_uri(0, session, nb_uri, uris); + if (ret != LTTNG_OK) { + goto consumer_error; + } + session->output_traces = 1; + } else { + session->output_traces = 0; + DBG2("Session %s created with no output", session->name); } session->consumer->enabled = 1; diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index d91c3e60b..d3f6c071c 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -721,7 +721,8 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, unsigned char *uuid, uint32_t chan_id, uint64_t tracefile_size, - uint64_t tracefile_count) + uint64_t tracefile_count, + unsigned int monitor) { assert(msg); @@ -744,6 +745,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.ask_channel.chan_id = chan_id; msg->u.ask_channel.tracefile_size = tracefile_size; msg->u.ask_channel.tracefile_count = tracefile_count; + msg->u.ask_channel.monitor = monitor; memcpy(msg->u.ask_channel.uuid, uuid, sizeof(msg->u.ask_channel.uuid)); @@ -771,7 +773,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, enum lttng_event_output output, int type, uint64_t tracefile_size, - uint64_t tracefile_count) + uint64_t tracefile_count, + unsigned int monitor) { assert(msg); @@ -790,6 +793,7 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.channel.type = type; msg->u.channel.tracefile_size = tracefile_size; msg->u.channel.tracefile_count = tracefile_count; + msg->u.channel.monitor = monitor; strncpy(msg->u.channel.pathname, pathname, sizeof(msg->u.channel.pathname)); diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index 3c5cf155d..a954a073e 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -211,7 +211,8 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, unsigned char *uuid, uint32_t chan_id, uint64_t tracefile_size, - uint64_t tracefile_count); + uint64_t tracefile_count, + unsigned int monitor); void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg, enum lttng_consumer_command cmd, uint64_t channel_key, @@ -230,7 +231,8 @@ void consumer_init_channel_comm_msg(struct lttcomm_consumer_msg *msg, enum lttng_event_output output, int type, uint64_t tracefile_size, - uint64_t tracefile_count); + uint64_t tracefile_count, + unsigned int monitor); int consumer_is_data_pending(uint64_t session_id, struct consumer_output *consumer); int consumer_close_metadata(struct consumer_socket *socket, diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 044b1a81f..ef6dccb53 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -29,27 +29,14 @@ #include "health.h" #include "kernel-consumer.h" -/* - * Sending a single channel to the consumer with command ADD_CHANNEL. - */ -int kernel_consumer_add_channel(struct consumer_socket *sock, - struct ltt_kernel_channel *channel, struct ltt_kernel_session *session) +static char *create_channel_path(struct consumer_output *consumer, + uid_t uid, gid_t gid) { int ret; char tmp_path[PATH_MAX]; - const char *pathname; - struct lttcomm_consumer_msg lkm; - struct consumer_output *consumer; + char *pathname = NULL; - /* Safety net */ - assert(channel); - assert(session); - assert(session->consumer); - - consumer = session->consumer; - - DBG("Kernel consumer adding channel %s to kernel consumer", - channel->channel->name); + assert(consumer); /* Get the right path name destination */ if (consumer->type == CONSUMER_DST_LOCAL) { @@ -57,14 +44,13 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s", consumer->dst.trace_path, consumer->subdir); if (ret < 0) { - PERROR("snprintf metadata path"); + PERROR("snprintf kernel channel path"); goto error; } - pathname = tmp_path; + pathname = strndup(tmp_path, sizeof(tmp_path)); /* Create directory */ - ret = run_as_mkdir_recursive(pathname, S_IRWXU | S_IRWXG, - session->uid, session->gid); + ret = run_as_mkdir_recursive(pathname, S_IRWXU | S_IRWXG, uid, gid); if (ret < 0) { if (ret != -EEXIST) { ERR("Trace directory creation error"); @@ -75,13 +61,53 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, } else { ret = snprintf(tmp_path, sizeof(tmp_path), "%s", consumer->subdir); if (ret < 0) { - PERROR("snprintf metadata path"); + PERROR("snprintf kernel metadata path"); goto error; } - pathname = tmp_path; + pathname = strndup(tmp_path, sizeof(tmp_path)); DBG3("Kernel network consumer subdir path: %s", pathname); } + return pathname; + +error: + free(pathname); + return NULL; +} + +/* + * Sending a single channel to the consumer with command ADD_CHANNEL. + */ +int kernel_consumer_add_channel(struct consumer_socket *sock, + struct ltt_kernel_channel *channel, struct ltt_kernel_session *session, + unsigned int monitor) +{ + int ret; + char *pathname; + struct lttcomm_consumer_msg lkm; + struct consumer_output *consumer; + + /* Safety net */ + assert(channel); + assert(session); + assert(session->consumer); + + consumer = session->consumer; + + DBG("Kernel consumer adding channel %s to kernel consumer", + channel->channel->name); + + if (monitor) { + pathname = create_channel_path(consumer, session->uid, session->gid); + if (!pathname) { + ret = -1; + goto error; + } + } else { + /* Empty path. */ + pathname = ""; + } + /* Prep channel message structure */ consumer_init_channel_comm_msg(&lkm, LTTNG_CONSUMER_ADD_CHANNEL, @@ -96,7 +122,8 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, channel->channel->attr.output, CONSUMER_CHANNEL_TYPE_DATA, channel->channel->attr.tracefile_size, - channel->channel->attr.tracefile_count); + channel->channel->attr.tracefile_count, + monitor); health_code_update(); @@ -115,11 +142,10 @@ error: * Sending metadata to the consumer with command ADD_CHANNEL and ADD_STREAM. */ int kernel_consumer_add_metadata(struct consumer_socket *sock, - struct ltt_kernel_session *session, int no_monitor) + struct ltt_kernel_session *session, unsigned int monitor) { int ret; - char tmp_path[PATH_MAX]; - const char *pathname; + char *pathname; struct lttcomm_consumer_msg lkm; struct consumer_output *consumer; @@ -133,35 +159,15 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, /* Get consumer output pointer */ consumer = session->consumer; - /* Get the right path name destination */ - if (consumer->type == CONSUMER_DST_LOCAL) { - /* Set application path to the destination path */ - ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s", - consumer->dst.trace_path, consumer->subdir); - if (ret < 0) { - PERROR("snprintf metadata path"); + if (monitor) { + pathname = create_channel_path(consumer, session->uid, session->gid); + if (!pathname) { + ret = -1; goto error; } - pathname = tmp_path; - - /* Create directory */ - ret = run_as_mkdir_recursive(pathname, S_IRWXU | S_IRWXG, - session->uid, session->gid); - if (ret < 0) { - if (ret != -EEXIST) { - ERR("Trace directory creation error"); - goto error; - } - } - DBG3("Kernel local consumer tracefile path: %s", pathname); } else { - ret = snprintf(tmp_path, sizeof(tmp_path), "%s", consumer->subdir); - if (ret < 0) { - PERROR("snprintf metadata path"); - goto error; - } - pathname = tmp_path; - DBG3("Kernel network consumer subdir path: %s", pathname); + /* Empty path. */ + pathname = ""; } /* Prep channel message structure */ @@ -177,7 +183,8 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, 1, DEFAULT_KERNEL_CHANNEL_OUTPUT, CONSUMER_CHANNEL_TYPE_METADATA, - 0, 0); + 0, 0, + monitor); health_code_update(); @@ -223,7 +230,7 @@ error: */ int kernel_consumer_add_stream(struct consumer_socket *sock, struct ltt_kernel_channel *channel, struct ltt_kernel_stream *stream, - struct ltt_kernel_session *session) + struct ltt_kernel_session *session, unsigned int monitor) { int ret; struct lttcomm_consumer_msg lkm; @@ -266,7 +273,8 @@ error: * Send all stream fds of kernel channel to the consumer. */ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, - struct ltt_kernel_channel *channel, struct ltt_kernel_session *session) + struct ltt_kernel_channel *channel, struct ltt_kernel_session *session, + unsigned int monitor) { int ret; struct ltt_kernel_stream *stream; @@ -286,7 +294,7 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, DBG("Sending streams of channel %s to kernel consumer", channel->channel->name); - ret = kernel_consumer_add_channel(sock, channel, session); + ret = kernel_consumer_add_channel(sock, channel, session, monitor); if (ret < 0) { goto error; } @@ -298,7 +306,8 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, } /* Add stream on the kernel consumer side. */ - ret = kernel_consumer_add_stream(sock, channel, stream, session); + ret = kernel_consumer_add_stream(sock, channel, stream, session, + monitor); if (ret < 0) { goto error; } @@ -314,7 +323,7 @@ error: int kernel_consumer_send_session(struct consumer_socket *sock, struct ltt_kernel_session *session) { - int ret; + int ret, monitor = 0; struct ltt_kernel_channel *chan; /* Safety net */ @@ -328,10 +337,15 @@ int kernel_consumer_send_session(struct consumer_socket *sock, goto error; } + /* Don't monitor the streams on the consumer if in flight recorder. */ + if (session->output_traces) { + monitor = 1; + } + DBG("Sending session stream to kernel consumer"); if (session->metadata_stream_fd >= 0) { - ret = kernel_consumer_add_metadata(sock, session, 0); + ret = kernel_consumer_add_metadata(sock, session, monitor); if (ret < 0) { goto error; } @@ -342,7 +356,8 @@ int kernel_consumer_send_session(struct consumer_socket *sock, /* Send channel and streams of it */ cds_list_for_each_entry(chan, &session->channel_list.head, list) { - ret = kernel_consumer_send_channel_stream(sock, chan, session); + ret = kernel_consumer_send_channel_stream(sock, chan, session, + monitor); if (ret < 0) { goto error; } diff --git a/src/bin/lttng-sessiond/kernel-consumer.h b/src/bin/lttng-sessiond/kernel-consumer.h index 9deb6b949..64795111a 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.h +++ b/src/bin/lttng-sessiond/kernel-consumer.h @@ -22,17 +22,19 @@ #include "trace-kernel.h" int kernel_consumer_send_channel_stream(struct consumer_socket *sock, - struct ltt_kernel_channel *channel, struct ltt_kernel_session *session); + struct ltt_kernel_channel *channel, struct ltt_kernel_session *session, + unsigned int monitor); int kernel_consumer_send_session(struct consumer_socket *sock, struct ltt_kernel_session *session); int kernel_consumer_add_stream(struct consumer_socket *sock, struct ltt_kernel_channel *channel, struct ltt_kernel_stream *stream, - struct ltt_kernel_session *session); + struct ltt_kernel_session *session, unsigned int monitor); int kernel_consumer_add_metadata(struct consumer_socket *sock, - struct ltt_kernel_session *session, int no_monitor); + struct ltt_kernel_session *session, unsigned int monitor); int kernel_consumer_add_channel(struct consumer_socket *sock, - struct ltt_kernel_channel *channel, struct ltt_kernel_session *session); + struct ltt_kernel_channel *channel, struct ltt_kernel_session *session, + unsigned int monitor); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 3b27c6f36..c02f6d91e 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -646,7 +646,8 @@ static int update_kernel_stream(struct consumer_data *consumer_data, int fd) pthread_mutex_lock(socket->lock); ret = kernel_consumer_send_channel_stream(socket, - channel, ksess); + channel, ksess, + session->output_traces ? 1 : 0); pthread_mutex_unlock(socket->lock); if (ret < 0) { rcu_read_unlock(); @@ -2377,7 +2378,7 @@ static int create_ust_session(struct ltt_session *session, lus->uid = session->uid; lus->gid = session->gid; - + lus->output_traces = session->output_traces; session->ust_session = lus; /* Copy session output to the newly created UST session */ @@ -2434,6 +2435,7 @@ static int create_kernel_session(struct ltt_session *session) session->kernel_session->uid = session->uid; session->kernel_session->gid = session->gid; + session->kernel_session->output_traces = session->output_traces; return LTTNG_OK; diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index d1f6e5f00..21ffd336d 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -111,6 +111,8 @@ struct ltt_kernel_session { unsigned int id; /* Session is started and active */ unsigned int started; + /* Tell or not if the session has to output the traces. */ + unsigned int output_traces; }; /* diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index dcb45c237..03f37abaa 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -105,6 +105,8 @@ struct ltt_ust_session { uint64_t next_channel_id; /* Once this value reaches UINT32_MAX, no more id can be allocated. */ uint64_t used_channel_id; + /* Tell or not if the session has to output the traces. */ + unsigned int output_traces; }; /* diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index dd0f6f8db..56cbb8578 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1440,6 +1440,7 @@ static void shadow_copy_session(struct ust_app_session *ua_sess, ua_sess->bits_per_long = app->bits_per_long; /* There is only one consumer object per session possible. */ ua_sess->consumer = usess->consumer; + ua_sess->output_traces = usess->output_traces; switch (ua_sess->buffer_type) { case LTTNG_BUFFER_PER_PID: diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 298669440..74d4cd6a2 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -197,6 +197,8 @@ struct ust_app_session { uint32_t bits_per_long; /* For delayed reclaim */ struct rcu_head rcu_head; + /* If the channel's streams have to be outputed or not. */ + unsigned int output_traces; }; /* diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 367e92cd3..72b68bb7f 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -157,7 +157,8 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, registry->uuid, chan_id, ua_chan->tracefile_size, - ua_chan->tracefile_count); + ua_chan->tracefile_count, + ua_sess->output_traces); health_code_update(); diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index ddd2983e2..72702d5a5 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -40,6 +40,7 @@ static char *opt_url; static char *opt_ctrl_url; static char *opt_data_url; static int opt_no_consumer; +static int opt_no_output; static int opt_disable_consumer; enum { @@ -55,7 +56,8 @@ static struct poptOption long_options[] = { {"set-url", 'U', POPT_ARG_STRING, &opt_url, 0, 0, 0}, {"ctrl-url", 'C', POPT_ARG_STRING, &opt_ctrl_url, 0, 0, 0}, {"data-url", 'D', POPT_ARG_STRING, &opt_data_url, 0, 0, 0}, - {"no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0}, + {"no-output", 0, POPT_ARG_VAL, &opt_no_output, 1, 0, 0}, + {"no-consumer", 0, POPT_ARG_VAL, &opt_no_consumer, 1, 0, 0}, {"disable-consumer", 0, POPT_ARG_VAL, &opt_disable_consumer, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0} }; @@ -80,6 +82,7 @@ static void usage(FILE *ofp) fprintf(ofp, " -h, --help Show this help\n"); fprintf(ofp, " --list-options Simple listing of options\n"); fprintf(ofp, " -o, --output PATH Specify output path for traces\n"); + fprintf(ofp, " --no-output Traces will not be outputed\n"); fprintf(ofp, "\n"); fprintf(ofp, "Extended Options:\n"); fprintf(ofp, "\n"); @@ -248,7 +251,7 @@ static int create_session(void) } else if (opt_url) { /* Handling URL (-U opt) */ url = opt_url; print_str_url = url; - } else { + } else if (!opt_no_output) { /* Auto output path */ alloc_path = utils_get_home_dir(); if (alloc_path == NULL) { @@ -272,6 +275,9 @@ static int create_session(void) if (!opt_data_url && !opt_ctrl_url) { print_str_url = alloc_url + strlen("file://"); } + } else { + /* No output means --no-output. */ + url = NULL; } if ((!opt_ctrl_url && opt_data_url) || (opt_ctrl_url && !opt_data_url)) { @@ -357,7 +363,7 @@ int cmd_create(int argc, const char **argv) } if (opt_no_consumer) { - MSG("The option --no-consumer is obsolete."); + MSG("The option --no-consumer is obsolete. Use --no-output now."); ret = CMD_WARNING; goto end; } diff --git a/src/common/consumer.c b/src/common/consumer.c index b9b581880..e3b6cd5bf 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -747,7 +747,8 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uint64_t relayd_id, enum lttng_event_output output, uint64_t tracefile_size, - uint64_t tracefile_count) + uint64_t tracefile_count, + unsigned int monitor) { struct lttng_consumer_channel *channel; @@ -766,6 +767,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, channel->output = output; channel->tracefile_size = tracefile_size; channel->tracefile_count = tracefile_count; + channel->monitor = monitor; strncpy(channel->pathname, pathname, sizeof(channel->pathname)); channel->pathname[sizeof(channel->pathname) - 1] = '\0'; diff --git a/src/common/consumer.h b/src/common/consumer.h index d0986ef1e..9fadc5a06 100644 --- a/src/common/consumer.h +++ b/src/common/consumer.h @@ -156,6 +156,12 @@ struct lttng_consumer_channel { /* On-disk circular buffer */ uint64_t tracefile_size; uint64_t tracefile_count; + /* + * Monitor or not the streams of this channel meaning this indicates if the + * streams should be sent to the data/metadata thread or added to the no + * monitor list of the channel. + */ + unsigned int monitor; }; /* @@ -476,7 +482,8 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key, uint64_t relayd_id, enum lttng_event_output output, uint64_t tracefile_size, - uint64_t tracefile_count); + uint64_t tracefile_count, + unsigned int monitor); void consumer_del_stream(struct lttng_consumer_stream *stream, struct lttng_ht *ht); void consumer_del_metadata_stream(struct lttng_consumer_stream *stream, diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index d4a0d7c67..86428f066 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -144,7 +144,8 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.channel.name, msg.u.channel.uid, msg.u.channel.gid, msg.u.channel.relayd_id, msg.u.channel.output, msg.u.channel.tracefile_size, - msg.u.channel.tracefile_count); + msg.u.channel.tracefile_count, + msg.u.channel.monitor); if (new_channel == NULL) { lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR); goto end_nosignal; @@ -317,7 +318,8 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } } - if (msg.u.stream.no_monitor) { + /* Do not monitor this stream. */ + if (!channel->monitor) { DBG("Kernel consumer add stream %s in no monitor mode with" "relayd id %" PRIu64, new_stream->name, new_stream->relayd_stream_id); @@ -561,8 +563,11 @@ int lttng_kconsumer_on_recv_stream(struct lttng_consumer_stream *stream) assert(stream); - /* Don't create anything if this is set for streaming. */ - if (stream->net_seq_idx == (uint64_t) -1ULL) { + /* + * Don't create anything if this is set for streaming or should not be + * monitored. + */ + if (stream->net_seq_idx == (uint64_t) -1ULL && stream->chan->monitor) { ret = utils_create_stream_file(stream->chan->pathname, stream->name, stream->chan->tracefile_size, stream->tracefile_count_current, stream->uid, stream->gid); diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 07c645cc7..07c3ff1f5 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -319,6 +319,8 @@ struct lttcomm_consumer_msg { int type; /* Per cpu or metadata. */ uint64_t tracefile_size; /* bytes */ uint32_t tracefile_count; /* number of tracefiles */ + /* If the channel's streams have to be monitored or not. */ + uint32_t monitor; } LTTNG_PACKED channel; /* Only used by Kernel. */ struct { uint64_t stream_key; @@ -360,6 +362,8 @@ struct lttcomm_consumer_msg { uint32_t chan_id; /* Channel ID on the tracer side. */ uint64_t tracefile_size; /* bytes */ uint32_t tracefile_count; /* number of tracefiles */ + /* Tells the consumer if the stream should be or not monitored. */ + uint32_t monitor; } LTTNG_PACKED ask_channel; struct { uint64_t key; diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 8ade3b35f..f24b5fa3e 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -114,13 +114,14 @@ error: static struct lttng_consumer_channel *allocate_channel(uint64_t session_id, const char *pathname, const char *name, uid_t uid, gid_t gid, int relayd_id, uint64_t key, enum lttng_event_output output, - uint64_t tracefile_size, uint64_t tracefile_count) + uint64_t tracefile_size, uint64_t tracefile_count, + unsigned int monitor) { assert(pathname); assert(name); return consumer_allocate_channel(key, session_id, pathname, name, uid, gid, - relayd_id, output, tracefile_size, tracefile_count); + relayd_id, output, tracefile_size, tracefile_count, monitor); } /* @@ -924,7 +925,8 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, msg.u.ask_channel.relayd_id, msg.u.ask_channel.key, (enum lttng_event_output) msg.u.ask_channel.output, msg.u.ask_channel.tracefile_size, - msg.u.ask_channel.tracefile_count); + msg.u.ask_channel.tracefile_count, + msg.u.ask_channel.monitor); if (!channel) { goto end_channel_error; } diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index c9693f711..3863aa1ce 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1471,7 +1471,7 @@ int _lttng_create_session_ext(const char *name, const char *url, struct lttcomm_session_msg lsm; struct lttng_uri *uris = NULL; - if (name == NULL || datetime == NULL || url == NULL) { + if (name == NULL || datetime == NULL) { return -LTTNG_ERR_INVALID; } -- 2.34.1