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 <lttng/domain.h>
12 #include <lttng/lttng-error.h>
13 #include <urcu/rculfhash.h>
14 #include "notification-thread.hpp"
15 #include "notification-thread-internal.hpp"
16 #include "notification-thread-events.hpp"
17 #include <common/waiter.hpp>
20 struct notification_thread_data;
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_ADD_SESSION,
29 NOTIFICATION_COMMAND_TYPE_REMOVE_SESSION,
30 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
31 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
32 NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
33 NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
34 NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
35 NOTIFICATION_COMMAND_TYPE_QUIT,
36 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
37 NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
40 struct notification_thread_command {
41 struct cds_list_head cmd_list_node;
43 enum notification_thread_command_type type;
45 /* Register trigger. */
47 struct lttng_trigger *trigger;
48 bool is_trigger_anonymous;
50 /* Unregister trigger. */
52 const struct lttng_trigger *trigger;
57 const char *session_name;
72 enum lttng_domain_type domain;
80 enum lttng_domain_type domain;
84 uint64_t trace_archive_chunk_id;
86 struct lttng_trace_archive_location *location;
88 /* Add/Remove tracer event source fd. */
90 int tracer_event_source_fd;
91 enum lttng_domain_type domain;
92 } tracer_event_source;
95 /* Credentials of the requesting user. */
98 /* Client communication update. */
100 notification_client_id id;
101 enum client_transmission_status status;
102 } client_communication_update;
105 const struct lttng_trigger *trigger;
112 struct lttng_triggers *triggers;
115 struct lttng_trigger *trigger;
118 /* lttng_waiter on which to wait for command reply (optional). */
119 struct lttng_waiter reply_waiter;
120 enum lttng_error_code reply_code;
124 enum lttng_error_code notification_thread_command_register_trigger(
125 struct notification_thread_handle *handle,
126 struct lttng_trigger *trigger,
127 bool is_anonymous_trigger);
129 enum lttng_error_code notification_thread_command_unregister_trigger(
130 struct notification_thread_handle *handle,
131 const struct lttng_trigger *trigger);
133 enum lttng_error_code notification_thread_command_add_session(
134 struct notification_thread_handle *handle,
136 const char *session_name,
140 enum lttng_error_code notification_thread_command_remove_session(
141 struct notification_thread_handle *handle,
142 uint64_t session_id);
144 enum lttng_error_code notification_thread_command_add_channel(
145 struct notification_thread_handle *handle,
147 char *channel_name, uint64_t key,
148 enum lttng_domain_type domain, uint64_t capacity);
150 enum lttng_error_code notification_thread_command_remove_channel(
151 struct notification_thread_handle *handle,
152 uint64_t key, enum lttng_domain_type domain);
154 enum lttng_error_code notification_thread_command_session_rotation_ongoing(
155 struct notification_thread_handle *handle,
157 uint64_t trace_archive_chunk_id);
159 /* Ownership of location is transferred. */
160 enum lttng_error_code notification_thread_command_session_rotation_completed(
161 struct notification_thread_handle *handle,
163 uint64_t trace_archive_chunk_id,
164 struct lttng_trace_archive_location *location);
167 * Return the set of triggers visible to a given client.
169 * The trigger objects contained in the set are the actual trigger instances
170 * used by the notification subsystem (i.e. not a copy). Given that the command
171 * is only used to serialize the triggers, this is fine: the properties that
172 * are serialized are immutable over the lifetime of the triggers.
174 * Moreover, the lifetime of the trigger instances is protected through
175 * reference counting (references are held by the trigger set).
177 * The caller has the exclusive ownership of the returned trigger set.
179 enum lttng_error_code notification_thread_command_list_triggers(
180 struct notification_thread_handle *handle,
182 struct lttng_triggers **triggers);
185 * The ownership of trigger_event_application_pipe is _not_ transferred to
186 * the notification thread.
188 enum lttng_error_code notification_thread_command_add_tracer_event_source(
189 struct notification_thread_handle *handle,
190 int tracer_event_source_fd,
191 enum lttng_domain_type domain);
193 enum lttng_error_code notification_thread_command_remove_tracer_event_source(
194 struct notification_thread_handle *handle,
195 int tracer_event_source_fd);
197 void notification_thread_command_quit(
198 struct notification_thread_handle *handle);
200 enum lttng_error_code notification_thread_command_get_trigger(
201 struct notification_thread_handle *handle,
202 const struct lttng_trigger *trigger,
203 struct lttng_trigger **real_trigger);
205 #endif /* NOTIFICATION_THREAD_COMMANDS_H */