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