]>
Commit | Line | Data |
---|---|---|
0ad19a3f | 1 | /* |
2 | * lxc: linux Container library | |
3 | * | |
4 | * (C) Copyright IBM Corp. 2007, 2008 | |
5 | * | |
6 | * Authors: | |
9afe19d6 | 7 | * Daniel Lezcano <daniel.lezcano at free.fr> |
0ad19a3f | 8 | * |
9 | * This library is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU Lesser General Public | |
11 | * License as published by the Free Software Foundation; either | |
12 | * version 2.1 of the License, or (at your option) any later version. | |
13 | * | |
14 | * This library is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * Lesser General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU Lesser General Public | |
20 | * License along with this library; if not, write to the Free Software | |
250b1eec | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0ad19a3f | 22 | */ |
f1a4a029 ÇO |
23 | #ifndef __LXC_LXC_H |
24 | #define __LXC_LXC_H | |
0ad19a3f | 25 | |
26 | #ifdef __cplusplus | |
27 | extern "C" { | |
28 | #endif | |
29 | ||
507cee36 | 30 | #include <stdbool.h> |
ad3ac5e0 | 31 | #include <stddef.h> |
2b89a9c1 | 32 | #include <sys/select.h> |
8d06bd13 | 33 | #include <sys/types.h> |
d38dd64a | 34 | |
f2363e38 | 35 | #include "state.h" |
ad3ac5e0 MN |
36 | |
37 | struct lxc_msg; | |
fae349da | 38 | struct lxc_conf; |
0ae4f887 | 39 | struct lxc_arguments; |
aa460476 | 40 | struct lxc_handler; |
ad3ac5e0 | 41 | |
0ad19a3f | 42 | /** |
43 | Following code is for liblxc. | |
44 | ||
2aa79ee7 | 45 | lxc/lxc.h will contain exports of liblxc |
0ad19a3f | 46 | **/ |
47 | ||
0ad19a3f | 48 | /* |
0ae4f887 | 49 | * Start the specified command inside a system container |
507cee36 | 50 | * @name : the name of the container |
c050cfe3 | 51 | * @argv : an array of char * corresponding to the command line |
507cee36 | 52 | * @conf : configuration |
bb955810 | 53 | * @daemonize : whether or not the container is daemonized |
ec64264d | 54 | * Returns 0 on success, < 0 otherwise |
0ad19a3f | 55 | */ |
aa460476 CB |
56 | extern int lxc_start(const char *name, char *const argv[], |
57 | struct lxc_handler *handler, const char *lxcpath, | |
bb955810 | 58 | bool daemonize, int *error_num); |
0ad19a3f | 59 | |
0ae4f887 GK |
60 | /* |
61 | * Start the specified command inside an application container | |
507cee36 | 62 | * @name : the name of the container |
c050cfe3 | 63 | * @argv : an array of char * corresponding to the command line |
507cee36 TA |
64 | * @quiet : if != 0 then lxc-init won't produce any output |
65 | * @conf : configuration | |
bb955810 | 66 | * @daemonize : whether or not the container is daemonized |
ec64264d | 67 | * Returns 0 on success, < 0 otherwise |
0ae4f887 GK |
68 | */ |
69 | extern int lxc_execute(const char *name, char *const argv[], int quiet, | |
aa460476 | 70 | struct lxc_handler *handler, const char *lxcpath, |
bb955810 | 71 | bool daemonize, int *error_num); |
0ae4f887 | 72 | |
0ad19a3f | 73 | /* |
74 | * Close the fd associated with the monitoring | |
75 | * @fd : the file descriptor provided by lxc_monitor_open | |
76 | * Returns 0 on success, < 0 otherwise | |
77 | */ | |
78 | extern int lxc_monitor_close(int fd); | |
79 | ||
0ad19a3f | 80 | /* |
81 | * Freeze all the tasks running inside the container <name> | |
82 | * @name : the container name | |
83 | * Returns 0 on success, < 0 otherwise | |
84 | */ | |
5a087e05 CB |
85 | extern int lxc_freeze(struct lxc_conf *conf, const char *name, |
86 | const char *lxcpath); | |
0ad19a3f | 87 | |
88 | /* | |
89 | * Unfreeze all previously frozen tasks. | |
90 | * @name : the name of the container | |
ec64264d | 91 | * Return 0 on success, < 0 otherwise |
0ad19a3f | 92 | */ |
5a087e05 CB |
93 | extern int lxc_unfreeze(struct lxc_conf *conf, const char *name, |
94 | const char *lxcpath); | |
0ad19a3f | 95 | |
96 | /* | |
97 | * Retrieve the container state | |
98 | * @name : the name of the container | |
99 | * Returns the state of the container on success, < 0 otherwise | |
100 | */ | |
13f5be62 | 101 | extern lxc_state_t lxc_state(const char *name, const char *lxcpath); |
0ad19a3f | 102 | |
72d0e1cb SG |
103 | /* |
104 | * Create and return a new lxccontainer struct. | |
105 | */ | |
afeecbba | 106 | extern struct lxc_container *lxc_container_new(const char *name, const char *configpath); |
72d0e1cb SG |
107 | |
108 | /* | |
109 | * Returns 1 on success, 0 on failure. | |
110 | */ | |
111 | extern int lxc_container_get(struct lxc_container *c); | |
112 | ||
113 | /* | |
114 | * Put a lxccontainer struct reference. | |
115 | * Return -1 on error. | |
116 | * Return 0 if this was not the last reference. | |
117 | * If it is the last reference, free the lxccontainer and return 1. | |
118 | */ | |
119 | extern int lxc_container_put(struct lxc_container *c); | |
120 | ||
121 | /* | |
122 | * Get a list of valid wait states. | |
123 | * If states is NULL, simply return the number of states | |
124 | */ | |
4a7c7daa | 125 | extern int lxc_get_wait_states(const char **states); |
72d0e1cb | 126 | |
dfb31b25 SH |
127 | /* |
128 | * Add a dependency to a container | |
129 | */ | |
130 | extern int add_rdepend(struct lxc_conf *lxc_conf, char *rdepend); | |
131 | ||
0d9cd9c3 CB |
132 | /* |
133 | * Set a key/value configuration option. Requires that to take a lock on the | |
134 | * in-memory config of the container. | |
135 | */ | |
136 | extern int lxc_set_config_item_locked(struct lxc_conf *conf, const char *key, | |
137 | const char *v); | |
138 | ||
0ad19a3f | 139 | #ifdef __cplusplus |
140 | } | |
141 | #endif | |
142 | ||
143 | #endif |