]>
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> |
f2363e38 | 34 | #include "state.h" |
ad3ac5e0 MN |
35 | |
36 | struct lxc_msg; | |
fae349da | 37 | struct lxc_conf; |
0ae4f887 | 38 | struct lxc_arguments; |
ad3ac5e0 | 39 | |
0ad19a3f | 40 | /** |
41 | Following code is for liblxc. | |
42 | ||
2aa79ee7 | 43 | lxc/lxc.h will contain exports of liblxc |
0ad19a3f | 44 | **/ |
45 | ||
0ad19a3f | 46 | /* |
0ae4f887 | 47 | * Start the specified command inside a system container |
507cee36 TA |
48 | * @name : the name of the container |
49 | * @argv : an array of char * corresponding to the commande line | |
50 | * @conf : configuration | |
51 | * @backgrounded : whether or not the container is daemonized | |
ec64264d | 52 | * Returns 0 on success, < 0 otherwise |
0ad19a3f | 53 | */ |
13f5be62 | 54 | extern int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf, |
507cee36 | 55 | const char *lxcpath, bool backgrounded); |
0ad19a3f | 56 | |
0ae4f887 GK |
57 | /* |
58 | * Start the specified command inside an application container | |
507cee36 TA |
59 | * @name : the name of the container |
60 | * @argv : an array of char * corresponding to the commande line | |
61 | * @quiet : if != 0 then lxc-init won't produce any output | |
62 | * @conf : configuration | |
63 | * @backgrounded : whether or not the container is daemonized | |
ec64264d | 64 | * Returns 0 on success, < 0 otherwise |
0ae4f887 GK |
65 | */ |
66 | extern int lxc_execute(const char *name, char *const argv[], int quiet, | |
507cee36 TA |
67 | struct lxc_conf *conf, const char *lxcpath, |
68 | bool backgrounded); | |
0ae4f887 | 69 | |
0ad19a3f | 70 | /* |
71 | * Close the fd associated with the monitoring | |
72 | * @fd : the file descriptor provided by lxc_monitor_open | |
73 | * Returns 0 on success, < 0 otherwise | |
74 | */ | |
75 | extern int lxc_monitor_close(int fd); | |
76 | ||
0ad19a3f | 77 | /* |
78 | * Freeze all the tasks running inside the container <name> | |
79 | * @name : the container name | |
80 | * Returns 0 on success, < 0 otherwise | |
81 | */ | |
9123e471 | 82 | extern int lxc_freeze(const char *name, const char *lxcpath); |
0ad19a3f | 83 | |
84 | /* | |
85 | * Unfreeze all previously frozen tasks. | |
86 | * @name : the name of the container | |
ec64264d | 87 | * Return 0 on success, < 0 otherwise |
0ad19a3f | 88 | */ |
9123e471 | 89 | extern int lxc_unfreeze(const char *name, const char *lxcpath); |
0ad19a3f | 90 | |
91 | /* | |
92 | * Retrieve the container state | |
93 | * @name : the name of the container | |
94 | * Returns the state of the container on success, < 0 otherwise | |
95 | */ | |
13f5be62 | 96 | extern lxc_state_t lxc_state(const char *name, const char *lxcpath); |
0ad19a3f | 97 | |
0ad19a3f | 98 | /* |
576f946d | 99 | * Set a specified value for a specified subsystem. The specified |
100 | * subsystem must be fully specified, eg. "cpu.shares" | |
ae5c8b8e | 101 | * @filename : the cgroup attribute filename |
576f946d | 102 | * @value : the value to be set |
33ad9f1a | 103 | * @name : the name of the container |
ae5c8b8e | 104 | * @lxcpath : lxc config path for container |
0ad19a3f | 105 | * Returns 0 on success, < 0 otherwise |
106 | */ | |
33ad9f1a | 107 | extern int lxc_cgroup_set(const char *filename, const char *value, const char *name, const char *lxcpath); |
0ad19a3f | 108 | |
109 | /* | |
576f946d | 110 | * Get a specified value for a specified subsystem. The specified |
111 | * subsystem must be fully specified, eg. "cpu.shares" | |
ae5c8b8e | 112 | * @filename : the cgroup attribute filename |
576f946d | 113 | * @value : the value to be set |
114 | * @len : the len of the value variable | |
33ad9f1a | 115 | * @name : the name of the container |
ae5c8b8e | 116 | * @lxcpath : lxc config path for container |
70f7755e | 117 | * Returns the number of bytes read, < 0 on error |
0ad19a3f | 118 | */ |
33ad9f1a | 119 | extern int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath); |
0ad19a3f | 120 | |
72d0e1cb SG |
121 | /* |
122 | * Create and return a new lxccontainer struct. | |
123 | */ | |
afeecbba | 124 | extern struct lxc_container *lxc_container_new(const char *name, const char *configpath); |
72d0e1cb SG |
125 | |
126 | /* | |
127 | * Returns 1 on success, 0 on failure. | |
128 | */ | |
129 | extern int lxc_container_get(struct lxc_container *c); | |
130 | ||
131 | /* | |
132 | * Put a lxccontainer struct reference. | |
133 | * Return -1 on error. | |
134 | * Return 0 if this was not the last reference. | |
135 | * If it is the last reference, free the lxccontainer and return 1. | |
136 | */ | |
137 | extern int lxc_container_put(struct lxc_container *c); | |
138 | ||
139 | /* | |
140 | * Get a list of valid wait states. | |
141 | * If states is NULL, simply return the number of states | |
142 | */ | |
4a7c7daa | 143 | extern int lxc_get_wait_states(const char **states); |
72d0e1cb | 144 | |
dfb31b25 SH |
145 | /* |
146 | * Add a dependency to a container | |
147 | */ | |
148 | extern int add_rdepend(struct lxc_conf *lxc_conf, char *rdepend); | |
149 | ||
0ad19a3f | 150 | #ifdef __cplusplus |
151 | } | |
152 | #endif | |
153 | ||
154 | #endif |