SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-commands.h
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
11#include <lttng/domain.h>
12#include <lttng/lttng-error.h>
13#include <urcu/rculfhash.h>
14#include "notification-thread.h"
8abe313a
JG
15#include "notification-thread-internal.h"
16#include "notification-thread-events.h"
8ada111f 17#include <common/waiter.h>
d3a684ee 18#include <stdbool.h>
ab0ee2ca
JG
19
20struct notification_thread_data;
21struct lttng_trigger;
22
23enum 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,
731c1b12
JG
28 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
29 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
d3a684ee
JR
30 NOTIFICATION_COMMAND_TYPE_ADD_APPLICATION,
31 NOTIFICATION_COMMAND_TYPE_REMOVE_APPLICATION,
32 NOTIFICATION_COMMAND_TYPE_GET_TOKENS,
33 NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
ab0ee2ca 34 NOTIFICATION_COMMAND_TYPE_QUIT,
d3a684ee 35 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
ab0ee2ca
JG
36};
37
ab0ee2ca
JG
38struct notification_thread_command {
39 struct cds_list_head cmd_list_node;
40
41 enum notification_thread_command_type type;
42 union {
43 /* Register/Unregister trigger. */
44 struct lttng_trigger *trigger;
45 /* Add channel. */
8abe313a
JG
46 struct {
47 struct {
48 const char *name;
49 uid_t uid;
50 gid_t gid;
51 } session;
52 struct {
53 const char *name;
54 enum lttng_domain_type domain;
55 uint64_t key;
56 uint64_t capacity;
57 } channel;
58 } add_channel;
ab0ee2ca
JG
59 /* Remove channel. */
60 struct {
61 uint64_t key;
62 enum lttng_domain_type domain;
63 } remove_channel;
731c1b12
JG
64 struct {
65 const char *session_name;
66 uid_t uid;
67 gid_t gid;
68 uint64_t trace_archive_chunk_id;
69 struct lttng_trace_archive_location *location;
70 } session_rotation;
d3a684ee
JR
71 /* Add/Remove application */
72 struct {
73 int read_side_trigger_event_application_pipe;
74 } application;
75 /* List triggers */
76 struct {
77 /* Credential */
78 uid_t uid;
79 gid_t gid;
80 } list_triggers;
81 /* Client communication update. */
82 struct {
83 notification_client_id id;
84 enum client_transmission_status status;
85 } client_communication_update;
86
ab0ee2ca
JG
87 } parameters;
88
d3a684ee
JR
89 union {
90 struct {
91 struct lttng_triggers *triggers;
92 } get_tokens;
93 struct {
94 struct lttng_triggers *triggers;
95 } list_triggers;
96 } reply;
97
8ada111f
JG
98 /* lttng_waiter on which to wait for command reply (optional). */
99 struct lttng_waiter reply_waiter;
ab0ee2ca 100 enum lttng_error_code reply_code;
d3a684ee 101 bool is_async;
ab0ee2ca
JG
102};
103
104enum lttng_error_code notification_thread_command_register_trigger(
105 struct notification_thread_handle *handle,
106 struct lttng_trigger *trigger);
107
108enum lttng_error_code notification_thread_command_unregister_trigger(
109 struct notification_thread_handle *handle,
110 struct lttng_trigger *trigger);
111
112enum lttng_error_code notification_thread_command_add_channel(
113 struct notification_thread_handle *handle,
731c1b12 114 char *session_name, uid_t session_uid, gid_t session_gid,
ab0ee2ca
JG
115 char *channel_name, uint64_t key,
116 enum lttng_domain_type domain, uint64_t capacity);
117
118enum lttng_error_code notification_thread_command_remove_channel(
119 struct notification_thread_handle *handle,
120 uint64_t key, enum lttng_domain_type domain);
121
731c1b12
JG
122enum lttng_error_code notification_thread_command_session_rotation_ongoing(
123 struct notification_thread_handle *handle,
124 const char *session_name, uid_t session_uid, gid_t session_gid,
125 uint64_t trace_archive_chunk_id);
126
127/* Ownership of location is transferred. */
128enum lttng_error_code notification_thread_command_session_rotation_completed(
129 struct notification_thread_handle *handle,
130 const char *session_name, uid_t session_uid, gid_t session_gid,
131 uint64_t trace_archive_chunk_id,
132 struct lttng_trace_archive_location *location);
133
d3a684ee
JR
134enum lttng_error_code notification_thread_command_add_application(
135 struct notification_thread_handle *handle,
136 struct lttng_pipe *trigger_event_application_pipe);
137
138enum lttng_error_code notification_thread_command_remove_application(
139 struct notification_thread_handle *handle,
140 struct lttng_pipe *trigger_event_application_pipe);
141
142/* Must hold the notification_trigger_tokens_ht_lock to protect against
143 * insertion removal of triggers TODO: is it the case even with refcounting? */
144/* todo find a better way....*/
145enum lttng_error_code notification_thread_command_get_tokens(
146 struct notification_thread_handle *handle,
147 struct lttng_triggers **triggers);
148
149/* TODO: for now we borrow with no refcount the trigger. THIS IS DANGEROUS */
150enum lttng_error_code notification_thread_command_list_triggers(
151 struct notification_thread_handle *handle,
152 uid_t uid,
153 gid_t gid,
154 struct lttng_triggers **triggers);
155
ab0ee2ca
JG
156void notification_thread_command_quit(
157 struct notification_thread_handle *handle);
158
159#endif /* NOTIFICATION_THREAD_COMMANDS_H */
This page took 0.048354 seconds and 5 git commands to generate.