Lttng-ctl: Expose sessiond cmd_clear_session command
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 11 Feb 2019 16:24:38 +0000 (11:24 -0500)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 18 Feb 2019 19:25:02 +0000 (14:25 -0500)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
include/lttng/session.h
src/bin/lttng-sessiond/client.c
src/common/sessiond-comm/sessiond-comm.h
src/lib/lttng-ctl/lttng-ctl.c

index 599892d13508d7470f829f6c89da84b18aea6b9c..dff6b45d40dedcf09001d76c1c7124f10c5e49d9 100644 (file)
@@ -84,6 +84,41 @@ extern int lttng_create_session_snapshot(const char *name,
 extern int lttng_create_session_live(const char *name, const char *url,
                unsigned int timer_interval);
 
+/*
+ * Clear a tracing session.
+ *
+ * Clear the data buffers and trace data.
+ *
+ * For sessions saving trace data to disk and streaming over the network to a
+ * relay daemon, the buffers content and existing stream files are cleared when
+ * the clear command is issued.
+ *
+ * For snapshot sessions (flight recorder), only the buffer content is cleared.
+ * Prior snapshots are individually recorded to disk, and are therefore
+ * untouched by this "clear" command.
+ *
+ * For live sessions streaming over network to a relay daemon, the buffers
+ * will be cleared, and the files on the relay daemon side will be cleared as
+ * well. However, any active live trace viewer currently reading an existing
+ * trace packet will be able to proceed to read that packet entirely before
+ * skipping over cleared stream data.
+ *
+ * The clear command guarantees that no trace data preceding the instant it is
+ * called will be in the resulting trace.
+ *
+ * Trace data produced from the moment it is called and when the
+ * function returned might be present in the resulting trace.
+ *
+ * Return 0 on success else a negative LTTng error code.
+ *
+ * Important error codes:
+ *    LTTNG_ERR_CLEAR_DISALLOWED_RELAY
+ *    LTTNG_ERR_CLEAR_NOT_AVAILABLE
+ *    LTTNG_ERR_CLEAR_NOT_AVAILABLE_RELAY
+ *    LTTNG_ERR_CLEAR_FAIL_CONSUMER
+*/
+extern int lttng_clear_session(const char *name);
+
 /*
  * Destroy a tracing session.
  *
index a889529a76967f881c9c05159ccdb55300336f51..31ee73c888e893c6c15b6e35c0babf3350d32a6b 100644 (file)
@@ -36,6 +36,7 @@
 #include "testpoint.h"
 #include "utils.h"
 #include "manage-consumer.h"
+#include "clear.h"
 
 static bool is_root;
 
@@ -740,6 +741,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock,
        case LTTNG_ROTATION_GET_INFO:
        case LTTNG_ROTATION_SET_SCHEDULE:
        case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
+       case LTTNG_CLEAR_SESSION:
                need_domain = 0;
                break;
        default:
@@ -2000,6 +2002,14 @@ error_add_context:
                ret = LTTNG_OK;
                break;
        }
+       case LTTNG_CLEAR_SESSION:
+       {
+               ret = cmd_clear_session(cmd_ctx->session);
+               if (ret != LTTNG_OK) {
+                       goto error;
+               }
+               break;
+       }
        default:
                ret = LTTNG_ERR_UND;
                break;
index 336ebe978a76250220231b5536e5e0633a775cba..f06553a7b5861f48bf82e7006d178bc1c2101910 100644 (file)
@@ -105,6 +105,7 @@ enum lttcomm_sessiond_command {
        LTTNG_ROTATION_GET_INFO               = 46,
        LTTNG_ROTATION_SET_SCHEDULE           = 47,
        LTTNG_SESSION_LIST_ROTATION_SCHEDULES = 48,
+       LTTNG_CLEAR_SESSION                   = 49,
 };
 
 enum lttcomm_relayd_command {
index 165fef4dc5c412392fe49daec62be947d4de3853..3b6423f6d3d7a4422727c4021587bf90346b4e56 100644 (file)
@@ -1784,6 +1784,26 @@ int lttng_create_session(const char *name, const char *url)
        return ret;
 }
 
+/*
+ * Clear the session
+ */
+int lttng_clear_session(const char *session_name)
+{
+       struct lttcomm_session_msg lsm;
+
+       if (session_name == NULL) {
+               return -LTTNG_ERR_INVALID;
+       }
+
+       memset(&lsm, 0, sizeof(lsm));
+
+       lsm.cmd_type = LTTNG_CLEAR_SESSION;
+       lttng_ctl_copy_string(lsm.session.name, session_name,
+                       sizeof(lsm.session.name));
+
+       return lttng_ctl_ask_sessiond(&lsm, NULL);
+}
+
 /*
  * Destroy session using name.
  * Returns size of returned session payload data or a negative error code.
This page took 0.032287 seconds and 5 git commands to generate.