From: David Goulet Date: Thu, 4 Aug 2011 00:55:02 +0000 (-0400) Subject: Change disable channel command to be per domain X-Git-Tag: v2.0-pre7~11 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0b97ec540cc2e4561ddbef4d4542b6dfb59b0a43;p=lttng-tools.git Change disable channel command to be per domain Removes LTTNG_KERNEL_DISABLE_CHANNEL and use a generic command based on lttng domain. Signed-off-by: David Goulet --- diff --git a/liblttngctl/liblttngctl.c b/liblttngctl/liblttngctl.c index aca8374a2..f57201ab1 100644 --- a/liblttngctl/liblttngctl.c +++ b/liblttngctl/liblttngctl.c @@ -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); } /* diff --git a/liblttsessiondcomm/liblttsessiondcomm.h b/liblttsessiondcomm/liblttsessiondcomm.h index ef55e86e3..33be8dd8b 100644 --- a/liblttsessiondcomm/liblttsessiondcomm.h +++ b/liblttsessiondcomm/liblttsessiondcomm.h @@ -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, diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 49842520d..7d453214e 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -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; }