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