]>
Commit | Line | Data |
---|---|---|
cc73685d CB |
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
2 | ||
f1a4a029 ÇO |
3 | #ifndef __LXC_LXC_H |
4 | #define __LXC_LXC_H | |
0ad19a3f | 5 | |
6 | #ifdef __cplusplus | |
7 | extern "C" { | |
8 | #endif | |
9 | ||
507cee36 | 10 | #include <stdbool.h> |
ad3ac5e0 | 11 | #include <stddef.h> |
2b89a9c1 | 12 | #include <sys/select.h> |
8d06bd13 | 13 | #include <sys/types.h> |
d38dd64a | 14 | |
59eac805 | 15 | #include "compiler.h" |
49aaa754 | 16 | #include "memory_utils.h" |
f2363e38 | 17 | #include "state.h" |
ad3ac5e0 MN |
18 | |
19 | struct lxc_msg; | |
fae349da | 20 | struct lxc_conf; |
0ae4f887 | 21 | struct lxc_arguments; |
aa460476 | 22 | struct lxc_handler; |
ad3ac5e0 | 23 | |
0ad19a3f | 24 | /** |
25 | Following code is for liblxc. | |
26 | ||
2aa79ee7 | 27 | lxc/lxc.h will contain exports of liblxc |
0ad19a3f | 28 | **/ |
29 | ||
0ad19a3f | 30 | /* |
0ae4f887 | 31 | * Start the specified command inside a system container |
c050cfe3 | 32 | * @argv : an array of char * corresponding to the command line |
507cee36 | 33 | * @conf : configuration |
bb955810 | 34 | * @daemonize : whether or not the container is daemonized |
ec64264d | 35 | * Returns 0 on success, < 0 otherwise |
0ad19a3f | 36 | */ |
59eac805 CB |
37 | __hidden extern int lxc_start(char *const argv[], struct lxc_handler *handler, const char *lxcpath, |
38 | bool daemonize, int *error_num); | |
0ad19a3f | 39 | |
0ae4f887 GK |
40 | /* |
41 | * Start the specified command inside an application container | |
507cee36 | 42 | * @name : the name of the container |
c050cfe3 | 43 | * @argv : an array of char * corresponding to the command line |
507cee36 TA |
44 | * @quiet : if != 0 then lxc-init won't produce any output |
45 | * @conf : configuration | |
bb955810 | 46 | * @daemonize : whether or not the container is daemonized |
ec64264d | 47 | * Returns 0 on success, < 0 otherwise |
0ae4f887 | 48 | */ |
59eac805 CB |
49 | __hidden extern int lxc_execute(const char *name, char *const argv[], int quiet, |
50 | struct lxc_handler *handler, const char *lxcpath, bool daemonize, | |
51 | int *error_num); | |
0ae4f887 | 52 | |
0ad19a3f | 53 | /* |
54 | * Close the fd associated with the monitoring | |
55 | * @fd : the file descriptor provided by lxc_monitor_open | |
56 | * Returns 0 on success, < 0 otherwise | |
57 | */ | |
59eac805 | 58 | __hidden extern int lxc_monitor_close(int fd); |
0ad19a3f | 59 | |
0ad19a3f | 60 | /* |
61 | * Freeze all the tasks running inside the container <name> | |
62 | * @name : the container name | |
63 | * Returns 0 on success, < 0 otherwise | |
64 | */ | |
59eac805 | 65 | __hidden extern int lxc_freeze(struct lxc_conf *conf, const char *name, const char *lxcpath); |
0ad19a3f | 66 | |
67 | /* | |
68 | * Unfreeze all previously frozen tasks. | |
69 | * @name : the name of the container | |
ec64264d | 70 | * Return 0 on success, < 0 otherwise |
0ad19a3f | 71 | */ |
59eac805 | 72 | __hidden extern int lxc_unfreeze(struct lxc_conf *conf, const char *name, const char *lxcpath); |
0ad19a3f | 73 | |
74 | /* | |
75 | * Retrieve the container state | |
76 | * @name : the name of the container | |
77 | * Returns the state of the container on success, < 0 otherwise | |
78 | */ | |
59eac805 | 79 | __hidden extern lxc_state_t lxc_state(const char *name, const char *lxcpath); |
0ad19a3f | 80 | |
72d0e1cb SG |
81 | /* |
82 | * Create and return a new lxccontainer struct. | |
83 | */ | |
afeecbba | 84 | extern struct lxc_container *lxc_container_new(const char *name, const char *configpath); |
72d0e1cb SG |
85 | |
86 | /* | |
87 | * Returns 1 on success, 0 on failure. | |
88 | */ | |
89 | extern int lxc_container_get(struct lxc_container *c); | |
90 | ||
91 | /* | |
92 | * Put a lxccontainer struct reference. | |
93 | * Return -1 on error. | |
94 | * Return 0 if this was not the last reference. | |
95 | * If it is the last reference, free the lxccontainer and return 1. | |
96 | */ | |
97 | extern int lxc_container_put(struct lxc_container *c); | |
49aaa754 CB |
98 | static inline void put_lxc_container(struct lxc_container *c) |
99 | { | |
100 | if (c) | |
101 | lxc_container_put(c); | |
102 | } | |
103 | define_cleanup_function(struct lxc_container *, put_lxc_container); | |
104 | #define __put_lxc_container call_cleaner(put_lxc_container) | |
72d0e1cb SG |
105 | |
106 | /* | |
107 | * Get a list of valid wait states. | |
108 | * If states is NULL, simply return the number of states | |
109 | */ | |
4a7c7daa | 110 | extern int lxc_get_wait_states(const char **states); |
72d0e1cb | 111 | |
dfb31b25 SH |
112 | /* |
113 | * Add a dependency to a container | |
114 | */ | |
59eac805 | 115 | __hidden extern int add_rdepend(struct lxc_conf *lxc_conf, char *rdepend); |
dfb31b25 | 116 | |
0d9cd9c3 CB |
117 | /* |
118 | * Set a key/value configuration option. Requires that to take a lock on the | |
119 | * in-memory config of the container. | |
120 | */ | |
59eac805 | 121 | __hidden extern int lxc_set_config_item_locked(struct lxc_conf *conf, const char *key, const char *v); |
0d9cd9c3 | 122 | |
0ad19a3f | 123 | #ifdef __cplusplus |
124 | } | |
125 | #endif | |
126 | ||
59eac805 | 127 | #endif /* __LXC_LXC_H */ |