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(struct lttng_snapshot_output
*output
);
43 /* Return maximum size of a snapshot. */
44 uint64_t lttng_snapshot_output_get_maxsize(struct lttng_snapshot_output
*output
);
45 /* Return snapshot name. */
46 const char *lttng_snapshot_output_get_name(struct lttng_snapshot_output
*output
);
47 /* Return snapshot control URL in a text format. */
48 const char *lttng_snapshot_output_get_ctrl_url(struct lttng_snapshot_output
*output
);
49 /* Return snapshot data URL in a text format. */
50 const char *lttng_snapshot_output_get_data_url(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
);
68 /* Set the control URL. Local and remote URL are supported. */
69 int lttng_snapshot_output_set_ctrl_url(const char *url
,
70 struct lttng_snapshot_output
*output
);
71 /* Set the data URL. Local and remote URL are supported. */
72 int lttng_snapshot_output_set_data_url(const char *url
,
73 struct lttng_snapshot_output
*output
);
76 * Add an output object to a session identified by name.
78 * Return 0 on success or else a negative LTTNG_ERR code.
80 int lttng_snapshot_add_output(const char *session_name
,
81 struct lttng_snapshot_output
*output
);
84 * Delete an output object to a session identified by name.
86 * Return 0 on success or else a negative LTTNG_ERR code.
88 int lttng_snapshot_del_output(const char *session_name
,
89 struct lttng_snapshot_output
*output
);
92 * List all snapshot output(s) of a session identified by name. The output list
93 * object is populated and can be iterated over with the get_next call below.
95 * Return 0 on success or else a negative LTTNG_ERR code and the list pointer
98 int lttng_snapshot_list_output(const char *session_name
,
99 struct lttng_snapshot_output_list
**list
);
102 * Return the next available snapshot output object in the given list. A list
103 * output command MUST have been done before.
105 * Return the next object on success or else NULL indicating the end of the
108 struct lttng_snapshot_output
*lttng_snapshot_output_list_get_next(
109 struct lttng_snapshot_output_list
*list
);
112 * Free an output list object.
114 void lttng_snapshot_output_list_destroy(struct lttng_snapshot_output_list
*list
);
117 * Snapshot a trace for the given session.
119 * The output object can be NULL but an add output MUST be done prior to this
120 * call. If it's not NULL, it will be used to snapshot a trace.
122 * The wait parameter is ignored for now. The snapshot record command will
123 * ALWAYS wait for the snapshot to complete before returning meaning the
124 * snapshot has been written on disk or streamed over the network to a relayd.
126 * Return 0 on success or else a negative LTTNG_ERR value.
128 int lttng_snapshot_record(const char *session_name
,
129 struct lttng_snapshot_output
*output
, int wait
);
135 #endif /* LTTNG_SNAPSHOT_H */