Change disable channel command to be per domain
authorDavid Goulet <david.goulet@polymtl.ca>
Thu, 4 Aug 2011 00:55:02 +0000 (20:55 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Thu, 4 Aug 2011 00:55:02 +0000 (20:55 -0400)
Removes LTTNG_KERNEL_DISABLE_CHANNEL and use a generic command based on
lttng domain.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
liblttngctl/liblttngctl.c
liblttsessiondcomm/liblttsessiondcomm.h
ltt-sessiond/main.c

index aca8374a2ebc7f55a22ce0ddceafa15eca8788eb..f57201ab186be26ffe0106589325be5db42fe0a1 100644 (file)
@@ -450,29 +450,16 @@ int lttng_enable_channel(struct lttng_domain *domain,
 }
 
 /*
- * Disable recording for the channel for the kernel tracer.
+ * Disable channel.
+ *
+ * All tracing will be stopped for registered events of the channel.
  */
 int lttng_disable_channel(struct lttng_domain *domain, const char *name)
 {
-       int ret = -1;
-
        copy_string(lsm.u.disable.channel_name, name, NAME_MAX);
+       copy_lttng_domain(domain);
 
-       if (domain) {
-               switch (domain->type) {
-                       case LTTNG_DOMAIN_KERNEL:
-                               ret = ask_sessiond(LTTNG_KERNEL_DISABLE_CHANNEL, NULL);
-                               break;
-                       case LTTNG_DOMAIN_UST:
-                               ret = LTTCOMM_NOT_IMPLEMENTED;
-                               break;
-                       default:
-                               ret = LTTCOMM_UNKNOWN_DOMAIN;
-                               break;
-               };
-       }
-
-       return ret;
+       return ask_sessiond(LTTNG_DISABLE_CHANNEL, NULL);
 }
 
 /*
index ef55e86e30b343ab4d0c4100ade446ebbbc0bf6d..33be8dd8baef06b6a2324357460336e863123358 100644 (file)
@@ -43,7 +43,7 @@
 enum lttcomm_sessiond_command {
        /* Tracer context command */
        LTTNG_ADD_CONTEXT,
-       LTTNG_KERNEL_DISABLE_CHANNEL,
+       LTTNG_DISABLE_CHANNEL,
        LTTNG_KERNEL_DISABLE_EVENT,
        LTTNG_KERNEL_DISABLE_ALL_EVENT,
        LTTNG_KERNEL_ENABLE_CHANNEL,
index 49842520dd70db2a5e034f2b21d4ab652e707e54..7d453214ee1936830fcd846d9411610c414f3082 100644 (file)
@@ -1296,7 +1296,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
        switch (cmd_ctx->lsm->cmd_type) {
        case LTTNG_ADD_CONTEXT:
        case LTTNG_KERNEL_DISABLE_ALL_EVENT:
-       case LTTNG_KERNEL_DISABLE_CHANNEL:
+       case LTTNG_DISABLE_CHANNEL:
        case LTTNG_KERNEL_DISABLE_EVENT:
        case LTTNG_KERNEL_ENABLE_ALL_EVENT:
        case LTTNG_KERNEL_ENABLE_CHANNEL:
@@ -1376,14 +1376,15 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                default:
                        /* TODO: Userspace tracing */
                        ret = LTTCOMM_NOT_IMPLEMENTED;
+                       goto error;
                }
 
                ret = LTTCOMM_OK;
                break;
        }
-       case LTTNG_KERNEL_DISABLE_CHANNEL:
+       case LTTNG_DISABLE_CHANNEL:
        {
-               struct ltt_kernel_channel *chan;
+               struct ltt_kernel_channel *kchan;
 
                /* Setup lttng message with no payload */
                ret = setup_lttng_msg(cmd_ctx, 0);
@@ -1391,22 +1392,30 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                        goto setup_error;
                }
 
-               chan = get_kernel_channel_by_name(cmd_ctx->lsm->u.disable.channel_name,
-                               cmd_ctx->session->kernel_session);
-               if (chan == NULL) {
-                       ret = LTTCOMM_KERN_CHAN_NOT_FOUND;
-                       goto error;
-               } else if (chan->enabled == 1) {
-                       ret = kernel_disable_channel(chan);
-                       if (ret < 0) {
-                               if (ret != EEXIST) {
-                                       ret = LTTCOMM_KERN_CHAN_DISABLE_FAIL;
-                               }
+               switch (cmd_ctx->lsm->domain.type) {
+               case LTTNG_DOMAIN_KERNEL:
+                       kchan = get_kernel_channel_by_name(cmd_ctx->lsm->u.disable.channel_name,
+                                       cmd_ctx->session->kernel_session);
+                       if (kchan == NULL) {
+                               ret = LTTCOMM_KERN_CHAN_NOT_FOUND;
                                goto error;
+                       } else if (kchan->enabled == 1) {
+                               ret = kernel_disable_channel(kchan);
+                               if (ret < 0) {
+                                       if (ret != EEXIST) {
+                                               ret = LTTCOMM_KERN_CHAN_DISABLE_FAIL;
+                                       }
+                                       goto error;
+                               }
                        }
+                       kernel_wait_quiescent(kernel_tracer_fd);
+                       break;
+               default:
+                       /* TODO: Userspace tracing */
+                       ret = LTTCOMM_NOT_IMPLEMENTED;
+                       goto error;
                }
 
-               kernel_wait_quiescent(kernel_tracer_fd);
                ret = LTTCOMM_OK;
                break;
        }
This page took 0.042303 seconds and 4 git commands to generate.