Change disable event command to be per domain
authorDavid Goulet <david.goulet@polymtl.ca>
Thu, 4 Aug 2011 01:21:12 +0000 (21:21 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Thu, 4 Aug 2011 01:21:12 +0000 (21:21 -0400)
Removes LTTNG_KERNEL_DISABLE_EVENT 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 fd5a552cf012d94e904b72f77cf7dc86d9635e72..37a0f8b8b257ca13026eedaf98d9dda88184bfc2 100644 (file)
@@ -385,7 +385,7 @@ int lttng_enable_event(struct lttng_domain *domain,
 }
 
 /*
- * Disable an event in the kernel tracer.
+ * Disable event of a channel and domain.
  */
 int lttng_disable_event(struct lttng_domain *domain, const char *name,
                const char *channel_name)
@@ -398,23 +398,13 @@ int lttng_disable_event(struct lttng_domain *domain, const char *name,
                copy_string(lsm.u.disable.channel_name, channel_name, NAME_MAX);
        }
 
-       if (domain) {
-               switch (domain->type) {
-                       case LTTNG_DOMAIN_KERNEL:
-                               if (name == NULL) {
-                                       ret = ask_sessiond(LTTNG_KERNEL_DISABLE_ALL_EVENT, NULL);
-                               } else {
-                                       copy_string(lsm.u.disable.name, name, NAME_MAX);
-                                       ret = ask_sessiond(LTTNG_KERNEL_DISABLE_EVENT, NULL);
-                               }
-                               break;
-                       case LTTNG_DOMAIN_UST:
-                               ret = LTTCOMM_NOT_IMPLEMENTED;
-                               break;
-                       default:
-                               ret = LTTCOMM_UNKNOWN_DOMAIN;
-                               break;
-               };
+       copy_lttng_domain(domain);
+
+       if (name == NULL) {
+               ret = ask_sessiond(LTTNG_DISABLE_ALL_EVENT, NULL);
+       } else {
+               copy_string(lsm.u.disable.name, name, NAME_MAX);
+               ret = ask_sessiond(LTTNG_DISABLE_EVENT, NULL);
        }
 
        return ret;
index 8ebadfdabf089593a8f783d32a414f72498085c9..5cb6151876379f5de9e15523764eed456aee8f6d 100644 (file)
@@ -44,8 +44,8 @@ enum lttcomm_sessiond_command {
        /* Tracer context command */
        LTTNG_ADD_CONTEXT,
        LTTNG_DISABLE_CHANNEL,
-       LTTNG_KERNEL_DISABLE_EVENT,
-       LTTNG_KERNEL_DISABLE_ALL_EVENT,
+       LTTNG_DISABLE_EVENT,
+       LTTNG_DISABLE_ALL_EVENT,
        LTTNG_KERNEL_ENABLE_CHANNEL,
        LTTNG_KERNEL_ENABLE_EVENT,
        LTTNG_KERNEL_ENABLE_ALL_EVENT,
index cf88db97159c3c661d9b06201e0df6953fa003dc..c2a4be9af24e76f8d83459480487ccf16f9b3de0 100644 (file)
@@ -1295,9 +1295,9 @@ 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_DISABLE_ALL_EVENT:
        case LTTNG_DISABLE_CHANNEL:
-       case LTTNG_KERNEL_DISABLE_EVENT:
+       case LTTNG_DISABLE_EVENT:
        case LTTNG_KERNEL_ENABLE_ALL_EVENT:
        case LTTNG_KERNEL_ENABLE_CHANNEL:
        case LTTNG_KERNEL_ENABLE_EVENT:
@@ -1419,10 +1419,10 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                ret = LTTCOMM_OK;
                break;
        }
-       case LTTNG_KERNEL_DISABLE_EVENT:
+       case LTTNG_DISABLE_EVENT:
        {
-               struct ltt_kernel_channel *chan;
-               struct ltt_kernel_event *ev;
+               struct ltt_kernel_channel *kchan;
+               struct ltt_kernel_event *kevent;
 
                /* Setup lttng message with no payload */
                ret = setup_lttng_msg(cmd_ctx, 0);
@@ -1430,32 +1430,41 @@ 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;
-               }
-
-               ev = get_kernel_event_by_name(cmd_ctx->lsm->u.disable.name, chan);
-               if (ev != NULL) {
-                       DBG("Disabling kernel event %s for channel %s.",
-                                       cmd_ctx->lsm->u.disable.name, cmd_ctx->lsm->u.disable.channel_name);
-                       ret = kernel_disable_event(ev);
-                       if (ret < 0) {
-                               ret = LTTCOMM_KERN_ENABLE_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;
                        }
+
+                       kevent = get_kernel_event_by_name(cmd_ctx->lsm->u.disable.name, kchan);
+                       if (kevent != NULL) {
+                               DBG("Disabling kernel event %s for channel %s.", kevent->event->name,
+                                               kchan->channel->name);
+                               ret = kernel_disable_event(kevent);
+                               if (ret < 0) {
+                                       ret = LTTCOMM_KERN_ENABLE_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;
        }
-       case LTTNG_KERNEL_DISABLE_ALL_EVENT:
+       case LTTNG_DISABLE_ALL_EVENT:
        {
-               struct ltt_kernel_channel *chan;
-               struct ltt_kernel_event *ev;
+               struct ltt_kernel_channel *kchan;
+               struct ltt_kernel_event *kevent;
 
                /* Setup lttng message with no payload */
                ret = setup_lttng_msg(cmd_ctx, 0);
@@ -1463,27 +1472,35 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                        goto setup_error;
                }
 
-               DBG("Disabling all enabled kernel events");
-
-               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;
-               }
+               switch (cmd_ctx->lsm->domain.type) {
+               case LTTNG_DOMAIN_KERNEL:
+                       DBG("Disabling all enabled kernel events");
+                       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;
+                       }
 
-               /* For each event in the kernel session */
-               cds_list_for_each_entry(ev, &chan->events_list.head, list) {
-                       DBG("Disabling kernel event %s for channel %s.",
-                                       ev->event->name, cmd_ctx->lsm->u.disable.channel_name);
-                       ret = kernel_disable_event(ev);
-                       if (ret < 0) {
-                               continue;
+                       /* For each event in the kernel session */
+                       cds_list_for_each_entry(kevent, &kchan->events_list.head, list) {
+                               DBG("Disabling kernel event %s for channel %s.",
+                                               kevent->event->name, kchan->channel->name);
+                               ret = kernel_disable_event(kevent);
+                               if (ret < 0) {
+                                       continue;
+                               }
                        }
+
+                       /* Quiescent wait after event disable */
+                       kernel_wait_quiescent(kernel_tracer_fd);
+                       break;
+               default:
+                       /* TODO: Userspace tracing */
+                       ret = LTTCOMM_NOT_IMPLEMENTED;
+                       goto error;
                }
 
-               /* Quiescent wait after event disable */
-               kernel_wait_quiescent(kernel_tracer_fd);
                ret = LTTCOMM_OK;
                break;
        }
This page took 0.041061 seconds and 4 git commands to generate.