2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #ifndef NOTIFICATION_THREAD_COMMANDS_H
9 #define NOTIFICATION_THREAD_COMMANDS_H
11 #include "notification-thread-events.hpp"
12 #include "notification-thread-internal.hpp"
13 #include "notification-thread.hpp"
15 #include <common/waiter.hpp>
17 #include <lttng/domain.h>
18 #include <lttng/lttng-error.h>
21 #include <urcu/rculfhash.h>
23 struct notification_thread_data;
26 enum notification_thread_command_type {
27 NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER,
28 NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER,
29 NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL,
30 NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL,
31 NOTIFICATION_COMMAND_TYPE_ADD_SESSION,
32 NOTIFICATION_COMMAND_TYPE_REMOVE_SESSION,
33 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
34 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
35 NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
36 NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
37 NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
38 NOTIFICATION_COMMAND_TYPE_QUIT,
39 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
40 NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
43 struct notification_thread_command {
44 struct cds_list_head cmd_list_node;
46 enum notification_thread_command_type type;
48 /* Register trigger. */
50 struct lttng_trigger *trigger;
51 bool is_trigger_anonymous;
53 /* Unregister trigger. */
55 const struct lttng_trigger *trigger;
60 const char *session_name;
75 enum lttng_domain_type domain;
83 enum lttng_domain_type domain;
87 uint64_t trace_archive_chunk_id;
89 struct lttng_trace_archive_location *location;
91 /* Add/Remove tracer event source fd. */
93 int tracer_event_source_fd;
94 enum lttng_domain_type domain;
95 } tracer_event_source;
98 /* Credentials of the requesting user. */
101 /* Client communication update. */
103 notification_client_id id;
104 enum client_transmission_status status;
105 } client_communication_update;
108 const struct lttng_trigger *trigger;
115 struct lttng_triggers *triggers;
118 struct lttng_trigger *trigger;
121 /* lttng_waiter on which to wait for command reply (optional). */
122 struct lttng_waiter reply_waiter;
123 enum lttng_error_code reply_code;
127 enum lttng_error_code
128 notification_thread_command_register_trigger(struct notification_thread_handle *handle,
129 struct lttng_trigger *trigger,
130 bool is_anonymous_trigger);
132 enum lttng_error_code
133 notification_thread_command_unregister_trigger(struct notification_thread_handle *handle,
134 const struct lttng_trigger *trigger);
136 enum lttng_error_code
137 notification_thread_command_add_session(struct notification_thread_handle *handle,
139 const char *session_name,
143 enum lttng_error_code
144 notification_thread_command_remove_session(struct notification_thread_handle *handle,
145 uint64_t session_id);
147 enum lttng_error_code
148 notification_thread_command_add_channel(struct notification_thread_handle *handle,
152 enum lttng_domain_type domain,
155 enum lttng_error_code notification_thread_command_remove_channel(
156 struct notification_thread_handle *handle, uint64_t key, enum lttng_domain_type domain);
158 enum lttng_error_code
159 notification_thread_command_session_rotation_ongoing(struct notification_thread_handle *handle,
161 uint64_t trace_archive_chunk_id);
163 /* Ownership of location is transferred. */
164 enum lttng_error_code notification_thread_command_session_rotation_completed(
165 struct notification_thread_handle *handle,
167 uint64_t trace_archive_chunk_id,
168 struct lttng_trace_archive_location *location);
171 * Return the set of triggers visible to a given client.
173 * The trigger objects contained in the set are the actual trigger instances
174 * used by the notification subsystem (i.e. not a copy). Given that the command
175 * is only used to serialize the triggers, this is fine: the properties that
176 * are serialized are immutable over the lifetime of the triggers.
178 * Moreover, the lifetime of the trigger instances is protected through
179 * reference counting (references are held by the trigger set).
181 * The caller has the exclusive ownership of the returned trigger set.
183 enum lttng_error_code
184 notification_thread_command_list_triggers(struct notification_thread_handle *handle,
186 struct lttng_triggers **triggers);
189 * The ownership of trigger_event_application_pipe is _not_ transferred to
190 * the notification thread.
192 enum lttng_error_code
193 notification_thread_command_add_tracer_event_source(struct notification_thread_handle *handle,
194 int tracer_event_source_fd,
195 enum lttng_domain_type domain);
197 enum lttng_error_code
198 notification_thread_command_remove_tracer_event_source(struct notification_thread_handle *handle,
199 int tracer_event_source_fd);
201 void notification_thread_command_quit(struct notification_thread_handle *handle);
203 enum lttng_error_code
204 notification_thread_command_get_trigger(struct notification_thread_handle *handle,
205 const struct lttng_trigger *trigger,
206 struct lttng_trigger **real_trigger);
208 #endif /* NOTIFICATION_THREAD_COMMANDS_H */