docs: Add supported versions and fix-backport policy
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-commands.h
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef NOTIFICATION_THREAD_COMMANDS_H
9 #define NOTIFICATION_THREAD_COMMANDS_H
10
11 #include <lttng/domain.h>
12 #include <lttng/lttng-error.h>
13 #include <urcu/rculfhash.h>
14 #include "notification-thread.h"
15 #include "notification-thread-internal.h"
16 #include "notification-thread-events.h"
17 #include <common/waiter.h>
18 #include <stdbool.h>
19
20 struct notification_thread_data;
21 struct lttng_trigger;
22
23 enum notification_thread_command_type {
24 NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER,
25 NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER,
26 NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL,
27 NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL,
28 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
29 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
30 NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
31 NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
32 NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
33 NOTIFICATION_COMMAND_TYPE_QUIT,
34 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
35 NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
36 };
37
38 struct notification_thread_command {
39 struct cds_list_head cmd_list_node;
40
41 enum notification_thread_command_type type;
42 union {
43 /* Register trigger. */
44 struct {
45 struct lttng_trigger *trigger;
46 bool is_trigger_anonymous;
47 } register_trigger;
48 /* Unregister trigger. */
49 struct {
50 const struct lttng_trigger *trigger;
51 } unregister_trigger;
52 /* Add channel. */
53 struct {
54 struct {
55 const char *name;
56 uid_t uid;
57 gid_t gid;
58 } session;
59 struct {
60 const char *name;
61 enum lttng_domain_type domain;
62 uint64_t key;
63 uint64_t capacity;
64 } channel;
65 } add_channel;
66 /* Remove channel. */
67 struct {
68 uint64_t key;
69 enum lttng_domain_type domain;
70 } remove_channel;
71 struct {
72 const char *session_name;
73 uid_t uid;
74 gid_t gid;
75 uint64_t trace_archive_chunk_id;
76 /* Weak reference. */
77 struct lttng_trace_archive_location *location;
78 } session_rotation;
79 /* Add/Remove tracer event source fd. */
80 struct {
81 int tracer_event_source_fd;
82 enum lttng_domain_type domain;
83 } tracer_event_source;
84 /* List triggers. */
85 struct {
86 /* Credentials of the requesting user. */
87 uid_t uid;
88 } list_triggers;
89 /* Client communication update. */
90 struct {
91 notification_client_id id;
92 enum client_transmission_status status;
93 } client_communication_update;
94
95 struct {
96 const struct lttng_trigger *trigger;
97 } get_trigger;
98
99 } parameters;
100
101 union {
102 struct {
103 struct lttng_triggers *triggers;
104 } list_triggers;
105 struct {
106 struct lttng_trigger *trigger;
107 } get_trigger;
108 } reply;
109 /* lttng_waiter on which to wait for command reply (optional). */
110 struct lttng_waiter reply_waiter;
111 enum lttng_error_code reply_code;
112 bool is_async;
113 };
114
115 enum lttng_error_code notification_thread_command_register_trigger(
116 struct notification_thread_handle *handle,
117 struct lttng_trigger *trigger,
118 bool is_anonymous_trigger);
119
120 enum lttng_error_code notification_thread_command_unregister_trigger(
121 struct notification_thread_handle *handle,
122 const struct lttng_trigger *trigger);
123
124 enum lttng_error_code notification_thread_command_add_channel(
125 struct notification_thread_handle *handle,
126 char *session_name, uid_t session_uid, gid_t session_gid,
127 char *channel_name, uint64_t key,
128 enum lttng_domain_type domain, uint64_t capacity);
129
130 enum lttng_error_code notification_thread_command_remove_channel(
131 struct notification_thread_handle *handle,
132 uint64_t key, enum lttng_domain_type domain);
133
134 enum lttng_error_code notification_thread_command_session_rotation_ongoing(
135 struct notification_thread_handle *handle,
136 const char *session_name, uid_t session_uid, gid_t session_gid,
137 uint64_t trace_archive_chunk_id);
138
139 /* Ownership of location is transferred. */
140 enum lttng_error_code notification_thread_command_session_rotation_completed(
141 struct notification_thread_handle *handle,
142 const char *session_name, uid_t session_uid, gid_t session_gid,
143 uint64_t trace_archive_chunk_id,
144 struct lttng_trace_archive_location *location);
145
146 /*
147 * Return the set of triggers visible to a given client.
148 *
149 * The trigger objects contained in the set are the actual trigger instances
150 * used by the notification subsystem (i.e. not a copy). Given that the command
151 * is only used to serialize the triggers, this is fine: the properties that
152 * are serialized are immutable over the lifetime of the triggers.
153 *
154 * Moreover, the lifetime of the trigger instances is protected through
155 * reference counting (references are held by the trigger set).
156 *
157 * The caller has the exclusive ownership of the returned trigger set.
158 */
159 enum lttng_error_code notification_thread_command_list_triggers(
160 struct notification_thread_handle *handle,
161 uid_t client_uid,
162 struct lttng_triggers **triggers);
163
164 /*
165 * The ownership of trigger_event_application_pipe is _not_ transferred to
166 * the notification thread.
167 */
168 enum lttng_error_code notification_thread_command_add_tracer_event_source(
169 struct notification_thread_handle *handle,
170 int tracer_event_source_fd,
171 enum lttng_domain_type domain);
172
173 enum lttng_error_code notification_thread_command_remove_tracer_event_source(
174 struct notification_thread_handle *handle,
175 int tracer_event_source_fd);
176
177 void notification_thread_command_quit(
178 struct notification_thread_handle *handle);
179
180 enum lttng_error_code notification_thread_command_get_trigger(
181 struct notification_thread_handle *handle,
182 const struct lttng_trigger *trigger,
183 struct lttng_trigger **real_trigger);
184
185 #endif /* NOTIFICATION_THREAD_COMMANDS_H */
This page took 0.032057 seconds and 4 git commands to generate.