Support LTTNG_KERNEL_SESSION_SET_NAME of lttng-modules
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 5 Sep 2019 22:23:53 +0000 (18:23 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 5 Sep 2019 22:50:15 +0000 (18:50 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/kernel.c
src/common/kernel-ctl/kernel-ctl.c
src/common/kernel-ctl/kernel-ctl.h
src/common/kernel-ctl/kernel-ioctl.h
src/common/lttng-kernel.h

index b79503b7d0185fd90b076c705f54ae6b90b8b3c2..daf14b3396f8e8792b50c52028310aff0cf164d4 100644 (file)
@@ -134,6 +134,20 @@ int kernel_create_session(struct ltt_session *session)
 
        DBG("Kernel session created (fd: %d)", lks->fd);
 
+       /*
+        * This is necessary since the creation time is present in the session
+        * name when it is generated.
+        */
+       if (session->has_auto_generated_name) {
+               ret = kernctl_session_set_name(lks->fd, DEFAULT_SESSION_NAME);
+       } else {
+               ret = kernctl_session_set_name(lks->fd, session->name);
+       }
+       if (ret) {
+               WARN("Could not set kernel session name for session %" PRIu64 " name: %s",
+                       session->id, session->name);
+       }
+
        return 0;
 
 error:
index 047d40a34d80ea611ff940a78efdb26ebf9127bd..c9c52b528d582d9282112b4d3d62d1a5903e13cd 100644 (file)
@@ -22,6 +22,7 @@
 #include <sys/ioctl.h>
 #include <string.h>
 #include <common/align.h>
+#include <common/macros.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <assert.h>
@@ -238,6 +239,22 @@ int kernctl_session_regenerate_statedump(int fd)
        return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_STATEDUMP);
 }
 
+int kernctl_session_set_name(int fd, const char *name)
+{
+       int ret;
+       struct lttng_kernel_session_name session_name;
+
+       ret = lttng_strncpy(session_name.name, name, sizeof(session_name.name));
+       if (ret) {
+               goto end;
+       }
+
+       ret = LTTNG_IOCTL_CHECK(
+                       fd, LTTNG_KERNEL_SESSION_SET_NAME, &session_name);
+end:
+       return ret;
+}
+
 int kernctl_create_stream(int fd)
 {
        return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_STREAM,
index 841c31da0d4c17d0fe353e32b0b73c73e0e3d65b..884929ac17753a5a90a429c56cd63d6534c1c37a 100644 (file)
@@ -67,6 +67,7 @@ int kernctl_list_tracker_pids(int fd);
 
 int kernctl_session_regenerate_metadata(int fd);
 int kernctl_session_regenerate_statedump(int fd);
+int kernctl_session_set_name(int fd, const char *name);
 
 /* Buffer operations */
 
index e7ff50b24349e0f152856a30177f36b6cbebb8f3..ce910e96f64a5c58100342d9b6cd976d94ae577a 100644 (file)
 #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 cd1a15f67cf256fb66c63edd2517acb1d9e683c8..001a16e2d4507e844535fdc88e4687f52160e636 100644 (file)
@@ -27,6 +27,7 @@
 
 #define LTTNG_KERNEL_SYM_NAME_LEN  256
 #define LTTNG_KERNEL_MAX_UPROBE_NUM  32
+#define LTTNG_KERNEL_SESSION_NAME_LEN  256
 
 /*
  * LTTng DebugFS ABI structures.
@@ -178,4 +179,11 @@ struct lttng_kernel_filter_bytecode {
        char data[0];
 } LTTNG_PACKED;
 
+/*
+ * kernel session name
+ */
+struct lttng_kernel_session_name {
+       char name[LTTNG_KERNEL_SESSION_NAME_LEN];
+} LTTNG_PACKED;
+
 #endif /* _LTTNG_KERNEL_H */
This page took 0.028982 seconds and 4 git commands to generate.