]>
Commit | Line | Data |
---|---|---|
cc73685d | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
250b1eec | 2 | |
9be53773 SH |
3 | #ifndef __LXC_CONTAINER_H |
4 | #define __LXC_CONTAINER_H | |
d38dd64a | 5 | |
1160ce89 CB |
6 | #include "config.h" |
7 | ||
72d0e1cb | 8 | #include <malloc.h> |
95ee490b | 9 | #include <semaphore.h> |
72d0e1cb | 10 | #include <stdbool.h> |
d659597e | 11 | #include <stdint.h> |
d38dd64a | 12 | #include <stdlib.h> |
72d0e1cb | 13 | |
f2363e38 ÇO |
14 | #include <lxc/attach_options.h> |
15 | ||
579e783e AM |
16 | #ifdef __cplusplus |
17 | extern "C" { | |
18 | #endif | |
19 | ||
953e611c | 20 | #define LXC_CLONE_KEEPNAME (1 << 0) /*!< Do not edit the rootfs to change the hostname */ |
619256b5 ÇO |
21 | #define LXC_CLONE_KEEPMACADDR (1 << 1) /*!< Do not change the MAC address on network interfaces */ |
22 | #define LXC_CLONE_SNAPSHOT (1 << 2) /*!< Snapshot the original filesystem(s) */ | |
0a83cbbb SH |
23 | #define LXC_CLONE_KEEPBDEVTYPE (1 << 3) /*!< Use the same bdev type */ |
24 | #define LXC_CLONE_MAYBE_SNAPSHOT (1 << 4) /*!< Snapshot only if bdev supports it, else copy */ | |
25 | #define LXC_CLONE_MAXFLAGS (1 << 5) /*!< Number of \c LXC_CLONE_* flags */ | |
754076f5 | 26 | #define LXC_CLONE_ALLOW_RUNNING (1 << 6) /*!< allow snapshot creation even if source container is running */ |
953e611c JH |
27 | #define LXC_CREATE_QUIET (1 << 0) /*!< Redirect \c stdin to \c /dev/zero and \c stdout and \c stderr to \c /dev/null */ |
28 | #define LXC_CREATE_MAXFLAGS (1 << 1) /*!< Number of \c LXC_CREATE* flags */ | |
29df56cd | 29 | #define LXC_MOUNT_API_V1 1 |
dc23c1c8 | 30 | |
1897e3bc SH |
31 | struct bdev_specs; |
32 | ||
f5dd1d53 SH |
33 | struct lxc_snapshot; |
34 | ||
95ee490b SG |
35 | struct lxc_lock; |
36 | ||
aef3d51e TA |
37 | struct migrate_opts; |
38 | ||
191d43cc CB |
39 | struct lxc_console_log; |
40 | ||
29df56cd LT |
41 | struct lxc_mount { |
42 | int version; | |
43 | }; | |
44 | ||
953e611c JH |
45 | /*! |
46 | * An LXC container. | |
e2ae7f6d SH |
47 | * |
48 | * Note that changing the order of struct members is an API change, as callers | |
49 | * will end up having the wrong offset when calling a function. So when making | |
50 | * changes, whenever possible stick to simply appending new members. | |
953e611c | 51 | */ |
72d0e1cb | 52 | struct lxc_container { |
1a0e70ac | 53 | /* private fields */ |
953e611c JH |
54 | /*! |
55 | * \private | |
56 | * Name of container. | |
57 | */ | |
72d0e1cb | 58 | char *name; |
953e611c JH |
59 | |
60 | /*! | |
61 | * \private | |
62 | * Full path to configuration file. | |
63 | */ | |
72d0e1cb | 64 | char *configfile; |
953e611c | 65 | |
72cf75fa QH |
66 | /*! |
67 | * \private | |
68 | * File to store pid. | |
69 | */ | |
70 | char *pidfile; | |
71 | ||
953e611c JH |
72 | /*! |
73 | * \private | |
74 | * Container semaphore lock. | |
75 | */ | |
df271a59 | 76 | struct lxc_lock *slock; |
953e611c JH |
77 | |
78 | /*! | |
79 | * \private | |
80 | * Container private lock. | |
81 | */ | |
df271a59 | 82 | struct lxc_lock *privlock; |
953e611c JH |
83 | |
84 | /*! | |
85 | * \private | |
86 | * Number of references to this container. | |
87 | * \note protected by privlock. | |
88 | */ | |
89 | int numthreads; | |
90 | ||
91 | /*! | |
92 | * \private | |
93 | * Container configuration. | |
94 | * | |
50e3e83d | 95 | * \internal TODO: do we want the whole lxc_handler? |
953e611c JH |
96 | */ |
97 | struct lxc_conf *lxc_conf; | |
72d0e1cb | 98 | |
1a0e70ac | 99 | /* public fields */ |
953e611c | 100 | /*! Human-readable string representing last error */ |
72d0e1cb | 101 | char *error_string; |
953e611c JH |
102 | |
103 | /*! Last error number */ | |
72d0e1cb | 104 | int error_num; |
953e611c JH |
105 | |
106 | /*! Whether container wishes to be daemonized */ | |
540f932a | 107 | bool daemonize; |
72d0e1cb | 108 | |
953e611c | 109 | /*! Full path to configuration file */ |
2a59a681 SH |
110 | char *config_path; |
111 | ||
953e611c JH |
112 | /*! |
113 | * \brief Determine if \c /var/lib/lxc/$name/config exists. | |
114 | * | |
115 | * \param c Container. | |
116 | * | |
117 | * \return \c true if container is defined, else \c false. | |
118 | */ | |
119 | bool (*is_defined)(struct lxc_container *c); | |
120 | ||
121 | /*! | |
122 | * \brief Determine state of container. | |
123 | * | |
124 | * \param c Container. | |
125 | * | |
126 | * \return Static upper-case string representing state of container. | |
127 | * | |
128 | * \note Returned string must not be freed. | |
129 | */ | |
72d0e1cb | 130 | const char *(*state)(struct lxc_container *c); |
953e611c JH |
131 | |
132 | /*! | |
133 | * \brief Determine if container is running. | |
134 | * | |
135 | * \param c Container. | |
136 | * | |
137 | * \return \c true on success, else \c false. | |
138 | */ | |
139 | bool (*is_running)(struct lxc_container *c); | |
140 | ||
141 | /*! | |
142 | * \brief Freeze running container. | |
143 | * | |
144 | * \param c Container. | |
145 | * | |
146 | * \return \c true on success, else \c false. | |
147 | */ | |
72d0e1cb | 148 | bool (*freeze)(struct lxc_container *c); |
953e611c JH |
149 | |
150 | /*! | |
151 | * \brief Thaw a frozen container. | |
152 | * | |
153 | * \param c Container. | |
154 | * | |
155 | * \return \c true on success, else \c false. | |
156 | */ | |
72d0e1cb | 157 | bool (*unfreeze)(struct lxc_container *c); |
953e611c JH |
158 | |
159 | /*! | |
160 | * \brief Determine process ID of the containers init process. | |
161 | * | |
162 | * \param c Container. | |
f7f1ba77 | 163 | * |
953e611c JH |
164 | * \return pid of init process as seen from outside the |
165 | * container. | |
166 | */ | |
72d0e1cb | 167 | pid_t (*init_pid)(struct lxc_container *c); |
953e611c JH |
168 | |
169 | /*! | |
170 | * \brief Load the specified configuration for the container. | |
171 | * | |
172 | * \param c Container. | |
173 | * \param alt_file Full path to alternate configuration file, or | |
174 | * \c NULL to use the default configuration file. | |
175 | * | |
176 | * \return \c true on success, else \c false. | |
177 | */ | |
12a50cc6 | 178 | bool (*load_config)(struct lxc_container *c, const char *alt_file); |
953e611c JH |
179 | |
180 | /*! | |
181 | * \brief Start the container. | |
182 | * | |
183 | * \param c Container. | |
184 | * \param useinit Use lxcinit rather than \c /sbin/init. | |
185 | * \param argv Array of arguments to pass to init. | |
186 | * | |
187 | * \return \c true on success, else \c false. | |
188 | */ | |
12a50cc6 | 189 | bool (*start)(struct lxc_container *c, int useinit, char * const argv[]); |
953e611c JH |
190 | |
191 | /*! | |
192 | * \brief Start the container (list variant). | |
193 | * | |
194 | * \param c Container. | |
195 | * \param useinit Use lxcinit rather than \c /sbin/init. | |
196 | * \param ... Command-line to pass to init (must end in \c NULL). | |
197 | * | |
198 | * \return \c true on success, else \c false. | |
199 | * | |
200 | * \note Identical to \ref start except that that the init | |
201 | * arguments are specified via a list rather than an array of | |
202 | * pointers. | |
203 | */ | |
72d0e1cb | 204 | bool (*startl)(struct lxc_container *c, int useinit, ...); |
953e611c JH |
205 | |
206 | /*! | |
207 | * \brief Stop the container. | |
208 | * | |
209 | * \param c Container. | |
210 | * | |
211 | * \return \c true on success, else \c false. | |
212 | */ | |
72d0e1cb | 213 | bool (*stop)(struct lxc_container *c); |
953e611c JH |
214 | |
215 | /*! | |
289cdc73 | 216 | * \brief Change whether the container wants to run disconnected |
953e611c JH |
217 | * from the terminal. |
218 | * | |
219 | * \param c Container. | |
c9d845b5 | 220 | * \param state Value for the daemonize bit (0 or 1). |
953e611c | 221 | * |
289cdc73 | 222 | * \return \c true on success, else \c false. |
953e611c | 223 | */ |
540f932a | 224 | bool (*want_daemonize)(struct lxc_container *c, bool state); |
953e611c JH |
225 | |
226 | /*! | |
289cdc73 | 227 | * \brief Change whether the container wishes all file descriptors |
46abf219 RJ |
228 | * to be closed on startup. The LISTEN_FDS environment variable |
229 | * can be set to keep inherited file descriptors open. | |
953e611c JH |
230 | * |
231 | * \param c Container. | |
c9d845b5 | 232 | * \param state Value for the close_all_fds bit (0 or 1). |
953e611c | 233 | * |
289cdc73 | 234 | * \return \c true on success, else \c false. |
953e611c | 235 | */ |
540f932a | 236 | bool (*want_close_all_fds)(struct lxc_container *c, bool state); |
953e611c JH |
237 | |
238 | /*! | |
239 | * \brief Return current config file name. | |
240 | * | |
241 | * \param c Container. | |
242 | * | |
243 | * \return config file name, or \c NULL on error. | |
244 | * | |
245 | * \note The result is allocated, so the caller must free the result. | |
246 | */ | |
72d0e1cb | 247 | char *(*config_file_name)(struct lxc_container *c); |
953e611c JH |
248 | |
249 | /*! | |
250 | * \brief Wait for container to reach a particular state. | |
251 | * | |
252 | * \param c Container. | |
253 | * \param state State to wait for. | |
254 | * \param timeout Timeout in seconds. | |
255 | * | |
256 | * \return \c true if state reached within \p timeout, else \c false. | |
257 | * | |
258 | * \note A \p timeout of \c -1 means wait forever. A \p timeout | |
259 | * of \c 0 means do not wait. | |
260 | */ | |
12a50cc6 | 261 | bool (*wait)(struct lxc_container *c, const char *state, int timeout); |
953e611c JH |
262 | |
263 | /*! | |
264 | * \brief Set a key/value configuration option. | |
265 | * | |
266 | * \param c Container. | |
267 | * \param key Name of option to set. | |
268 | * \param value Value of \p name to set. | |
269 | * | |
270 | * \return \c true on success, else \c false. | |
271 | */ | |
12a50cc6 | 272 | bool (*set_config_item)(struct lxc_container *c, const char *key, const char *value); |
953e611c JH |
273 | |
274 | /*! | |
275 | * \brief Delete the container. | |
276 | * | |
277 | * \param c Container. | |
278 | * | |
279 | * \return \c true on success, else \c false. | |
280 | * | |
281 | * \note Container must be stopped and have no dependent snapshots. | |
282 | */ | |
72d0e1cb | 283 | bool (*destroy)(struct lxc_container *c); |
953e611c JH |
284 | |
285 | /*! | |
056da80e | 286 | * \brief Save configuration to a file. |
953e611c JH |
287 | * |
288 | * \param c Container. | |
289 | * \param alt_file Full path to file to save configuration in. | |
290 | * | |
291 | * \return \c true on success, else \c false. | |
292 | */ | |
12a50cc6 | 293 | bool (*save_config)(struct lxc_container *c, const char *alt_file); |
953e611c JH |
294 | |
295 | /*! | |
296 | * \brief Create a container. | |
297 | * | |
298 | * \param c Container (with lxcpath, name and a starting | |
299 | * configuration set). | |
300 | * \param t Template to execute to instantiate the root | |
301 | * filesystem and adjust the configuration. | |
302 | * \param bdevtype Backing store type to use (if \c NULL, \c dir will be used). | |
303 | * \param specs Additional parameters for the backing store (for | |
304 | * example LVM volume group to use). | |
305 | * \param flags \c LXC_CREATE_* options (currently only \ref | |
306 | * LXC_CREATE_QUIET is supported). | |
307 | * \param argv Arguments to pass to the template, terminated by \c NULL (if no | |
308 | * arguments are required, just pass \c NULL). | |
309 | * | |
310 | * \return \c true on success, else \c false. | |
311 | */ | |
1897e3bc | 312 | bool (*create)(struct lxc_container *c, const char *t, const char *bdevtype, |
dc23c1c8 | 313 | struct bdev_specs *specs, int flags, char *const argv[]); |
953e611c JH |
314 | |
315 | /*! | |
316 | * \brief Create a container (list variant). | |
317 | * | |
318 | * \param c Container (with lxcpath, name and a starting | |
319 | * configuration set). | |
320 | * \param t Template to execute to instantiate the root | |
321 | * filesystem and adjust the configuration. | |
322 | * \param bdevtype Backing store type to use (if \c NULL, \c dir will be used). | |
323 | * \param specs Additional parameters for the backing store (for | |
324 | * example LVM volume group to use). | |
325 | * \param flags \c LXC_CREATE_* options (currently only \ref | |
326 | * LXC_CREATE_QUIET is supported). | |
327 | * \param ... Command-line to pass to init (must end in \c NULL). | |
328 | * | |
329 | * \return \c true on success, else \c false. | |
330 | * | |
331 | * \note Identical to \ref create except that the template | |
332 | * arguments are specified as a list rather than an array of | |
333 | * pointers. | |
334 | */ | |
1897e3bc | 335 | bool (*createl)(struct lxc_container *c, const char *t, const char *bdevtype, |
dc23c1c8 | 336 | struct bdev_specs *specs, int flags, ...); |
953e611c | 337 | |
06e5650e ÇO |
338 | /*! |
339 | * \brief Rename a container | |
340 | * | |
341 | * \param c Container. | |
342 | * \param newname New name to be used for the container. | |
343 | * | |
344 | * \return \c true on success, else \c false. | |
345 | */ | |
346 | bool (*rename)(struct lxc_container *c, const char *newname); | |
347 | ||
953e611c JH |
348 | /*! |
349 | * \brief Request the container reboot by sending it \c SIGINT. | |
350 | * | |
351 | * \param c Container. | |
352 | * | |
353 | * \return \c true if reboot request successful, else \c false. | |
354 | */ | |
3e625e2d | 355 | bool (*reboot)(struct lxc_container *c); |
953e611c JH |
356 | |
357 | /*! | |
358 | * \brief Request the container shutdown by sending it \c | |
359 | * SIGPWR. | |
360 | * | |
361 | * \param c Container. | |
0464b881 SG |
362 | * \param timeout Seconds to wait before returning false. |
363 | * (-1 to wait forever, 0 to avoid waiting). | |
953e611c | 364 | * |
0464b881 | 365 | * \return \c true if the container was shutdown successfully, else \c false. |
953e611c | 366 | */ |
72d0e1cb | 367 | bool (*shutdown)(struct lxc_container *c, int timeout); |
953e611c JH |
368 | |
369 | /*! | |
370 | * \brief Completely clear the containers in-memory configuration. | |
371 | * | |
372 | * \param c Container. | |
373 | */ | |
4df7f012 | 374 | void (*clear_config)(struct lxc_container *c); |
953e611c JH |
375 | |
376 | /*! | |
377 | * \brief Clear a configuration item. | |
378 | * | |
379 | * \param c Container. | |
380 | * \param key Name of option to clear. | |
381 | * | |
382 | * \return \c true on success, else \c false. | |
383 | * | |
384 | * \note Analog of \ref set_config_item. | |
385 | */ | |
12a50cc6 | 386 | bool (*clear_config_item)(struct lxc_container *c, const char *key); |
953e611c JH |
387 | |
388 | /*! | |
389 | * \brief Retrieve the value of a config item. | |
390 | * | |
391 | * \param c Container. | |
392 | * \param key Name of option to get. | |
393 | * \param[out] retv Caller-allocated buffer to write value of \p key | |
394 | * into (or \c NULL to determine length of value). | |
395 | * \param inlen Length of \p retv (may be zero). | |
396 | * | |
397 | * \return Length of config items value, or < 0 on error. | |
398 | * | |
399 | * \note The caller can (and should) determine how large a buffer to allocate for | |
400 | * \p retv by initially passing its value as \c NULL and considering the return value. | |
401 | * This function can then be called again passing a newly-allocated suitably-sized buffer. | |
402 | * \note If \p retv is NULL, \p inlen is ignored. | |
13a4215b | 403 | * \note If \p inlen is smaller than required, nothing will be written to \p retv and still return |
404 | * the length of config item value. | |
953e611c | 405 | */ |
12a50cc6 | 406 | int (*get_config_item)(struct lxc_container *c, const char *key, char *retv, int inlen); |
953e611c | 407 | |
8ac18377 ÇO |
408 | |
409 | /*! | |
410 | * \brief Retrieve the value of a config item from running container. | |
411 | * | |
412 | * \param c Container. | |
413 | * \param key Name of option to get. | |
414 | * | |
415 | * \return the item or NULL on error. | |
416 | * | |
417 | * \note Returned string must be freed by the caller. | |
418 | */ | |
419 | char* (*get_running_config_item)(struct lxc_container *c, const char *key); | |
420 | ||
953e611c JH |
421 | /*! |
422 | * \brief Retrieve a list of config item keys given a key | |
423 | * prefix. | |
424 | * | |
425 | * \param c Container. | |
426 | * \param key Name of option to get. | |
427 | * \param[out] retv Caller-allocated buffer to write list of keys to | |
428 | * (or \c NULL to determine overall length of keys list). | |
429 | * \param inlen Length of \p retv (may be zero). | |
430 | * | |
431 | * \return Length of keys list, or < 0 on error. | |
432 | * | |
433 | * \note The list values written to \p retv are separated by | |
434 | * a newline character ('\\n'). | |
435 | * \note The caller can (and should) determine how large a buffer to allocate for | |
436 | * \p retv by initially passing its value as \c NULL and considering the return value. | |
437 | * This function can then be called again passing a newly-allocated suitably-sized buffer. | |
438 | * \note If \p retv is NULL, \p inlen is ignored. | |
439 | * \note If \p inlen is smaller than required, the value written | |
440 | * to \p retv will be truncated. | |
441 | */ | |
12a50cc6 | 442 | int (*get_keys)(struct lxc_container *c, const char *key, char *retv, int inlen); |
953e611c JH |
443 | |
444 | /*! | |
445 | * \brief Obtain a list of network interfaces. | |
446 | * \param c Container. | |
447 | * | |
448 | * \return Newly-allocated array of network interfaces, or \c | |
449 | * NULL on error. | |
450 | * | |
451 | * \note The returned array is allocated, so the caller must free it. | |
452 | * \note The returned array is terminated with a \c NULL entry. | |
453 | */ | |
799f29ab | 454 | char** (*get_interfaces)(struct lxc_container *c); |
953e611c JH |
455 | |
456 | /*! | |
457 | * \brief Determine the list of container IP addresses. | |
458 | * | |
459 | * \param c Container. | |
460 | * \param interface Network interface name to consider. | |
461 | * \param family Network family (for example "inet", "inet6"). | |
462 | * \param scope IPv6 scope id (ignored if \p family is not "inet6"). | |
463 | * | |
464 | * \return Newly-allocated array of network interfaces, or \c | |
465 | * NULL on error. | |
466 | * | |
467 | * \note The returned array is allocated, so the caller must free it. | |
468 | * \note The returned array is terminated with a \c NULL entry. | |
469 | */ | |
f0ca2726 | 470 | char** (*get_ips)(struct lxc_container *c, const char* interface, const char* family, int scope); |
953e611c JH |
471 | |
472 | /*! | |
473 | * \brief Retrieve the specified cgroup subsystem value for the container. | |
474 | * | |
475 | * \param c Container. | |
476 | * \param subsys cgroup subsystem to retrieve. | |
477 | * \param[out] retv Caller-allocated buffer to write value of \p | |
478 | * subsys into (or \c NULL to determine length of value). | |
479 | * \param inlen length of \p retv (may be zero). | |
480 | * | |
481 | * \return Length of \p subsys value, or < 0 on error. | |
482 | * | |
483 | * \note If \p retv is \c NULL, \p inlen is ignored. | |
484 | * \note If \p inlen is smaller than required, the value written | |
485 | * to \p retv will be truncated. | |
794dd120 SH |
486 | */ |
487 | int (*get_cgroup_item)(struct lxc_container *c, const char *subsys, char *retv, int inlen); | |
953e611c JH |
488 | |
489 | /*! | |
490 | * \brief Set the specified cgroup subsystem value for the container. | |
491 | * | |
492 | * \param c Container. | |
493 | * \param subsys cgroup subsystem to consider. | |
494 | * \param value Value to set for \p subsys. | |
495 | * | |
496 | * \return \c true on success, else \c false. | |
497 | */ | |
794dd120 | 498 | bool (*set_cgroup_item)(struct lxc_container *c, const char *subsys, const char *value); |
72d0e1cb | 499 | |
953e611c JH |
500 | /*! |
501 | * \brief Determine full path to the containers configuration file. | |
502 | * Each container can have a custom configuration path. However | |
503 | * by default it will be set to either the \c LXCPATH configure | |
504 | * variable, or the lxcpath value in the \c LXC_GLOBAL_CONF configuration | |
505 | * file (i.e. \c /etc/lxc/lxc.conf). | |
506 | * The value for a specific container can be changed using | |
507 | * \ref set_config_path. There is no other way to specify this in general at the moment. | |
508 | * | |
509 | * \param c Container. | |
510 | * | |
511 | * \return Static string representing full path to configuration | |
512 | * file. | |
513 | * | |
514 | * \note Returned string must not be freed. | |
2a59a681 SH |
515 | */ |
516 | const char *(*get_config_path)(struct lxc_container *c); | |
953e611c JH |
517 | |
518 | /*! | |
519 | * \brief Set the full path to the containers configuration | |
520 | * file. | |
521 | * | |
522 | * \param c Container. | |
523 | * \param path Full path to configuration file. | |
524 | * | |
525 | * \return \c true on success, else \c false. | |
526 | */ | |
2a59a681 SH |
527 | bool (*set_config_path)(struct lxc_container *c, const char *path); |
528 | ||
953e611c JH |
529 | /*! |
530 | * \brief Copy a stopped container. | |
531 | * | |
532 | * \param c Original container. | |
533 | * \param newname New name for the container. If \c NULL, the same | |
534 | * name is used and a new lxcpath MUST be specified. | |
535 | * \param lxcpath lxcpath in which to create the new container. If | |
536 | * \c NULL, the original container's lxcpath will be used. | |
537 | * (XXX: should we use the default instead?) | |
538 | * \param flags Additional \c LXC_CLONE* flags to change the cloning behaviour: | |
539 | * - \ref LXC_CLONE_KEEPNAME | |
953e611c JH |
540 | * - \ref LXC_CLONE_KEEPMACADDR |
541 | * - \ref LXC_CLONE_SNAPSHOT | |
542 | * \param bdevtype Optionally force the cloned bdevtype to a specified plugin. | |
543 | * By default the original is used (subject to snapshot requirements). | |
544 | * \param bdevdata Information about how to create the new storage | |
545 | * (i.e. fstype and fsdata). | |
cf642e10 | 546 | * \param newsize In case of a block device backing store, an |
953e611c JH |
547 | * optional size. If \c 0, the original backing store's size will |
548 | * be used if possible. Note this only applies to the rootfs. For | |
549 | * any other filesystems, the original size will be duplicated. | |
550 | * \param hookargs Additional arguments to pass to the clone hook script. | |
551 | * | |
552 | * \return Newly-allocated copy of container \p c, or \p NULL on | |
553 | * error. | |
554 | * | |
555 | * \note If devtype was not specified, and \p flags contains \ref | |
556 | * LXC_CLONE_SNAPSHOT then use the native \p bdevtype if possible, | |
557 | * else use an overlayfs. | |
9be53773 SH |
558 | */ |
559 | struct lxc_container *(*clone)(struct lxc_container *c, const char *newname, | |
953e611c | 560 | const char *lxcpath, int flags, const char *bdevtype, |
d659597e | 561 | const char *bdevdata, uint64_t newsize, char **hookargs); |
9be53773 | 562 | |
953e611c JH |
563 | /*! |
564 | * \brief Allocate a console tty for the container. | |
0115f8fd | 565 | * |
953e611c JH |
566 | * \param c Container. |
567 | * \param[in,out] ttynum Terminal number to attempt to allocate, | |
568 | * or \c -1 to allocate the first available tty. | |
36a94ce8 | 569 | * \param[out] ptxfd File descriptor referring to the ptx side of the pty. |
0115f8fd | 570 | * |
953e611c JH |
571 | * \return tty file descriptor number on success, or \c -1 on |
572 | * failure. | |
573 | * | |
574 | * \note On successful return, \p ttynum will contain the tty number | |
575 | * that was allocated. | |
576 | * \note The returned file descriptor is used to keep the tty | |
577 | * allocated. The caller should call close(2) on the returned file | |
578 | * descriptor when no longer required so that it may be allocated | |
579 | * by another caller. | |
0115f8fd | 580 | */ |
36a94ce8 | 581 | int (*console_getfd)(struct lxc_container *c, int *ttynum, int *ptxfd); |
b5159817 | 582 | |
953e611c JH |
583 | /*! |
584 | * \brief Allocate and run a console tty. | |
585 | * | |
586 | * \param c Container. | |
587 | * \param ttynum Terminal number to attempt to allocate, \c -1 to | |
588 | * allocate the first available tty or \c 0 to allocate the | |
589 | * console. | |
590 | * \param stdinfd File descriptor to read input from. | |
591 | * \param stdoutfd File descriptor to write output to. | |
592 | * \param stderrfd File descriptor to write error output to. | |
593 | * \param escape The escape character (1 == 'a', 2 == 'b', ...). | |
b5159817 | 594 | * |
953e611c | 595 | * \return \c 0 on success, \c -1 on failure. |
b5159817 | 596 | * |
953e611c JH |
597 | * \note This function will not return until the console has been |
598 | * exited by the user. | |
b5159817 DE |
599 | */ |
600 | int (*console)(struct lxc_container *c, int ttynum, | |
953e611c | 601 | int stdinfd, int stdoutfd, int stderrfd, int escape); |
0115f8fd | 602 | |
953e611c JH |
603 | /*! |
604 | * \brief Create a sub-process attached to a container and run | |
605 | * a function inside it. | |
606 | * | |
607 | * \param c Container. | |
608 | * \param exec_function Function to run. | |
609 | * \param exec_payload Data to pass to \p exec_function. | |
610 | * \param options \ref lxc_attach_options_t. | |
611 | * \param[out] attached_process Process ID of process running inside | |
612 | * container \p c that is running \p exec_function. | |
613 | * | |
614 | * \return \c 0 on success, \c -1 on error. | |
615 | */ | |
616 | int (*attach)(struct lxc_container *c, lxc_attach_exec_t exec_function, | |
617 | void *exec_payload, lxc_attach_options_t *options, pid_t *attached_process); | |
a0e93eeb | 618 | |
953e611c JH |
619 | /*! |
620 | * \brief Run a program inside a container and wait for it to exit. | |
621 | * | |
622 | * \param c Container. | |
623 | * \param options See \ref attach options. | |
624 | * \param program Full path inside container of program to run. | |
625 | * \param argv Array of arguments to pass to \p program. | |
626 | * | |
627 | * \return \c waitpid(2) status of exited process that ran \p | |
628 | * program, or \c -1 on error. | |
629 | */ | |
a0e93eeb | 630 | int (*attach_run_wait)(struct lxc_container *c, lxc_attach_options_t *options, const char *program, const char * const argv[]); |
f5dd1d53 | 631 | |
953e611c JH |
632 | /*! |
633 | * \brief Run a program inside a container and wait for it to exit (list variant). | |
634 | * | |
635 | * \param c Container. | |
636 | * \param options See \ref attach options. | |
637 | * \param program Full path inside container of program to run. | |
638 | * \param ... Command-line to pass to \p program (must end in \c NULL). | |
639 | * | |
640 | * \return \c waitpid(2) status of exited process that ran \p | |
641 | * program, or \c -1 on error. | |
642 | */ | |
643 | int (*attach_run_waitl)(struct lxc_container *c, lxc_attach_options_t *options, const char *program, const char *arg, ...); | |
f5dd1d53 | 644 | |
953e611c JH |
645 | /*! |
646 | * \brief Create a container snapshot. | |
647 | * | |
648 | * Assuming default paths, snapshots will be created as | |
18aa217b | 649 | * \c /var/lib/lxc/\<c\>/snaps/snap\<n\> |
953e611c JH |
650 | * where \c \<c\> represents the container name and \c \<n\> |
651 | * represents the zero-based snapshot number. | |
652 | * | |
653 | * \param c Container. | |
654 | * \param commentfile Full path to file containing a description | |
655 | * of the snapshot. | |
656 | * | |
657 | * \return -1 on error, or zero-based snapshot number. | |
f5dd1d53 | 658 | * |
953e611c | 659 | * \note \p commentfile may be \c NULL but this is discouraged. |
f5dd1d53 | 660 | */ |
f0ca2726 | 661 | int (*snapshot)(struct lxc_container *c, const char *commentfile); |
f5dd1d53 | 662 | |
953e611c JH |
663 | /*! |
664 | * \brief Obtain a list of container snapshots. | |
665 | * | |
666 | * \param c Container. | |
667 | * \param[out] snapshots Dynamically-allocated Array of lxc_snapshot's. | |
f5dd1d53 | 668 | * |
953e611c | 669 | * \return Number of snapshots. |
f5dd1d53 | 670 | * |
953e611c JH |
671 | * \note The array returned in \p snapshots is allocated, so the caller must free it. |
672 | * \note To free an individual snapshot as returned in \p | |
673 | * snapshots, call the snapshots \c free function (see \c src/tests/snapshot.c for an example). | |
674 | */ | |
675 | int (*snapshot_list)(struct lxc_container *c, struct lxc_snapshot **snapshots); | |
676 | ||
677 | /*! | |
678 | * \brief Create a new container based on a snapshot. | |
f5dd1d53 | 679 | * |
953e611c JH |
680 | * The restored container will be a copy (not snapshot) of the snapshot, |
681 | * and restored in the lxcpath of the original container. | |
682 | * \param c Container. | |
683 | * \param snapname Name of snapshot. | |
684 | * \param newname Name to be used for the restored snapshot. | |
685 | * \return \c true on success, else \c false. | |
686 | * \warning If \p newname is the same as the current container | |
687 | * name, the container will be destroyed. However, this will | |
1f92162d | 688 | * fail if the snapshot is overlay-based, since the snapshots |
953e611c JH |
689 | * will pin the original container. |
690 | * \note As an example, if the container exists as \c /var/lib/lxc/c1, snapname might be \c 'snap0' | |
18aa217b | 691 | * (representing \c /var/lib/lxc/c1/snaps/snap0). If \p newname is \p c2, |
953e611c | 692 | * then \c snap0 will be copied to \c /var/lib/lxc/c2. |
f5dd1d53 | 693 | */ |
f0ca2726 | 694 | bool (*snapshot_restore)(struct lxc_container *c, const char *snapname, const char *newname); |
b494d2dd | 695 | |
953e611c JH |
696 | /*! |
697 | * \brief Destroy the specified snapshot. | |
771d96b3 | 698 | * |
953e611c JH |
699 | * \param c Container. |
700 | * \param snapname Name of snapshot. | |
701 | * | |
702 | * \return \c true on success, else \c false. | |
771d96b3 | 703 | */ |
f0ca2726 | 704 | bool (*snapshot_destroy)(struct lxc_container *c, const char *snapname); |
771d96b3 | 705 | |
953e611c JH |
706 | /*! |
707 | * \brief Determine if the caller may control the container. | |
708 | * | |
709 | * \param c Container. | |
710 | * | |
711 | * \return \c false if there is a control socket for the | |
712 | * container monitor and the caller may not access it, otherwise | |
713 | * returns \c true. | |
b494d2dd SH |
714 | */ |
715 | bool (*may_control)(struct lxc_container *c); | |
a9a0ed90 | 716 | |
953e611c JH |
717 | /*! |
718 | * \brief Add specified device to the container. | |
a9a0ed90 | 719 | * |
953e611c JH |
720 | * \param c Container. |
721 | * \param src_path Full path of the device. | |
722 | * \param dest_path Alternate path in the container (or \p NULL | |
723 | * to use \p src_path). | |
724 | * | |
725 | * \return \c true on success, else \c false. | |
a9a0ed90 | 726 | */ |
f0ca2726 | 727 | bool (*add_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path); |
953e611c JH |
728 | |
729 | /*! | |
730 | * \brief Remove specified device from the container. | |
a9a0ed90 | 731 | * |
953e611c JH |
732 | * \param c Container. |
733 | * \param src_path Full path of the device. | |
734 | * \param dest_path Alternate path in the container (or \p NULL | |
735 | * to use \p src_path). | |
736 | * | |
737 | * \return \c true on success, else \c false. | |
a9a0ed90 | 738 | */ |
f0ca2726 | 739 | bool (*remove_device_node)(struct lxc_container *c, const char *src_path, const char *dest_path); |
735f2c6e | 740 | |
d24095e4 SG |
741 | /* Post LXC-1.0 additions */ |
742 | ||
51d0854c DY |
743 | /*! |
744 | * \brief Add specified netdev to the container. | |
745 | * | |
746 | * \param c Container. | |
747 | * \param dev name of net device. | |
748 | * | |
749 | * \return \c true on success, else \c false. | |
750 | */ | |
751 | bool (*attach_interface)(struct lxc_container *c, const char *dev, const char *dst_dev); | |
752 | ||
753 | /*! | |
754 | * \brief Remove specified netdev from the container. | |
755 | * | |
756 | * \param c Container. | |
757 | * \param dev name of net device. | |
758 | * | |
759 | * \return \c true on success, else \c false. | |
760 | */ | |
761 | bool (*detach_interface)(struct lxc_container *c, const char *dev, const char *dst_dev); | |
735f2c6e TA |
762 | /*! |
763 | * \brief Checkpoint a container. | |
764 | * | |
765 | * \param c Container. | |
766 | * \param directory The directory to dump the container to. | |
767 | * \param stop Whether or not to stop the container after checkpointing. | |
768 | * \param verbose Enable criu's verbose logs. | |
769 | * | |
770 | * \return \c true on success, else \c false. | |
771 | * present at compile time). | |
772 | */ | |
773 | bool (*checkpoint)(struct lxc_container *c, char *directory, bool stop, bool verbose); | |
774 | ||
775 | /*! | |
776 | * \brief Restore a container from a checkpoint. | |
777 | * | |
778 | * \param c Container. | |
779 | * \param directory The directory to restore the container from. | |
780 | * \param verbose Enable criu's verbose logs. | |
781 | * | |
782 | * \return \c true on success, else \c false. | |
783 | * | |
784 | */ | |
785 | bool (*restore)(struct lxc_container *c, char *directory, bool verbose); | |
d24095e4 SG |
786 | |
787 | /*! | |
788 | * \brief Delete the container and all its snapshots. | |
789 | * | |
790 | * \param c Container. | |
791 | * | |
792 | * \return \c true on success, else \c false. | |
793 | * | |
794 | * \note Container must be stopped. | |
795 | */ | |
796 | bool (*destroy_with_snapshots)(struct lxc_container *c); | |
797 | ||
798 | /*! | |
799 | * \brief Destroy all the container's snapshot. | |
800 | * | |
801 | * \param c Container. | |
802 | * | |
803 | * \return \c true on success, else \c false. | |
804 | */ | |
805 | bool (*snapshot_destroy_all)(struct lxc_container *c); | |
806 | ||
807 | /* Post LXC-1.1 additions */ | |
aef3d51e TA |
808 | /*! |
809 | * \brief An API call to perform various migration operations | |
810 | * | |
c0125e79 | 811 | * \param cmd One of the MIGRATE_ constants. |
aef3d51e TA |
812 | * \param opts A migrate_opts struct filled with relevant options. |
813 | * \param size The size of the migrate_opts struct, i.e. sizeof(struct migrate_opts). | |
814 | * | |
815 | * \return \c 0 on success, nonzero on failure. | |
816 | */ | |
817 | int (*migrate)(struct lxc_container *c, unsigned int cmd, struct migrate_opts *opts, unsigned int size); | |
dcf33b94 | 818 | |
191d43cc CB |
819 | /*! |
820 | * \brief Query the console log of a container. | |
821 | * | |
822 | * \param c Container. | |
823 | * \param opts A lxc_console_log struct filled with relevant options. | |
824 | * | |
825 | * \return \c 0 on success, nonzero on failure. | |
826 | */ | |
827 | int (*console_log)(struct lxc_container *c, struct lxc_console_log *log); | |
d39b10eb CB |
828 | |
829 | /*! | |
830 | * \brief Request the container reboot by sending it \c SIGINT. | |
831 | * | |
832 | * \param c Container. | |
833 | * \param timeout Seconds to wait before returning false. | |
834 | * (-1 to wait forever, 0 to avoid waiting). | |
835 | * | |
836 | * \return \c true if the container was rebooted successfully, else \c false. | |
837 | */ | |
838 | bool (*reboot2)(struct lxc_container *c, int timeout); | |
29df56cd LT |
839 | |
840 | /*! | |
841 | * \brief Mount the host's path `source` onto the container's path `target`. | |
842 | */ | |
095b5c7d CB |
843 | int (*mount)(struct lxc_container *c, const char *source, |
844 | const char *target, const char *filesystemtype, | |
845 | unsigned long mountflags, const void *data, | |
846 | struct lxc_mount *mnt); | |
d83da817 LT |
847 | |
848 | /*! | |
849 | * \brief Unmount the container's path `target`. | |
850 | */ | |
851 | int (*umount)(struct lxc_container *c, const char *target, | |
095b5c7d | 852 | unsigned long mountflags, struct lxc_mount *mnt); |
cdb2a47f | 853 | |
890ecf08 CB |
854 | /*! |
855 | * \brief Retrieve a file descriptor for the container's seccomp filter. | |
856 | * | |
857 | * \param c Container | |
858 | * | |
859 | * \return file descriptor for container's seccomp filter | |
860 | */ | |
679289bf | 861 | int (*seccomp_notify_fd)(struct lxc_container *c); |
21405769 CB |
862 | |
863 | /*! | |
864 | * \brief Retrieve a file descriptor for the running container's seccomp filter. | |
865 | * | |
866 | * \param c Container | |
867 | * | |
868 | * \return file descriptor for the running container's seccomp filter | |
869 | */ | |
870 | int (*seccomp_notify_fd_active)(struct lxc_container *c); | |
fa3621ea CB |
871 | |
872 | /*! | |
873 | * \brief Retrieve a pidfd for the container's init process. | |
874 | * | |
875 | * \param c Container. | |
876 | * | |
877 | * \return pidfd of init process of the container. | |
878 | */ | |
879 | int (*init_pidfd)(struct lxc_container *c); | |
f797f05e CB |
880 | |
881 | /*! | |
882 | * \brief Retrieve a mount fd for the container's devpts instance. | |
883 | * | |
884 | * \param c Container. | |
885 | * | |
886 | * \return Mount fd of the container's devpts instance. | |
887 | */ | |
888 | int (*devpts_fd)(struct lxc_container *c); | |
f5dd1d53 SH |
889 | }; |
890 | ||
953e611c JH |
891 | /*! |
892 | * \brief An LXC container snapshot. | |
893 | */ | |
f5dd1d53 | 894 | struct lxc_snapshot { |
953e611c JH |
895 | char *name; /*!< Name of snapshot */ |
896 | char *comment_pathname; /*!< Full path to snapshots comment file (may be \c NULL) */ | |
897 | char *timestamp; /*!< Time snapshot was created */ | |
898 | char *lxcpath; /*!< Full path to LXCPATH for snapshot */ | |
899 | ||
900 | /*! | |
901 | * \brief De-allocate the snapshot. | |
902 | * \param s snapshot. | |
903 | */ | |
904 | void (*free)(struct lxc_snapshot *s); | |
72d0e1cb SG |
905 | }; |
906 | ||
f49ad558 ÇO |
907 | |
908 | /*! | |
909 | * \brief Specifications for how to create a new backing store | |
910 | */ | |
911 | struct bdev_specs { | |
d028235d SG |
912 | char *fstype; /*!< Filesystem type */ |
913 | uint64_t fssize; /*!< Filesystem size in bytes */ | |
914 | struct { | |
915 | char *zfsroot; /*!< ZFS root path */ | |
916 | } zfs; | |
917 | struct { | |
918 | char *vg; /*!< LVM Volume Group name */ | |
919 | char *lv; /*!< LVM Logical Volume name */ | |
920 | char *thinpool; /*!< LVM thin pool to use, if any */ | |
921 | } lvm; | |
7ed52ec6 | 922 | char *dir; /*!< Directory path */ |
7da812df LB |
923 | struct { |
924 | char *rbdname; /*!< RBD image name */ | |
925 | char *rbdpool; /*!< Ceph pool name */ | |
926 | } rbd; | |
f49ad558 ÇO |
927 | }; |
928 | ||
aef3d51e TA |
929 | /*! |
930 | * \brief Commands for the migrate API call. | |
931 | */ | |
932 | enum { | |
933 | MIGRATE_PRE_DUMP, | |
934 | MIGRATE_DUMP, | |
935 | MIGRATE_RESTORE, | |
b5b12b9e | 936 | MIGRATE_FEATURE_CHECK, |
aef3d51e TA |
937 | }; |
938 | ||
b5b12b9e AR |
939 | /*! |
940 | * \brief Available feature checks. | |
941 | */ | |
942 | #define FEATURE_MEM_TRACK (1ULL << 0) | |
943 | #define FEATURE_LAZY_PAGES (1ULL << 1) | |
944 | ||
aef3d51e TA |
945 | /*! |
946 | * \brief Options for the migrate API call. | |
947 | */ | |
948 | struct migrate_opts { | |
949 | /* new members should be added at the end */ | |
950 | char *directory; | |
951 | bool verbose; | |
952 | ||
953 | bool stop; /* stop the container after dump? */ | |
954 | char *predump_dir; /* relative to directory above */ | |
74eb576c NE |
955 | char *pageserver_address; /* where should memory pages be send? */ |
956 | char *pageserver_port; | |
19d1509c TA |
957 | |
958 | /* This flag indicates whether or not the container's rootfs will have | |
959 | * the same inodes on checkpoint and restore. In the case of e.g. zfs | |
960 | * send or btrfs send, or an LVM snapshot, this will be true, but it | |
961 | * won't if e.g. you rsync the filesystems between two machines. | |
962 | */ | |
963 | bool preserves_inodes; | |
b9ee6643 TA |
964 | |
965 | /* Path to an executable script that will be registered as a criu | |
966 | * "action script" | |
967 | */ | |
968 | char *action_script; | |
f1954503 AR |
969 | |
970 | /* If CRIU >= 2.4 is detected the option to skip in-flight connections | |
971 | * will be enabled by default. The flag 'disable_skip_in_flight' will | |
972 | * unconditionally disable this feature. In-flight connections are | |
973 | * not fully established TCP connections: SYN, SYN-ACK */ | |
974 | bool disable_skip_in_flight; | |
b2b7b0d2 TA |
975 | |
976 | /* This is the maximum file size for deleted files (which CRIU calls | |
977 | * "ghost" files) that will be handled. 0 indicates the CRIU default, | |
978 | * which at this time is 1MB. | |
979 | */ | |
980 | uint64_t ghost_limit; | |
b5b12b9e AR |
981 | |
982 | /* Some features cannot be checked by comparing the CRIU version. | |
983 | * Features like dirty page tracking or userfaultfd depend on | |
984 | * the architecture/kernel/criu combination. This is a bitmask | |
985 | * in which the desired feature checks can be encoded. | |
986 | */ | |
987 | uint64_t features_to_check; | |
aef3d51e TA |
988 | }; |
989 | ||
191d43cc CB |
990 | struct lxc_console_log { |
991 | /* Clear the console log. */ | |
992 | bool clear; | |
993 | ||
994 | /* Retrieve the console log. */ | |
995 | bool read; | |
996 | ||
997 | /* This specifies the maximum size to read from the ringbuffer. Setting | |
998 | * it to 0 means that the a read can be as big as the whole ringbuffer. | |
999 | * On return callers can check how many bytes were actually read. | |
1000 | * If "read" and "clear" are set to false and a non-zero value is | |
1001 | * specified then up to "read_max" bytes of data will be discarded from | |
1002 | * the ringbuffer. | |
1003 | */ | |
1004 | uint64_t *read_max; | |
1005 | ||
1006 | /* Data that was read from the ringbuffer. If "read_max" is 0 on return | |
1007 | * "data" is invalid. | |
1008 | */ | |
1009 | char *data; | |
1010 | }; | |
1011 | ||
953e611c JH |
1012 | /*! |
1013 | * \brief Create a new container. | |
1014 | * | |
1015 | * \param name Name to use for container. | |
1016 | * \param configpath Full path to configuration file to use. | |
1017 | * | |
1018 | * \return Newly-allocated container, or \c NULL on error. | |
1019 | */ | |
afeecbba | 1020 | struct lxc_container *lxc_container_new(const char *name, const char *configpath); |
953e611c JH |
1021 | |
1022 | /*! | |
1023 | * \brief Add a reference to the specified container. | |
1024 | * | |
1025 | * \param c Container. | |
1026 | * | |
1027 | * \return \c true on success, \c false on error. | |
1028 | */ | |
72d0e1cb | 1029 | int lxc_container_get(struct lxc_container *c); |
953e611c JH |
1030 | |
1031 | /*! | |
1032 | * \brief Drop a reference to the specified container. | |
1033 | * | |
1034 | * \param c Container. | |
1035 | * | |
1036 | * \return \c 0 on success, \c 1 if reference was successfully dropped | |
1037 | * and container has been freed, and \c -1 on error. | |
1038 | * | |
1039 | * \warning If \c 1 is returned, \p c is no longer valid. | |
1040 | */ | |
72d0e1cb | 1041 | int lxc_container_put(struct lxc_container *c); |
953e611c JH |
1042 | |
1043 | /*! | |
1044 | * \brief Obtain a list of all container states. | |
1045 | * \param[out] states Caller-allocated array to hold all states (may be \c NULL). | |
1046 | * | |
1047 | * \return Number of container states. | |
1048 | * | |
1049 | * \note Passing \c NULL for \p states allows the caller to first | |
1050 | * calculate how many states there are before calling the function again, the second time | |
1051 | * providing a suitably-sized array to store the static string pointers | |
1052 | * in. | |
1053 | * \note The \p states array should be freed by the caller, but not the strings the elements point to. | |
1054 | */ | |
4a7c7daa | 1055 | int lxc_get_wait_states(const char **states); |
953e611c | 1056 | |
dbfa7128 | 1057 | /*! |
593e8478 | 1058 | * \brief Get the value for a global config key |
953e611c | 1059 | * |
593e8478 | 1060 | * \param key The name of the config key |
953e611c | 1061 | * |
593e8478 | 1062 | * \return String representing the current value for the key. |
953e611c | 1063 | */ |
593e8478 | 1064 | const char *lxc_get_global_config_item(const char *key); |
953e611c JH |
1065 | |
1066 | /*! | |
1067 | * \brief Determine version of LXC. | |
1068 | * \return Static string representing version of LXC in use. | |
1069 | * | |
1070 | * \note Returned string must not be freed. | |
1071 | */ | |
b6b918a1 | 1072 | const char *lxc_get_version(void); |
72d0e1cb | 1073 | |
953e611c JH |
1074 | /*! |
1075 | * \brief Get a list of defined containers in a lxcpath. | |
a41f104b | 1076 | * |
953e611c JH |
1077 | * \param lxcpath lxcpath under which to look. |
1078 | * \param names If not \c NULL, then a list of container names will be returned here. | |
1079 | * \param cret If not \c NULL, then a list of lxc_containers will be returned here. | |
1080 | * | |
1081 | * \return Number of containers found, or \c -1 on error. | |
1082 | * | |
1083 | * \note Values returned in \p cret are sorted by container name. | |
a41f104b SH |
1084 | */ |
1085 | int list_defined_containers(const char *lxcpath, char ***names, struct lxc_container ***cret); | |
1086 | ||
953e611c JH |
1087 | /*! |
1088 | * \brief Get a list of active containers for a given lxcpath. | |
1089 | * | |
1090 | * \param lxcpath Full \c LXCPATH path to consider. | |
1091 | * \param[out] names Dynamically-allocated array of container names. | |
1092 | * \param[out] cret Dynamically-allocated list of containers. | |
1093 | * | |
1094 | * \return Number of containers found, or -1 on error. | |
a41f104b | 1095 | * |
953e611c JH |
1096 | * \note Some of the containers may not be "defined". |
1097 | * \note Values returned in \p cret are sorted by container name. | |
1098 | * \note \p names and \p cret may both (or either) be specified as \c NULL. | |
1099 | * \note \p names and \p cret must be freed by the caller. | |
a41f104b SH |
1100 | */ |
1101 | int list_active_containers(const char *lxcpath, char ***names, struct lxc_container ***cret); | |
1102 | ||
953e611c JH |
1103 | /*! |
1104 | * \brief Get a complete list of all containers for a given lxcpath. | |
2871830a | 1105 | * |
953e611c JH |
1106 | * \param lxcpath Full \c LXCPATH path to consider. |
1107 | * \param[out] names Dynamically-allocated array of container name. | |
1108 | * \param[out] cret Dynamically-allocated list of containers. | |
1109 | * | |
1110 | * \return Number of containers, or -1 on error. | |
1111 | * | |
1112 | * \note Some of the containers may not be "defined". | |
1113 | * \note Values returned in \p cret are sorted by container name. | |
1114 | * \note \p names and \p cret may both (or either) be specified as \c NULL. | |
1115 | * \note \p names and \p cret must be freed by the caller. | |
2871830a DE |
1116 | */ |
1117 | int list_all_containers(const char *lxcpath, char ***names, struct lxc_container ***cret); | |
1118 | ||
73b910a3 | 1119 | struct lxc_log { |
1120 | const char *name; | |
1121 | const char *lxcpath; | |
1122 | const char *file; | |
4b73005c | 1123 | const char *level; |
73b910a3 | 1124 | const char *prefix; |
1125 | bool quiet; | |
1126 | }; | |
1127 | ||
1128 | /*! | |
1129 | *\brief Initialize the log | |
1130 | * | |
1131 | *\param log lxc log configuration. | |
1132 | */ | |
1133 | int lxc_log_init(struct lxc_log *log); | |
1134 | ||
36eaa694 DE |
1135 | /*! |
1136 | * \brief Close log file. | |
1137 | */ | |
1138 | void lxc_log_close(void); | |
1139 | ||
12461428 CB |
1140 | /*! |
1141 | * \brief Check if the configuration item is supported by this LXC instance. | |
1142 | * | |
1143 | * \param key Configuration item to check for. | |
1144 | */ | |
1145 | bool lxc_config_item_is_supported(const char *key); | |
1146 | ||
aafa5f96 CB |
1147 | /*! |
1148 | * \brief Check if an API extension is supported by this LXC instance. | |
1149 | * | |
1150 | * \param extension API extension to check for. | |
1151 | */ | |
1152 | bool lxc_has_api_extension(const char *extension); | |
1153 | ||
579e783e AM |
1154 | #ifdef __cplusplus |
1155 | } | |
1156 | #endif | |
1157 | ||
9be53773 | 1158 | #endif |