From: Jonathan Rajotte Date: Thu, 5 Sep 2019 22:23:53 +0000 (-0400) Subject: Support LTTNG_KERNEL_SESSION_SET_NAME of lttng-modules X-Git-Tag: v2.12.0-rc1~442 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8ff4109e3e6089d04c018a10c96c8498f893fdfb;p=lttng-tools.git Support LTTNG_KERNEL_SESSION_SET_NAME of lttng-modules Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index b79503b7d..daf14b339 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -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: diff --git a/src/common/kernel-ctl/kernel-ctl.c b/src/common/kernel-ctl/kernel-ctl.c index 047d40a34..c9c52b528 100644 --- a/src/common/kernel-ctl/kernel-ctl.c +++ b/src/common/kernel-ctl/kernel-ctl.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -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, diff --git a/src/common/kernel-ctl/kernel-ctl.h b/src/common/kernel-ctl/kernel-ctl.h index 841c31da0..884929ac1 100644 --- a/src/common/kernel-ctl/kernel-ctl.h +++ b/src/common/kernel-ctl/kernel-ctl.h @@ -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 */ diff --git a/src/common/kernel-ctl/kernel-ioctl.h b/src/common/kernel-ctl/kernel-ioctl.h index e7ff50b24..ce910e96f 100644 --- a/src/common/kernel-ctl/kernel-ioctl.h +++ b/src/common/kernel-ctl/kernel-ioctl.h @@ -145,6 +145,8 @@ #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) diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index cd1a15f67..001a16e2d 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -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 */