+ {
+ struct ltt_kernel_channel *kchan;
+ struct ltt_kernel_session *ksess;
+
+ ksess = session->kernel_session;
+
+ /*
+ * If a non-default channel has been created in the
+ * session, explicitely require that -c chan_name needs
+ * to be provided.
+ */
+ if (ksess->has_non_default_channel && channel_name[0] == '\0') {
+ ret = LTTNG_ERR_NEED_CHANNEL_NAME;
+ goto error;
+ }
+
+ kchan = trace_kernel_get_channel_by_name(channel_name, ksess);
+ if (kchan == NULL) {
+ ret = LTTNG_ERR_KERN_CHAN_NOT_FOUND;
+ goto error;
+ }
+
+ switch (event->type) {
+ case LTTNG_EVENT_ALL:
+ ret = event_kernel_disable_event_all(kchan);
+ if (ret != LTTNG_OK) {
+ goto error;
+ }
+ break;
+ case LTTNG_EVENT_TRACEPOINT: /* fall-through */
+ case LTTNG_EVENT_SYSCALL:
+ if (!strcmp(event_name, "*")) {
+ ret = event_kernel_disable_event_type(kchan,
+ event->type);
+ } else {
+ ret = event_kernel_disable_event(kchan,
+ event_name);
+ }
+ if (ret != LTTNG_OK) {
+ goto error;
+ }
+ break;
+ case LTTNG_EVENT_PROBE:
+ case LTTNG_EVENT_FUNCTION:
+ case LTTNG_EVENT_FUNCTION_ENTRY:
+ ret = event_kernel_disable_event(kchan, event_name);
+ if (ret != LTTNG_OK) {
+ goto error;
+ }
+ break;
+ default:
+ ret = LTTNG_ERR_UNK;
+ goto error;
+ }
+
+ kernel_wait_quiescent(kernel_tracer_fd);
+ break;
+ }
+ case LTTNG_DOMAIN_UST:
+ {
+ struct ltt_ust_channel *uchan;
+ struct ltt_ust_session *usess;
+
+ usess = session->ust_session;
+
+ /*
+ * If a non-default channel has been created in the
+ * session, explicitely require that -c chan_name needs
+ * to be provided.
+ */
+ if (usess->has_non_default_channel && channel_name[0] == '\0') {
+ ret = LTTNG_ERR_NEED_CHANNEL_NAME;
+ goto error;
+ }
+
+ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
+ channel_name);
+ if (uchan == NULL) {
+ ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
+ goto error;
+ }
+
+ switch (event->type) {
+ case LTTNG_EVENT_ALL:
+ ret = event_ust_disable_tracepoint(usess, uchan, event_name);
+ if (ret != LTTNG_OK) {
+ goto error;
+ }
+ break;
+ default:
+ ret = LTTNG_ERR_UNK;
+ goto error;
+ }
+
+ DBG3("Disable UST event %s in channel %s completed", event_name,
+ channel_name);
+ break;
+ }
+ case LTTNG_DOMAIN_LOG4J:
+ case LTTNG_DOMAIN_JUL:
+ case LTTNG_DOMAIN_PYTHON:
+ {
+ struct agent *agt;
+ struct ltt_ust_session *usess = session->ust_session;
+
+ assert(usess);
+
+ switch (event->type) {
+ case LTTNG_EVENT_ALL:
+ break;
+ default:
+ ret = LTTNG_ERR_UNK;
+ goto error;
+ }
+
+ agt = trace_ust_find_agent(usess, domain);
+ if (!agt) {
+ ret = -LTTNG_ERR_UST_EVENT_NOT_FOUND;
+ goto error;
+ }
+ /* The wild card * means that everything should be disabled. */
+ if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) {
+ ret = event_agent_disable_all(usess, agt);
+ } else {
+ ret = event_agent_disable(usess, agt, event_name);
+ }
+ if (ret != LTTNG_OK) {
+ goto error;
+ }
+
+ break;
+ }
+ default:
+ ret = LTTNG_ERR_UND;
+ goto error;
+ }
+
+ ret = LTTNG_OK;
+
+error:
+ rcu_read_unlock();
+ return ret;
+}
+
+/*
+ * Command LTTNG_ADD_CONTEXT processed by the client thread.
+ */
+int cmd_add_context(struct ltt_session *session, int domain,
+ char *channel_name, struct lttng_event_context *ctx, int kwpipe)
+{
+ int ret, chan_kern_created = 0, chan_ust_created = 0;
+
+ switch (domain) {
+ case LTTNG_DOMAIN_KERNEL:
+ assert(session->kernel_session);