9bdf775a97c8e36dc7fe3846ec01189e6120e95c
[lttng-tools.git] / include / lttng / snapshot.h
1 /*
2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
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. */
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);
51
52 /*
53 * Snapshot output setter family functions.
54 *
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.
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);
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);
74
75 /*
76 * Add an output object to a session identified by name.
77 *
78 * Return 0 on success or else a negative LTTNG_ERR code.
79 */
80 int lttng_snapshot_add_output(const char *session_name,
81 struct lttng_snapshot_output *output);
82
83 /*
84 * Delete an output object to a session identified by name.
85 *
86 * Return 0 on success or else a negative LTTNG_ERR code.
87 */
88 int lttng_snapshot_del_output(const char *session_name,
89 struct lttng_snapshot_output *output);
90
91 /*
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.
94 *
95 * Return 0 on success or else a negative LTTNG_ERR code and the list pointer
96 * is untouched.
97 */
98 int lttng_snapshot_list_output(const char *session_name,
99 struct lttng_snapshot_output_list **list);
100
101 /*
102 * Return the next available snapshot output object in the given list. A list
103 * output command MUST have been done before.
104 *
105 * Return the next object on success or else NULL indicating the end of the
106 * list.
107 */
108 struct lttng_snapshot_output *lttng_snapshot_output_list_get_next(
109 struct lttng_snapshot_output_list *list);
110
111 /*
112 * Free an output list object.
113 */
114 void lttng_snapshot_output_list_destroy(struct lttng_snapshot_output_list *list);
115
116 /*
117 * Snapshot a trace for the given session.
118 *
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.
121 *
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.
125 *
126 * Return 0 on success or else a negative LTTNG_ERR value.
127 */
128 int lttng_snapshot_record(const char *session_name,
129 struct lttng_snapshot_output *output, int wait);
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* LTTNG_SNAPSHOT_H */
This page took 0.032212 seconds and 4 git commands to generate.