]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/lxc.h
ovl_rsync: make sure to umount
[mirror_lxc.git] / src / lxc / lxc.h
1 /*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2008
5 *
6 * Authors:
7 * Daniel Lezcano <daniel.lezcano at free.fr>
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
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 #ifndef __LXC_LXC_H
24 #define __LXC_LXC_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #include <stdbool.h>
31 #include <stddef.h>
32 #include <sys/select.h>
33 #include <sys/types.h>
34 #include "state.h"
35
36 struct lxc_msg;
37 struct lxc_conf;
38 struct lxc_arguments;
39
40 /**
41 Following code is for liblxc.
42
43 lxc/lxc.h will contain exports of liblxc
44 **/
45
46 /*
47 * Start the specified command inside a system container
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
52 * Returns 0 on success, < 0 otherwise
53 */
54 extern int lxc_start(const char *name, char *const argv[], struct lxc_conf *conf,
55 const char *lxcpath, bool backgrounded);
56
57 /*
58 * Start the specified command inside an application container
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
64 * Returns 0 on success, < 0 otherwise
65 */
66 extern int lxc_execute(const char *name, char *const argv[], int quiet,
67 struct lxc_conf *conf, const char *lxcpath,
68 bool backgrounded);
69
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
77 /*
78 * Freeze all the tasks running inside the container <name>
79 * @name : the container name
80 * Returns 0 on success, < 0 otherwise
81 */
82 extern int lxc_freeze(const char *name, const char *lxcpath);
83
84 /*
85 * Unfreeze all previously frozen tasks.
86 * @name : the name of the container
87 * Return 0 on success, < 0 otherwise
88 */
89 extern int lxc_unfreeze(const char *name, const char *lxcpath);
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 */
96 extern lxc_state_t lxc_state(const char *name, const char *lxcpath);
97
98 /*
99 * Set a specified value for a specified subsystem. The specified
100 * subsystem must be fully specified, eg. "cpu.shares"
101 * @filename : the cgroup attribute filename
102 * @value : the value to be set
103 * @name : the name of the container
104 * @lxcpath : lxc config path for container
105 * Returns 0 on success, < 0 otherwise
106 */
107 extern int lxc_cgroup_set(const char *filename, const char *value, const char *name, const char *lxcpath);
108
109 /*
110 * Get a specified value for a specified subsystem. The specified
111 * subsystem must be fully specified, eg. "cpu.shares"
112 * @filename : the cgroup attribute filename
113 * @value : the value to be set
114 * @len : the len of the value variable
115 * @name : the name of the container
116 * @lxcpath : lxc config path for container
117 * Returns the number of bytes read, < 0 on error
118 */
119 extern int lxc_cgroup_get(const char *filename, char *value, size_t len, const char *name, const char *lxcpath);
120
121 /*
122 * Retrieve the error string associated with the error returned by
123 * the function.
124 * @error : the value of the error
125 * Returns a string on success or NULL otherwise.
126 */
127 extern const char *lxc_strerror(int error);
128
129 /*
130 * Create and return a new lxccontainer struct.
131 */
132 extern struct lxc_container *lxc_container_new(const char *name, const char *configpath);
133
134 /*
135 * Returns 1 on success, 0 on failure.
136 */
137 extern int lxc_container_get(struct lxc_container *c);
138
139 /*
140 * Put a lxccontainer struct reference.
141 * Return -1 on error.
142 * Return 0 if this was not the last reference.
143 * If it is the last reference, free the lxccontainer and return 1.
144 */
145 extern int lxc_container_put(struct lxc_container *c);
146
147 /*
148 * Get a list of valid wait states.
149 * If states is NULL, simply return the number of states
150 */
151 extern int lxc_get_wait_states(const char **states);
152
153 /*
154 * Add a dependency to a container
155 */
156 extern int add_rdepend(struct lxc_conf *lxc_conf, char *rdepend);
157
158 #ifdef __cplusplus
159 }
160 #endif
161
162 #endif