Introduce LTTNG_KERNEL_SESSION_SET_NAME
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 13 Aug 2019 18:14:23 +0000 (14:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 13 Aug 2019 20:30:37 +0000 (16:30 -0400)
The tracer controller (lttng-sessiond) can now inform the kernel tracer
of the name of the created session. This will allow the tracer to
propagate the information inside the trace metadata under a "env" field.

This information is normally inferred from the generated folder
structure where a trace rests.

Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-abi.c
lttng-abi.h
lttng-events.h

index ca943791fdc9f2875cfd6c9412c2686bd22e85ff..aab2caca467f15eadcfb916858931b134daad6d5 100644 (file)
@@ -453,6 +453,23 @@ fd_error:
        return ret;
 }
 
+static
+int lttng_abi_session_set_name(struct lttng_session *session,
+               struct lttng_kernel_session_name *name)
+{
+       size_t len;
+
+       len = strnlen(name->name, LTTNG_KERNEL_SESSION_NAME_LEN);
+
+       if (len == LTTNG_KERNEL_SESSION_NAME_LEN) {
+               /* Name is too long/malformed */
+               return -EINVAL;
+       }
+
+       strcpy(session->name, name->name);
+       return 0;
+}
+
 /**
  *     lttng_session_ioctl - lttng session fd ioctl
  *
@@ -562,6 +579,16 @@ long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                return lttng_session_metadata_regenerate(session);
        case LTTNG_KERNEL_SESSION_STATEDUMP:
                return lttng_session_statedump(session);
+       case LTTNG_KERNEL_SESSION_SET_NAME:
+       {
+               struct lttng_kernel_session_name name;
+
+               if (copy_from_user(&name,
+                               (struct lttng_kernel_session_name __user *) arg,
+                               sizeof(struct lttng_kernel_session_name)))
+                       return -EFAULT;
+               return lttng_abi_session_set_name(session, &name);
+       }
        default:
                return -ENOIOCTLCMD;
        }
index 83bf93180bc6d97c8a048f561051f2a9a06d038e..0dd9a9fe91c561bc52a9e91ef338e14873365a3a 100644 (file)
  * should be increased when an incompatible ABI change is done.
  */
 #define LTTNG_MODULES_ABI_MAJOR_VERSION                2
-#define LTTNG_MODULES_ABI_MINOR_VERSION                3
+#define LTTNG_MODULES_ABI_MINOR_VERSION                4
 
 #define LTTNG_KERNEL_SYM_NAME_LEN      256
+#define LTTNG_KERNEL_SESSION_NAME_LEN  256
 
 enum lttng_kernel_instrumentation {
        LTTNG_KERNEL_TRACEPOINT = 0,
@@ -119,6 +120,10 @@ struct lttng_kernel_tracer_abi_version {
        uint32_t minor;
 } __attribute__((packed));
 
+struct lttng_kernel_session_name {
+       char name[LTTNG_KERNEL_SESSION_NAME_LEN];
+} __attribute__((packed));
+
 enum lttng_kernel_calibrate_type {
        LTTNG_KERNEL_CALIBRATE_KRETPROBE,
 };
@@ -209,8 +214,11 @@ struct lttng_kernel_filter_bytecode {
  */
 #define LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58)
 #define LTTNG_KERNEL_SESSION_METADATA_REGEN    _IO(0xF6, 0x59)
+
 /* 0x5A and 0x5B are reserved for a future ABI-breaking cleanup. */
 #define LTTNG_KERNEL_SESSION_STATEDUMP         _IO(0xF6, 0x5C)
+#define LTTNG_KERNEL_SESSION_SET_NAME          \
+       _IOR(0xF6, 0x5D, struct lttng_kernel_session_name)
 
 /* Channel FD ioctl */
 #define LTTNG_KERNEL_STREAM                    _IO(0xF6, 0x62)
index f5a7d23dd7b89b40320281975fe656ceba78fd47..14c65c00d25c7695c426a095261e162065936718 100644 (file)
@@ -521,6 +521,7 @@ struct lttng_session {
        struct list_head enablers_head;
        /* Hash table of events */
        struct lttng_event_ht events_ht;
+       char name[LTTNG_KERNEL_SESSION_NAME_LEN];
 };
 
 struct lttng_metadata_cache {
This page took 0.028283 seconds and 4 git commands to generate.