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>
1831ae68 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,
1831ae68
FD
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
JG
34 NOTIFICATION_COMMAND_TYPE_QUIT,
35};
36
ab0ee2ca
JG
37struct 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. */
8abe313a
JG
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;
ab0ee2ca
JG
58 /* Remove channel. */
59 struct {
60 uint64_t key;
61 enum lttng_domain_type domain;
62 } remove_channel;
731c1b12
JG
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;
1831ae68
FD
70 /* Add/Remove application */
71 struct {
72 int read_side_trigger_event_application_pipe;
73 } application;
74 /* List triggers */
75 struct {
76 /* Credential */
77 uid_t uid;
78 gid_t gid;
79 } list_triggers;
80
ab0ee2ca
JG
81 } parameters;
82
1831ae68
FD
83 union {
84 struct {
85 struct lttng_triggers *triggers;
86 } get_tokens;
87 struct {
88 struct lttng_triggers *triggers;
89 } list_triggers;
90 } reply;
91
8ada111f
JG
92 /* lttng_waiter on which to wait for command reply (optional). */
93 struct lttng_waiter reply_waiter;
ab0ee2ca 94 enum lttng_error_code reply_code;
1831ae68 95 bool is_async;
ab0ee2ca
JG
96};
97
98enum lttng_error_code notification_thread_command_register_trigger(
99 struct notification_thread_handle *handle,
100 struct lttng_trigger *trigger);
101
102enum lttng_error_code notification_thread_command_unregister_trigger(
103 struct notification_thread_handle *handle,
104 struct lttng_trigger *trigger);
105
106enum lttng_error_code notification_thread_command_add_channel(
107 struct notification_thread_handle *handle,
731c1b12 108 char *session_name, uid_t session_uid, gid_t session_gid,
ab0ee2ca
JG
109 char *channel_name, uint64_t key,
110 enum lttng_domain_type domain, uint64_t capacity);
111
112enum lttng_error_code notification_thread_command_remove_channel(
113 struct notification_thread_handle *handle,
114 uint64_t key, enum lttng_domain_type domain);
115
731c1b12
JG
116enum lttng_error_code notification_thread_command_session_rotation_ongoing(
117 struct notification_thread_handle *handle,
118 const char *session_name, uid_t session_uid, gid_t session_gid,
119 uint64_t trace_archive_chunk_id);
120
121/* Ownership of location is transferred. */
122enum lttng_error_code notification_thread_command_session_rotation_completed(
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 struct lttng_trace_archive_location *location);
127
1831ae68
FD
128enum lttng_error_code notification_thread_command_add_application(
129 struct notification_thread_handle *handle,
130 struct lttng_pipe *trigger_event_application_pipe);
131
132enum lttng_error_code notification_thread_command_remove_application(
133 struct notification_thread_handle *handle,
134 struct lttng_pipe *trigger_event_application_pipe);
135
136/* Must hold the notification_trigger_tokens_ht_lock to protect against
137 * insertion removal of triggers TODO: is it the case even with refcounting? */
138/* todo find a better way....*/
139enum lttng_error_code notification_thread_command_get_tokens(
140 struct notification_thread_handle *handle,
141 struct lttng_triggers **triggers);
142
143/* TODO: for now we borrow with no refcount the trigger. THIS IS DANGEROUS */
144enum lttng_error_code notification_thread_command_list_triggers(
145 struct notification_thread_handle *handle,
146 uid_t uid,
147 gid_t gid,
148 struct lttng_triggers **triggers);
149
ab0ee2ca
JG
150void notification_thread_command_quit(
151 struct notification_thread_handle *handle);
152
153#endif /* NOTIFICATION_THREAD_COMMANDS_H */
This page took 0.069571 seconds and 5 git commands to generate.