2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_SNAPSHOT_H
9 #define LTTNG_SNAPSHOT_H
13 #include <sys/types.h>
20 * Snapshot output object is opaque to the user. Use the helper functions below
23 struct lttng_snapshot_output
;
24 struct lttng_snapshot_output_list
;
27 * Return an newly allocated snapshot output object or NULL on error.
29 struct lttng_snapshot_output
*lttng_snapshot_output_create(void);
32 * Free a given snapshot output object.
34 void lttng_snapshot_output_destroy(struct lttng_snapshot_output
*output
);
37 * Snapshot output getter family functions. They all return the value present
41 /* Return snapshot ID. */
42 uint32_t lttng_snapshot_output_get_id(const struct lttng_snapshot_output
*output
);
43 /* Return maximum size of a snapshot. */
44 uint64_t lttng_snapshot_output_get_maxsize(const struct lttng_snapshot_output
*output
);
45 /* Return snapshot name. */
46 const char *lttng_snapshot_output_get_name(const struct lttng_snapshot_output
*output
);
47 /* Return snapshot control URL in a text format. */
48 const char *lttng_snapshot_output_get_ctrl_url(const struct lttng_snapshot_output
*output
);
49 /* Return snapshot data URL in a text format. */
50 const char *lttng_snapshot_output_get_data_url(const struct lttng_snapshot_output
*output
);
53 * Snapshot output setter family functions.
55 * For every set* call, 0 is returned on success or else -LTTNG_ERR_INVALID is
56 * returned indicating that at least one given parameter is invalid.
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
);
70 * Set the output destination to be a path on the local filesystem.
72 * The path must be absolute. It can optionally begin with `file://`.
74 int lttng_snapshot_output_set_local_path(const char *path
,
75 struct lttng_snapshot_output
*output
);
78 * Set the output destination to be the network from a combined control/data
81 * `url` must start with `net://` or `net6://`.
83 int lttng_snapshot_output_set_network_url(const char *url
,
84 struct lttng_snapshot_output
*output
);
87 * Set the output destination to be the network using separate URLs for control
90 * `ctrl_url` and `data_url` must start with `tcp://` or `tcp6://`.
92 int lttng_snapshot_output_set_network_urls(
93 const char *ctrl_url
, const char *data_url
,
94 struct lttng_snapshot_output
*output
);
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
);
106 * Add an output object to a session identified by name.
108 * Return 0 on success or else a negative LTTNG_ERR code.
110 int lttng_snapshot_add_output(const char *session_name
,
111 struct lttng_snapshot_output
*output
);
114 * Delete an output object to a session identified by name.
116 * Return 0 on success or else a negative LTTNG_ERR code.
118 int lttng_snapshot_del_output(const char *session_name
,
119 struct lttng_snapshot_output
*output
);
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.
125 * Return 0 on success or else a negative LTTNG_ERR code and the list pointer
128 int lttng_snapshot_list_output(const char *session_name
,
129 struct lttng_snapshot_output_list
**list
);
132 * Return the next available snapshot output object in the given list. A list
133 * output command MUST have been done before.
135 * Return the next object on success or else NULL indicating the end of the
138 struct lttng_snapshot_output
*lttng_snapshot_output_list_get_next(
139 struct lttng_snapshot_output_list
*list
);
142 * Free an output list object.
144 void lttng_snapshot_output_list_destroy(struct lttng_snapshot_output_list
*list
);
147 * Snapshot a trace for the given session.
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.
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.
156 * Return 0 on success or else a negative LTTNG_ERR value.
158 int lttng_snapshot_record(const char *session_name
,
159 struct lttng_snapshot_output
*output
, int wait
);
165 #endif /* LTTNG_SNAPSHOT_H */