Add channel output method selection
[lttng-tools.git] / ltt-sessiond / main.c
index 01e75cbb26488f0cd68aff386d5e76da98a85223..92e41b1c6aff91b1573843079cfd3420b38dc275 100644 (file)
@@ -720,6 +720,7 @@ static struct lttng_channel *init_default_channel(void)
        chan->attr.num_subbuf = DEFAULT_CHANNEL_SUBBUF_NUM;
        chan->attr.switch_timer_interval = DEFAULT_CHANNEL_SWITCH_TIMER;
        chan->attr.read_timer_interval = DEFAULT_CHANNEL_READ_TIMER;
+       chan->attr.output = DEFAULT_CHANNEL_OUTPUT;
 
 error:
        return chan;
@@ -803,6 +804,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
         * Check kernel command for kernel session.
         */
        switch (cmd_ctx->lsm->cmd_type) {
+       case LTTNG_KERNEL_ADD_CONTEXT:
        case LTTNG_KERNEL_CREATE_CHANNEL:
        case LTTNG_KERNEL_DISABLE_ALL_EVENT:
        case LTTNG_KERNEL_DISABLE_CHANNEL:
@@ -852,6 +854,84 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
 
        /* Process by command type */
        switch (cmd_ctx->lsm->cmd_type) {
+       case LTTNG_KERNEL_ADD_CONTEXT:
+       {
+               int found = 0, no_event = 0;
+               struct ltt_kernel_channel *chan;
+               struct ltt_kernel_event *event;
+
+               /* Setup lttng message with no payload */
+               ret = setup_lttng_msg(cmd_ctx, 0);
+               if (ret < 0) {
+                       goto setup_error;
+               }
+
+               /* Check if event name is given */
+               if (strlen(cmd_ctx->lsm->u.context.event_name) == 0) {
+                       no_event = 1;
+               }
+
+               if (strlen(cmd_ctx->lsm->u.context.channel_name) == 0) {
+                       /* Go over all channels */
+                       DBG("Adding context to all channels");
+                       cds_list_for_each_entry(chan,
+                                       &cmd_ctx->session->kernel_session->channel_list.head, list) {
+                               if (no_event) {
+                                       ret = kernel_add_channel_context(chan,
+                                                       &cmd_ctx->lsm->u.context.ctx);
+                                       if (ret < 0) {
+                                               continue;
+                                       }
+                               } else {
+                                       event = get_kernel_event_by_name(cmd_ctx->lsm->u.context.event_name, chan);
+                                       if (event != NULL) {
+                                               ret = kernel_add_event_context(event,
+                                                               &cmd_ctx->lsm->u.context.ctx);
+                                               if (ret < 0) {
+                                                       ret = LTTCOMM_KERN_CONTEXT_FAIL;
+                                                       goto error;
+                                               }
+                                               found = 1;
+                                               break;
+                                       }
+                               }
+                       }
+               } else {
+                       chan = get_kernel_channel_by_name(cmd_ctx->lsm->u.context.channel_name,
+                                       cmd_ctx->session->kernel_session);
+                       if (chan == NULL) {
+                               ret = LTTCOMM_KERN_CHAN_NOT_FOUND;
+                               goto error;
+                       }
+
+                       if (no_event) {
+                               ret = kernel_add_channel_context(chan,
+                                               &cmd_ctx->lsm->u.context.ctx);
+                               if (ret < 0) {
+                                       ret = LTTCOMM_KERN_CONTEXT_FAIL;
+                                       goto error;
+                               }
+                       } else {
+                               event = get_kernel_event_by_name(cmd_ctx->lsm->u.context.event_name, chan);
+                               if (event != NULL) {
+                                       ret = kernel_add_event_context(event,
+                                                       &cmd_ctx->lsm->u.context.ctx);
+                                       if (ret < 0) {
+                                               ret = LTTCOMM_KERN_CONTEXT_FAIL;
+                                               goto error;
+                                       }
+                               }
+                       }
+               }
+
+               if (!found && !no_event) {
+                       ret = LTTCOMM_NO_EVENT;
+                       goto error;
+               }
+
+               ret = LTTCOMM_OK;
+               break;
+       }
        case LTTNG_KERNEL_CREATE_CHANNEL:
        {
                /* Setup lttng message with no payload */
@@ -1087,7 +1167,6 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                                ret = kernel_create_event(&ev_attr, chan);
                                if (ret < 0) {
                                        /* Ignore error here and continue */
-                                       continue;
                                }
                        }
 
This page took 0.024384 seconds and 4 git commands to generate.