From f5177a38890d9d7f3324f9bc1d87c9cb77fcc2b3 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 3 Aug 2011 21:21:12 -0400 Subject: [PATCH] Change disable event command to be per domain Removes LTTNG_KERNEL_DISABLE_EVENT and use a generic command based on lttng domain. Signed-off-by: David Goulet --- liblttngctl/liblttngctl.c | 26 ++----- liblttsessiondcomm/liblttsessiondcomm.h | 4 +- ltt-sessiond/main.c | 97 +++++++++++++++---------- 3 files changed, 67 insertions(+), 60 deletions(-) diff --git a/liblttngctl/liblttngctl.c b/liblttngctl/liblttngctl.c index fd5a552cf..37a0f8b8b 100644 --- a/liblttngctl/liblttngctl.c +++ b/liblttngctl/liblttngctl.c @@ -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; diff --git a/liblttsessiondcomm/liblttsessiondcomm.h b/liblttsessiondcomm/liblttsessiondcomm.h index 8ebadfdab..5cb615187 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.h +++ b/liblttsessiondcomm/liblttsessiondcomm.h @@ -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, diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index cf88db971..c2a4be9af 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -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; } -- 2.34.1