}
/*
- * 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)
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;
*/
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:
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);
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);
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;
}