Don't report back error on syscalls fail for -a -k
authorDavid Goulet <dgoulet@efficios.com>
Fri, 6 Apr 2012 19:24:53 +0000 (15:24 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 10 Apr 2012 15:00:57 +0000 (11:00 -0400)
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 <dgoulet@efficios.com>
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/kernel.c
src/common/sessiond-comm/sessiond-comm.c
src/common/sessiond-comm/sessiond-comm.h

index ac4b0b4a365f7f493973f7389cd58f241c8292ae..6e9cc006f9e32b3540910dc79c2578ec94e23d40 100644 (file)
@@ -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;
 }
 
 /*
index 596af588c5800c4bd6754bd9ec00de93b3381649..39006ab2f37b508107fb468a427debb7d82bb566 100644 (file)
@@ -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;
index f396c42f3c4417499a4534af41523a56fd2a1d33..11319f333e84f34d30a75132d981444d136f7e24 100644 (file)
@@ -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",
index dbb744c0c1bfce51be428184e38176b1251dee01..6cc98d542e9a0b54797fb143cc588dbb49133348 100644 (file)
@@ -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 */
This page took 0.029705 seconds and 4 git commands to generate.