From: David Goulet Date: Wed, 23 Nov 2011 18:19:04 +0000 (-0500) Subject: Add UST default channel creation support X-Git-Tag: v2.0-pre15~82 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=aea829b3086fb53d411eb79a5abe0e706d4d9cf3;p=lttng-tools.git Add UST default channel creation support When enabling event without a channel specified, a default channel (channel0) will be created. Also fix the enabled flag for channels when listing them. Minor fix of code and comments. Signed-off-by: David Goulet --- diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index dc71e0eae..bca057543 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -1922,6 +1922,7 @@ static void list_lttng_channels(int domain, struct ltt_session *session, channels[i].attr.read_timer_interval = uchan->attr.read_timer_interval; channels[i].attr.output = uchan->attr.output; + channels[i].enabled = uchan->enabled; i++; } break; @@ -2134,14 +2135,14 @@ error: * Command LTTNG_ENABLE_CHANNEL processed by the client thread. */ static int cmd_enable_channel(struct ltt_session *session, - struct lttng_domain *domain, struct lttng_channel *attr) + int domain, struct lttng_channel *attr) { int ret; struct ltt_ust_session *usess = session->ust_session; DBG("Enabling channel %s for session %s", attr->name, session->name); - switch (domain->type) { + switch (domain) { case LTTNG_DOMAIN_KERNEL: { struct ltt_kernel_channel *kchan; @@ -2432,13 +2433,34 @@ static int cmd_enable_event(struct ltt_session *session, int domain, { struct ltt_ust_channel *uchan; struct ltt_ust_event *uevent; + struct lttng_channel *attr; uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name); if (uchan == NULL) { - /* TODO: Create default channel */ - ret = LTTCOMM_UST_CHAN_NOT_FOUND; - goto error; + /* Create default channel */ + attr = channel_new_default_attr(domain); + if (attr == NULL) { + ret = LTTCOMM_FATAL; + goto error; + } + + /* Use the internal command enable channel */ + ret = cmd_enable_channel(session, domain, attr); + if (ret < 0) { + goto error; + } + + free(attr); + + /* Get the newly created channel reference back */ + uchan = trace_ust_find_channel_by_name( + usess->domain_global.channels, channel_name); + if (uchan == NULL) { + /* Something is really wrong */ + ret = LTTCOMM_FATAL; + goto error; + } } uevent = trace_ust_find_event_by_name(uchan->events, event->name); @@ -2720,7 +2742,6 @@ static int cmd_stop_trace(struct ltt_session *session) kernel_wait_quiescent(kernel_tracer_fd); } - /* Flag session that trace should start automatically */ if (usess) { usess->start_trace = 0; @@ -3159,7 +3180,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx) } case LTTNG_ENABLE_CHANNEL: { - ret = cmd_enable_channel(cmd_ctx->session, &cmd_ctx->lsm->domain, + ret = cmd_enable_channel(cmd_ctx->session, cmd_ctx->lsm->domain.type, &cmd_ctx->lsm->u.channel.chan); break; } diff --git a/lttng-sessiond/ust-app.c b/lttng-sessiond/ust-app.c index 78c84bd75..cd5829cb6 100644 --- a/lttng-sessiond/ust-app.c +++ b/lttng-sessiond/ust-app.c @@ -1146,9 +1146,10 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) goto error_rcu_unlock; } - /* upon restart, we skip the setup, already done */ - if (ua_sess->started) + /* Upon restart, we skip the setup, already done */ + if (ua_sess->started) { goto skip_setup; + } ret = create_ust_app_metadata(ua_sess, usess->pathname, app); if (ret < 0) { @@ -1199,6 +1200,7 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) ret = -EINVAL; goto error_rcu_unlock; } + /* Setup UST consumer socket and send fds to it */ ret = ust_consumer_send_session(consumerd_fd, ua_sess); if (ret < 0) { diff --git a/lttng-sessiond/ust-app.h b/lttng-sessiond/ust-app.h index ec6bafdfe..657ca4a12 100644 --- a/lttng-sessiond/ust-app.h +++ b/lttng-sessiond/ust-app.h @@ -96,7 +96,7 @@ struct ust_app_session { struct ust_app { pid_t ppid; uid_t uid; /* User ID that owns the apps */ - gid_t gid; /* Group ID that owns the apps */ + gid_t gid; /* Group ID that owns the apps */ int bits_per_long; uint32_t v_major; /* Verion major number */ uint32_t v_minor; /* Verion minor number */