0f76ee5a60f520bccb4c6b699b1be89a396e35fc
[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 };
36
37 struct notification_thread_command {
38 struct cds_list_head cmd_list_node;
39
40 enum notification_thread_command_type type;
41 union {
42 /* Register/Unregister trigger. */
43 struct lttng_trigger *trigger;
44 /* Add channel. */
45 struct {
46 struct {
47 const char *name;
48 uid_t uid;
49 gid_t gid;
50 } session;
51 struct {
52 const char *name;
53 enum lttng_domain_type domain;
54 uint64_t key;
55 uint64_t capacity;
56 } channel;
57 } add_channel;
58 /* Remove channel. */
59 struct {
60 uint64_t key;
61 enum lttng_domain_type domain;
62 } remove_channel;
63 struct {
64 const char *session_name;
65 uid_t uid;
66 gid_t gid;
67 uint64_t trace_archive_chunk_id;
68 struct lttng_trace_archive_location *location;
69 } session_rotation;
70 /* Add/Remove tracer event source fd. */
71 struct {
72 int tracer_event_source_fd;
73 enum lttng_domain_type domain;
74 } tracer_event_source;
75 /* List triggers. */
76 struct {
77 /* Credentials of the requesting user. */
78 uid_t uid;
79 } list_triggers;
80 /* Client communication update. */
81 struct {
82 notification_client_id id;
83 enum client_transmission_status status;
84 } client_communication_update;
85
86 } parameters;
87
88 union {
89 struct {
90 struct lttng_triggers *triggers;
91 } list_triggers;
92 } reply;
93 /* lttng_waiter on which to wait for command reply (optional). */
94 struct lttng_waiter reply_waiter;
95 enum lttng_error_code reply_code;
96 bool is_async;
97 };
98
99 enum lttng_error_code notification_thread_command_register_trigger(
100 struct notification_thread_handle *handle,
101 struct lttng_trigger *trigger);
102
103 enum lttng_error_code notification_thread_command_unregister_trigger(
104 struct notification_thread_handle *handle,
105 struct lttng_trigger *trigger);
106
107 enum lttng_error_code notification_thread_command_add_channel(
108 struct notification_thread_handle *handle,
109 char *session_name, uid_t session_uid, gid_t session_gid,
110 char *channel_name, uint64_t key,
111 enum lttng_domain_type domain, uint64_t capacity);
112
113 enum lttng_error_code notification_thread_command_remove_channel(
114 struct notification_thread_handle *handle,
115 uint64_t key, enum lttng_domain_type domain);
116
117 enum lttng_error_code notification_thread_command_session_rotation_ongoing(
118 struct notification_thread_handle *handle,
119 const char *session_name, uid_t session_uid, gid_t session_gid,
120 uint64_t trace_archive_chunk_id);
121
122 /* Ownership of location is transferred. */
123 enum lttng_error_code notification_thread_command_session_rotation_completed(
124 struct notification_thread_handle *handle,
125 const char *session_name, uid_t session_uid, gid_t session_gid,
126 uint64_t trace_archive_chunk_id,
127 struct lttng_trace_archive_location *location);
128
129 /*
130 * Return the set of triggers visible to a given client.
131 *
132 * The trigger objects contained in the set are the actual trigger instances
133 * used by the notification subsystem (i.e. not a copy). Given that the command
134 * is only used to serialize the triggers, this is fine: the properties that
135 * are serialized are immutable over the lifetime of the triggers.
136 *
137 * Moreover, the lifetime of the trigger instances is protected through
138 * reference counting (references are held by the trigger set).
139 *
140 * The caller has the exclusive ownership of the returned trigger set.
141 */
142 enum lttng_error_code notification_thread_command_list_triggers(
143 struct notification_thread_handle *handle,
144 uid_t client_uid,
145 struct lttng_triggers **triggers);
146
147 /*
148 * The ownership of trigger_event_application_pipe is _not_ transferred to
149 * the notification thread.
150 */
151 enum lttng_error_code notification_thread_command_add_tracer_event_source(
152 struct notification_thread_handle *handle,
153 int tracer_event_source_fd,
154 enum lttng_domain_type domain);
155
156 enum lttng_error_code notification_thread_command_remove_tracer_event_source(
157 struct notification_thread_handle *handle,
158 int tracer_event_source_fd);
159
160 void notification_thread_command_quit(
161 struct notification_thread_handle *handle);
162
163 #endif /* NOTIFICATION_THREAD_COMMANDS_H */
This page took 0.046445 seconds and 3 git commands to generate.