2
* lxc: linux Container library
4
* (C) Copyright IBM Corp. 2007, 2008
7
* Daniel Lezcano <dlezcano at fr.ibm.com>
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31
Following code is for liblxc.
33
lxc/lxc.h will contain exports of liblxc
36
#include <lxc/state.h>
41
#include <lxc/namespace.h>
42
#include <lxc/utils.h>
43
#include <lxc/error.h>
44
#include <lxc/cgroup.h>
45
#include <lxc/monitor.h>
48
* Create the container object. Creates the /lxc/<name> directory
49
* and fills it with the files corresponding to the configuration
50
* structure passed as parameter.
51
* The first container will create the /lxc directory.
52
* @name : the name of the container
53
* @conf : the configuration data for the container
54
* Returns 0 on success, < 0 otherwise
56
extern int lxc_create(const char *name, struct lxc_conf *conf);
59
* Destroy the container object. Removes the files into the /lxc/<name>
60
* directory and removes the <name> directory.
61
* The last container will remove the /lxc directory.
62
* @name : the name of the container to be detroyed
63
* Returns 0 on success, < 0 otherwise
65
extern int lxc_destroy(const char *name);
68
* Start the specified command inside a container which has
69
* been created before with lxc_create.
70
* @name : the name of the container
71
* @argv : an array of char * corresponding to the commande line
72
* Returns 0 on sucess, < 0 otherwise
74
extern int lxc_start(const char *name, char *argv[]);
77
* Stop the container previously started with lxc_start, all
78
* the processes running inside this container will be killed.
79
* @name : the name of the container
80
* Returns 0 on success, < 0 otherwise
82
extern int lxc_stop(const char *name);
85
* Monitor the container, each time the state of the container
86
* is changed, a state data is send through a file descriptor passed to
87
* the function with output_fd.
88
* The function will block until the container is destroyed.
89
* @name : the name of the container
90
* @output_fd : the file descriptor where to send the states
91
* Returns 0 on success, < 0 otherwise
93
extern int lxc_monitor(const char *name, int output_fd);
96
* Open the monitoring mechanism for a specific container
97
* The function will return an fd corresponding to the events
98
* Returns a file descriptor on success, < 0 otherwise
100
extern int lxc_monitor_open();
103
* Read the state of the container if this one has changed
104
* The function will block until there is an event available
105
* @fd : the file descriptor provided by lxc_monitor_open
106
* @state : the variable which will be filled with the state
107
* Returns 0 if the monitored container has exited, > 0 if
108
* data was readen, < 0 otherwise
110
extern int lxc_monitor_read(int fd, struct lxc_msg *msg);
113
* Close the fd associated with the monitoring
114
* @fd : the file descriptor provided by lxc_monitor_open
115
* Returns 0 on success, < 0 otherwise
117
extern int lxc_monitor_close(int fd);
120
* Show the console of the container.
121
* @name : the name of container
122
* Returns 0 on sucess, < 0 otherwise
124
extern int lxc_console(const char *name, int ttynum, int *fd);
127
* Freeze all the tasks running inside the container <name>
128
* @name : the container name
129
* Returns 0 on success, < 0 otherwise
131
extern int lxc_freeze(const char *name);
134
* Unfreeze all previously frozen tasks.
135
* @name : the name of the container
136
* Return 0 on sucess, < 0 otherwise
138
extern int lxc_unfreeze(const char *name);
141
* Retrieve the container state
142
* @name : the name of the container
143
* Returns the state of the container on success, < 0 otherwise
145
extern lxc_state_t lxc_state(const char *name);
148
* Set a specified value for a specified subsystem. The specified
149
* subsystem must be fully specified, eg. "cpu.shares"
150
* @name : the name of the container
151
* @subsystem : the subsystem
152
* @value : the value to be set
153
* Returns 0 on success, < 0 otherwise
155
extern int lxc_cgroup_set(const char *name, const char *subsystem, const char *value);
158
* Get a specified value for a specified subsystem. The specified
159
* subsystem must be fully specified, eg. "cpu.shares"
160
* @name : the name of the container
161
* @subsystem : the subsystem
162
* @value : the value to be set
163
* @len : the len of the value variable
164
* Returns 0 on success, < 0 otherwise
166
extern int lxc_cgroup_get(const char *name, const char *subsystem,
167
char *value, size_t len);
170
* Retrieve the error string associated with the error returned by
172
* @error : the value of the error
173
* Returns a string on success or NULL otherwise.
175
extern const char *lxc_strerror(int error);
178
* Checkpoint a container previously frozen
179
* @name : the name of the container being checkpointed
180
* @fd : file descriptor on which the container is checkpointed
181
* @flags : checkpoint flags
182
* Returns 0 on success, < 0 otherwise
184
extern int lxc_checkpoint(const char *name, const char *statefile,
185
unsigned long flags);
188
* Restart a container previously frozen
189
* @name : the name of the container being restarted
190
* @fd : file descriptor from which the container is restarted
191
* @flags : restart flags
192
* Returns 0 on success, < 0 otherwise
194
extern int lxc_restart(const char *name, const char *statefile,
195
unsigned long flags);
198
* Returns the version number of the library
200
extern const char const *lxc_version(void);