Commit | Line | Data |
---|---|---|
da3c9ec1 | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> |
da3c9ec1 | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
da3c9ec1 | 5 | * |
da3c9ec1 DG |
6 | */ |
7 | ||
8 | #ifndef LTTNG_SNAPSHOT_H | |
9 | #define LTTNG_SNAPSHOT_H | |
10 | ||
11 | #include <limits.h> | |
12 | #include <stdint.h> | |
13 | #include <sys/types.h> | |
14 | ||
15 | #ifdef __cplusplus | |
16 | extern "C" { | |
17 | #endif | |
18 | ||
19 | /* | |
20 | * Snapshot output object is opaque to the user. Use the helper functions below | |
21 | * to use them. | |
22 | */ | |
23 | struct lttng_snapshot_output; | |
24 | struct lttng_snapshot_output_list; | |
25 | ||
26 | /* | |
27 | * Return an newly allocated snapshot output object or NULL on error. | |
28 | */ | |
29 | struct lttng_snapshot_output *lttng_snapshot_output_create(void); | |
30 | ||
31 | /* | |
32 | * Free a given snapshot output object. | |
33 | */ | |
34 | void lttng_snapshot_output_destroy(struct lttng_snapshot_output *output); | |
35 | ||
36 | /* | |
37 | * Snapshot output getter family functions. They all return the value present | |
38 | * in the object. | |
39 | */ | |
40 | ||
41 | /* Return snapshot ID. */ | |
1831ae68 | 42 | uint32_t lttng_snapshot_output_get_id(const struct lttng_snapshot_output *output); |
da3c9ec1 | 43 | /* Return maximum size of a snapshot. */ |
1831ae68 | 44 | uint64_t lttng_snapshot_output_get_maxsize(const struct lttng_snapshot_output *output); |
da3c9ec1 | 45 | /* Return snapshot name. */ |
1831ae68 | 46 | const char *lttng_snapshot_output_get_name(const struct lttng_snapshot_output *output); |
da3c9ec1 | 47 | /* Return snapshot control URL in a text format. */ |
1831ae68 | 48 | const char *lttng_snapshot_output_get_ctrl_url(const struct lttng_snapshot_output *output); |
da3c9ec1 | 49 | /* Return snapshot data URL in a text format. */ |
1831ae68 | 50 | const char *lttng_snapshot_output_get_data_url(const struct lttng_snapshot_output *output); |
da3c9ec1 DG |
51 | |
52 | /* | |
53 | * Snapshot output setter family functions. | |
54 | * | |
eef7781f | 55 | * For every set* call, 0 is returned on success or else -LTTNG_ERR_INVALID is |
da3c9ec1 DG |
56 | * returned indicating that at least one given parameter is invalid. |
57 | */ | |
58 | ||
59 | /* Set a custom ID. */ | |
60 | int lttng_snapshot_output_set_id(uint32_t id, | |
61 | struct lttng_snapshot_output *output); | |
62 | /* Set the maximum size. */ | |
63 | int lttng_snapshot_output_set_size(uint64_t size, | |
64 | struct lttng_snapshot_output *output); | |
65 | /* Set the snapshot name. */ | |
66 | int lttng_snapshot_output_set_name(const char *name, | |
67 | struct lttng_snapshot_output *output); | |
1831ae68 FD |
68 | |
69 | /* | |
70 | * Set the output destination to be a path on the local filesystem. | |
71 | * | |
72 | * The path must be absolute. It can optionally begin with `file://`. | |
73 | */ | |
74 | int lttng_snapshot_output_set_local_path(const char *path, | |
75 | struct lttng_snapshot_output *output); | |
76 | ||
77 | /* | |
78 | * Set the output destination to be the network from a combined control/data | |
79 | * URL. | |
80 | * | |
81 | * `url` must start with `net://` or `net6://`. | |
82 | */ | |
83 | int lttng_snapshot_output_set_network_url(const char *url, | |
84 | struct lttng_snapshot_output *output); | |
85 | ||
86 | /* | |
87 | * Set the output destination to be the network using separate URLs for control | |
88 | * and data. | |
89 | * | |
90 | * `ctrl_url` and `data_url` must start with `tcp://` or `tcp6://`. | |
91 | */ | |
92 | int lttng_snapshot_output_set_network_urls( | |
93 | const char *ctrl_url, const char *data_url, | |
94 | struct lttng_snapshot_output *output); | |
95 | ||
96 | // Deprecated? | |
97 | ||
da3c9ec1 DG |
98 | /* Set the control URL. Local and remote URL are supported. */ |
99 | int lttng_snapshot_output_set_ctrl_url(const char *url, | |
100 | struct lttng_snapshot_output *output); | |
101 | /* Set the data URL. Local and remote URL are supported. */ | |
102 | int lttng_snapshot_output_set_data_url(const char *url, | |
103 | struct lttng_snapshot_output *output); | |
104 | ||
105 | /* | |
106 | * Add an output object to a session identified by name. | |
107 | * | |
108 | * Return 0 on success or else a negative LTTNG_ERR code. | |
109 | */ | |
110 | int lttng_snapshot_add_output(const char *session_name, | |
111 | struct lttng_snapshot_output *output); | |
112 | ||
113 | /* | |
114 | * Delete an output object to a session identified by name. | |
115 | * | |
116 | * Return 0 on success or else a negative LTTNG_ERR code. | |
117 | */ | |
118 | int lttng_snapshot_del_output(const char *session_name, | |
119 | struct lttng_snapshot_output *output); | |
120 | ||
121 | /* | |
122 | * List all snapshot output(s) of a session identified by name. The output list | |
123 | * object is populated and can be iterated over with the get_next call below. | |
124 | * | |
125 | * Return 0 on success or else a negative LTTNG_ERR code and the list pointer | |
126 | * is untouched. | |
127 | */ | |
128 | int lttng_snapshot_list_output(const char *session_name, | |
129 | struct lttng_snapshot_output_list **list); | |
130 | ||
131 | /* | |
132 | * Return the next available snapshot output object in the given list. A list | |
133 | * output command MUST have been done before. | |
134 | * | |
135 | * Return the next object on success or else NULL indicating the end of the | |
136 | * list. | |
137 | */ | |
138 | struct lttng_snapshot_output *lttng_snapshot_output_list_get_next( | |
139 | struct lttng_snapshot_output_list *list); | |
140 | ||
141 | /* | |
142 | * Free an output list object. | |
143 | */ | |
144 | void lttng_snapshot_output_list_destroy(struct lttng_snapshot_output_list *list); | |
145 | ||
146 | /* | |
147 | * Snapshot a trace for the given session. | |
148 | * | |
149 | * The output object can be NULL but an add output MUST be done prior to this | |
150 | * call. If it's not NULL, it will be used to snapshot a trace. | |
151 | * | |
152 | * The wait parameter is ignored for now. The snapshot record command will | |
153 | * ALWAYS wait for the snapshot to complete before returning meaning the | |
154 | * snapshot has been written on disk or streamed over the network to a relayd. | |
155 | * | |
156 | * Return 0 on success or else a negative LTTNG_ERR value. | |
157 | */ | |
158 | int lttng_snapshot_record(const char *session_name, | |
159 | struct lttng_snapshot_output *output, int wait); | |
160 | ||
161 | #ifdef __cplusplus | |
162 | } | |
163 | #endif | |
164 | ||
165 | #endif /* LTTNG_SNAPSHOT_H */ |