Add UST default channel creation support
authorDavid Goulet <david.goulet@polymtl.ca>
Wed, 23 Nov 2011 18:19:04 +0000 (13:19 -0500)
committerDavid Goulet <david.goulet@polymtl.ca>
Wed, 23 Nov 2011 18:19:04 +0000 (13:19 -0500)
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 <david.goulet@polymtl.ca>
lttng-sessiond/main.c
lttng-sessiond/ust-app.c
lttng-sessiond/ust-app.h

index dc71e0eaea851990e8982f7152f5bd043733cdaa..bca057543f7afd6762be1377befef278b5120a11 100644 (file)
@@ -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;
        }
index 78c84bd755a82e0313743fc853bd77faac5648d2..cd5829cb6342bcc8f19676d1698c4193b9a9564d 100644 (file)
@@ -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) {
index ec6bafdfed38aaabafeeca25a71b3fcd484d5cea..657ca4a1289d5abf17d623b7544d2fa2d78b8c56 100644 (file)
@@ -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 */
This page took 0.031746 seconds and 4 git commands to generate.