From: David Goulet Date: Fri, 6 Apr 2012 19:24:53 +0000 (-0400) Subject: Don't report back error on syscalls fail for -a -k X-Git-Tag: v2.1.0-rc1~159 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bd29c13d4c9296705a4444404a69c0557e5b8cb9;p=lttng-tools.git Don't report back error on syscalls fail for -a -k lttng enable-event -a -k will not report an error anymmore if enabling syscall events has failed. Please refer to the commitdiff for a detailed comment on why this is done like so. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index ac4b0b4a3..6e9cc006f 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -134,10 +134,16 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession, if (kevent == NULL) { ret = kernel_create_event(event, kchan); if (ret < 0) { - if (ret == -EEXIST) { + switch (-ret) { + case EEXIST: ret = LTTCOMM_KERN_EVENT_EXIST; - } else { + break; + case ENOSYS: + ret = LTTCOMM_KERN_EVENT_ENOSYS; + break; + default: ret = LTTCOMM_KERN_ENABLE_FAIL; + break; } goto end; } @@ -239,15 +245,27 @@ end: int event_kernel_enable_all(struct ltt_kernel_session *ksession, struct ltt_kernel_channel *kchan, int kernel_tracer_fd) { - int ret; + int tp_ret, syscall_ret; - ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd); - if (ret != LTTCOMM_OK) { + tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd); + if (tp_ret != LTTCOMM_OK) { goto end; } - ret = event_kernel_enable_all_syscalls(ksession, kchan, kernel_tracer_fd); + + /* + * Reaching this code path means that all tracepoints were enabled without + * errors so we ignore the error value of syscalls. + * + * At the moment, failing to enable syscalls on "lttng enable-event -a -k" + * is not considered an error that need to be returned to the client since + * tracepoints did not fail. Future work will allow us to send back + * multiple errors to the client in one API call. + */ + syscall_ret = event_kernel_enable_all_syscalls(ksession, kchan, + kernel_tracer_fd); + end: - return ret; + return tp_ret; } /* diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 596af588c..39006ab2f 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -196,7 +196,13 @@ int kernel_create_event(struct lttng_event *ev, ret = kernctl_create_event(channel->fd, event->event); if (ret < 0) { - if (errno != EEXIST) { + switch (errno) { + case EEXIST: + break; + case ENOSYS: + WARN("Event type not implemented"); + break; + default: PERROR("create event ioctl"); } ret = -errno; diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index f396c42f3..11319f333 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -105,6 +105,7 @@ static const char *lttcomm_readable_code[] = { [ LTTCOMM_ERR_INDEX(LTTCOMM_NEED_ROOT_SESSIOND) ] = "Tracing the kernel requires a root lttng-sessiond daemon and \"tracing\" group user membership", [ LTTCOMM_ERR_INDEX(LTTCOMM_TRACE_ALREADY_STARTED) ] = "Tracing already started", [ LTTCOMM_ERR_INDEX(LTTCOMM_TRACE_ALREADY_STOPPED) ] = "Tracing already stopped", + [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_EVENT_ENOSYS) ] = "Kernel event type not supported", [ LTTCOMM_ERR_INDEX(CONSUMERD_COMMAND_SOCK_READY) ] = "consumerd command socket ready", [ LTTCOMM_ERR_INDEX(CONSUMERD_SUCCESS_RECV_FD) ] = "consumerd success on receiving fds", diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index dbb744c0c..6cc98d542 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -140,6 +140,7 @@ enum lttcomm_return_code { LTTCOMM_NEED_ROOT_SESSIOND, /* root sessiond is needed */ LTTCOMM_TRACE_ALREADY_STARTED, /* Tracing already started */ LTTCOMM_TRACE_ALREADY_STOPPED, /* Tracing already stopped */ + LTTCOMM_KERN_EVENT_ENOSYS, /* Kernel event type not supported */ CONSUMERD_COMMAND_SOCK_READY, /* when consumerd command socket ready */ CONSUMERD_SUCCESS_RECV_FD, /* success on receiving fds */