[lttng-dev] [PATCH lttng-tools 1/4] RFC: Add kernel namespace contexts

Michael Jeanson mjeanson at efficios.com
Tue Mar 6 15:53:49 EST 2018


Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
 include/lttng/event.h                  |  7 +++++++
 src/bin/lttng-sessiond/context.c       | 21 +++++++++++++++++++++
 src/bin/lttng-sessiond/save.c          | 21 +++++++++++++++++++++
 src/bin/lttng/commands/add_context.c   | 14 ++++++++++++++
 src/common/config/config-session-abi.h |  7 +++++++
 src/common/config/session-config.c     | 28 ++++++++++++++++++++++++++++
 src/common/lttng-kernel.h              |  7 +++++++
 7 files changed, 105 insertions(+)

diff --git a/include/lttng/event.h b/include/lttng/event.h
index 16b4d4f..44edd52 100644
--- a/include/lttng/event.h
+++ b/include/lttng/event.h
@@ -142,6 +142,13 @@ enum lttng_event_context_type {
 	LTTNG_EVENT_CONTEXT_PREEMPTIBLE		= 17,
 	LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE	= 18,
 	LTTNG_EVENT_CONTEXT_MIGRATABLE		= 19,
+	LTTNG_EVENT_CONTEXT_CGROUP_NS		= 20,
+	LTTNG_EVENT_CONTEXT_IPC_NS		= 21,
+	LTTNG_EVENT_CONTEXT_MNT_NS		= 22,
+	LTTNG_EVENT_CONTEXT_NET_NS		= 23,
+	LTTNG_EVENT_CONTEXT_PID_NS		= 24,
+	LTTNG_EVENT_CONTEXT_USER_NS		= 25,
+	LTTNG_EVENT_CONTEXT_UTS_NS		= 26,
 };
 
 enum lttng_event_field_type {
diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c
index 3c7c34d..14f2180 100644
--- a/src/bin/lttng-sessiond/context.c
+++ b/src/bin/lttng-sessiond/context.c
@@ -259,6 +259,27 @@ int context_kernel_add(struct ltt_kernel_session *ksession,
 	case LTTNG_EVENT_CONTEXT_MIGRATABLE:
 		kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_MIGRATABLE;
 		break;
+	case LTTNG_EVENT_CONTEXT_CGROUP_NS:
+		kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_CGROUP_NS;
+		break;
+	case LTTNG_EVENT_CONTEXT_IPC_NS:
+		kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_IPC_NS;
+		break;
+	case LTTNG_EVENT_CONTEXT_MNT_NS:
+		kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_MNT_NS;
+		break;
+	case LTTNG_EVENT_CONTEXT_NET_NS:
+		kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_NET_NS;
+		break;
+	case LTTNG_EVENT_CONTEXT_PID_NS:
+		kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PID_NS;
+		break;
+	case LTTNG_EVENT_CONTEXT_USER_NS:
+		kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_USER_NS;
+		break;
+	case LTTNG_EVENT_CONTEXT_UTS_NS:
+		kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_UTS_NS;
+		break;
 	default:
 		ret = LTTNG_ERR_KERN_CONTEXT_FAIL;
 		goto error;
diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c
index af01654..3bfeaab 100644
--- a/src/bin/lttng-sessiond/save.c
+++ b/src/bin/lttng-sessiond/save.c
@@ -285,6 +285,27 @@ const char *get_kernel_context_type_string(
 	case LTTNG_KERNEL_CONTEXT_MIGRATABLE:
 		context_type_string = config_event_context_migratable;
 		break;
+	case LTTNG_KERNEL_CONTEXT_CGROUP_NS:
+		context_type_string = config_event_context_cgroup_ns;
+		break;
+	case LTTNG_KERNEL_CONTEXT_IPC_NS:
+		context_type_string = config_event_context_ipc_ns;
+		break;
+	case LTTNG_KERNEL_CONTEXT_MNT_NS:
+		context_type_string = config_event_context_mnt_ns;
+		break;
+	case LTTNG_KERNEL_CONTEXT_NET_NS:
+		context_type_string = config_event_context_net_ns;
+		break;
+	case LTTNG_KERNEL_CONTEXT_PID_NS:
+		context_type_string = config_event_context_pid_ns;
+		break;
+	case LTTNG_KERNEL_CONTEXT_USER_NS:
+		context_type_string = config_event_context_user_ns;
+		break;
+	case LTTNG_KERNEL_CONTEXT_UTS_NS:
+		context_type_string = config_event_context_uts_ns;
+		break;
 	default:
 		context_type_string = NULL;
 	}
diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c
index d9121b0..1e9977f 100644
--- a/src/bin/lttng/commands/add_context.c
+++ b/src/bin/lttng/commands/add_context.c
@@ -84,6 +84,13 @@ enum context_type {
 	CONTEXT_PREEMPTIBLE  = 17,
 	CONTEXT_NEED_RESCHEDULE = 18,
 	CONTEXT_MIGRATABLE   = 19,
+	CONTEXT_CGROUP_NS    = 20,
+	CONTEXT_IPC_NS       = 21,
+	CONTEXT_MNT_NS       = 22,
+	CONTEXT_NET_NS       = 23,
+	CONTEXT_PID_NS       = 24,
+	CONTEXT_USER_NS      = 25,
+	CONTEXT_UTS_NS       = 26,
 };
 
 /*
@@ -240,6 +247,13 @@ const struct ctx_opts {
 	{ "preemptible", CONTEXT_PREEMPTIBLE },
 	{ "need_reschedule", CONTEXT_NEED_RESCHEDULE },
 	{ "migratable", CONTEXT_MIGRATABLE },
+	{ "cgroup_ns", CONTEXT_CGROUP_NS },
+	{ "ipc_ns", CONTEXT_IPC_NS },
+	{ "mnt_ns", CONTEXT_MNT_NS },
+	{ "net_ns", CONTEXT_NET_NS },
+	{ "pid_ns", CONTEXT_PID_NS },
+	{ "user_ns", CONTEXT_USER_NS },
+	{ "uts_ns", CONTEXT_UTS_NS },
 
 	/* Perf options */
 
diff --git a/src/common/config/config-session-abi.h b/src/common/config/config-session-abi.h
index 5f91109..d1c51c0c 100644
--- a/src/common/config/config-session-abi.h
+++ b/src/common/config/config-session-abi.h
@@ -129,5 +129,12 @@ extern const char * const config_event_context_interruptible;
 extern const char * const config_event_context_preemptible;
 extern const char * const config_event_context_need_reschedule;
 extern const char * const config_event_context_migratable;
+extern const char * const config_event_context_cgroup_ns;
+extern const char * const config_event_context_ipc_ns;
+extern const char * const config_event_context_mnt_ns;
+extern const char * const config_event_context_net_ns;
+extern const char * const config_event_context_pid_ns;
+extern const char * const config_event_context_user_ns;
+extern const char * const config_event_context_uts_ns;
 
 #endif /* CONFIG_SESSION_INTERNAL_H */
diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c
index 783a74a..130a095 100644
--- a/src/common/config/session-config.c
+++ b/src/common/config/session-config.c
@@ -179,6 +179,13 @@ LTTNG_HIDDEN const char * const config_event_context_interruptible = "INTERRUPTI
 LTTNG_HIDDEN const char * const config_event_context_preemptible = "PREEMPTIBLE";
 LTTNG_HIDDEN const char * const config_event_context_need_reschedule = "NEED_RESCHEDULE";
 LTTNG_HIDDEN const char * const config_event_context_migratable = "MIGRATABLE";
+LTTNG_HIDDEN const char * const config_event_context_cgroup_ns = "CGROUP_NS";
+LTTNG_HIDDEN const char * const config_event_context_ipc_ns = "IPC_NS";
+LTTNG_HIDDEN const char * const config_event_context_mnt_ns = "MNT_NS";
+LTTNG_HIDDEN const char * const config_event_context_net_ns = "NET_NS";
+LTTNG_HIDDEN const char * const config_event_context_pid_ns = "PID_NS";
+LTTNG_HIDDEN const char * const config_event_context_user_ns = "USER_NS";
+LTTNG_HIDDEN const char * const config_event_context_uts_ns = "UTS_NS";
 
 /* Deprecated symbols */
 const char * const config_element_perf;
@@ -1013,6 +1020,27 @@ int get_context_type(xmlChar *context_type)
 	} else if (!strcmp((char *) context_type,
 		config_event_context_migratable)) {
 		ret = LTTNG_EVENT_CONTEXT_MIGRATABLE;
+	} else if (!strcmp((char *) context_type,
+		config_event_context_cgroup_ns)) {
+		ret = LTTNG_EVENT_CONTEXT_CGROUP_NS;
+	} else if (!strcmp((char *) context_type,
+		config_event_context_ipc_ns)) {
+		ret = LTTNG_EVENT_CONTEXT_IPC_NS;
+	} else if (!strcmp((char *) context_type,
+		config_event_context_mnt_ns)) {
+		ret = LTTNG_EVENT_CONTEXT_MNT_NS;
+	} else if (!strcmp((char *) context_type,
+		config_event_context_net_ns)) {
+		ret = LTTNG_EVENT_CONTEXT_NET_NS;
+	} else if (!strcmp((char *) context_type,
+		config_event_context_pid_ns)) {
+		ret = LTTNG_EVENT_CONTEXT_PID_NS;
+	} else if (!strcmp((char *) context_type,
+		config_event_context_user_ns)) {
+		ret = LTTNG_EVENT_CONTEXT_USER_NS;
+	} else if (!strcmp((char *) context_type,
+		config_event_context_uts_ns)) {
+		ret = LTTNG_EVENT_CONTEXT_UTS_NS;
 	} else {
 		goto error;
 	}
diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h
index 8d87539..a55baee 100644
--- a/src/common/lttng-kernel.h
+++ b/src/common/lttng-kernel.h
@@ -58,6 +58,13 @@ enum lttng_kernel_context_type {
 	LTTNG_KERNEL_CONTEXT_PREEMPTIBLE    = 13,
 	LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14,
 	LTTNG_KERNEL_CONTEXT_MIGRATABLE     = 15,
+	LTTNG_KERNEL_CONTEXT_CGROUP_NS      = 16,
+	LTTNG_KERNEL_CONTEXT_IPC_NS         = 17,
+	LTTNG_KERNEL_CONTEXT_MNT_NS         = 18,
+	LTTNG_KERNEL_CONTEXT_NET_NS         = 19,
+	LTTNG_KERNEL_CONTEXT_PID_NS         = 20,
+	LTTNG_KERNEL_CONTEXT_USER_NS        = 21,
+	LTTNG_KERNEL_CONTEXT_UTS_NS         = 22,
 };
 
 /* Perf counter attributes */
-- 
2.7.4



More information about the lttng-dev mailing list