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