~serge-hallyn/ubuntu/quantal/lxc/lxc-oracle

« back to all changes in this revision

Viewing changes to src/lxc/lxc.h

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2009-04-29 17:49:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090429174913-jvahs1ykizqtodje
Tags: upstream-0.6.2
ImportĀ upstreamĀ versionĀ 0.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * lxc: linux Container library
 
3
 *
 
4
 * (C) Copyright IBM Corp. 2007, 2008
 
5
 *
 
6
 * Authors:
 
7
 * Daniel Lezcano <dlezcano at fr.ibm.com>
 
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
22
 */
 
23
#ifndef __lxc_h
 
24
#define __lxc_h
 
25
 
 
26
#ifdef __cplusplus
 
27
extern "C" {
 
28
#endif
 
29
 
 
30
/**
 
31
 Following code is for liblxc.
 
32
 
 
33
 lxc/lxc.h will contain exports of liblxc
 
34
 **/
 
35
 
 
36
#include <lxc/state.h>
 
37
#include <lxc/list.h>
 
38
#include <lxc/log.h>
 
39
#include <lxc/conf.h>
 
40
#include <lxc/lock.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>
 
46
 
 
47
/*
 
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
 
55
 */
 
56
extern int lxc_create(const char *name, struct lxc_conf *conf);
 
57
 
 
58
/*
 
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
 
64
 */
 
65
extern int lxc_destroy(const char *name);
 
66
 
 
67
/*
 
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
 
73
 */
 
74
extern int lxc_start(const char *name, char *argv[]);
 
75
 
 
76
/*
 
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
 
81
 */
 
82
extern int lxc_stop(const char *name);
 
83
 
 
84
/*
 
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
 
92
 */
 
93
extern int lxc_monitor(const char *name, int output_fd);
 
94
 
 
95
/*
 
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
 
99
 */
 
100
extern int lxc_monitor_open();
 
101
 
 
102
/*
 
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
 
109
 */
 
110
extern int lxc_monitor_read(int fd, struct lxc_msg *msg);
 
111
 
 
112
/*
 
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
 
116
 */
 
117
extern int lxc_monitor_close(int fd);
 
118
 
 
119
/*
 
120
 * Show the console of the container.
 
121
 * @name : the name of container
 
122
 * Returns 0 on sucess, < 0 otherwise
 
123
 */
 
124
extern int lxc_console(const char *name, int ttynum, int *fd);
 
125
 
 
126
/*
 
127
 * Freeze all the tasks running inside the container <name>
 
128
 * @name : the container name
 
129
 * Returns 0 on success, < 0 otherwise
 
130
 */
 
131
extern int lxc_freeze(const char *name);
 
132
 
 
133
/*
 
134
 * Unfreeze all previously frozen tasks.
 
135
 * @name : the name of the container
 
136
 * Return 0 on sucess, < 0 otherwise
 
137
 */
 
138
extern int lxc_unfreeze(const char *name);
 
139
 
 
140
/*
 
141
 * Retrieve the container state
 
142
 * @name : the name of the container
 
143
 * Returns the state of the container on success, < 0 otherwise
 
144
 */
 
145
extern lxc_state_t lxc_state(const char *name);
 
146
 
 
147
/*
 
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
 
154
 */
 
155
extern int lxc_cgroup_set(const char *name, const char *subsystem, const char *value);
 
156
 
 
157
/*
 
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
 
165
 */
 
166
extern int lxc_cgroup_get(const char *name, const char *subsystem, 
 
167
                          char *value, size_t len);
 
168
 
 
169
/*
 
170
 * Retrieve the error string associated with the error returned by
 
171
 * the function.
 
172
 * @error : the value of the error
 
173
 * Returns a string on success or NULL otherwise.
 
174
 */
 
175
extern const char *lxc_strerror(int error);
 
176
 
 
177
/*
 
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
 
183
 */
 
184
extern int lxc_checkpoint(const char *name, const char *statefile, 
 
185
                        unsigned long flags);
 
186
 
 
187
/*
 
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
 
193
 */
 
194
extern int lxc_restart(const char *name, const char *statefile, 
 
195
                        unsigned long flags);
 
196
 
 
197
/*
 
198
 * Returns the version number of the library
 
199
 */
 
200
extern const char const *lxc_version(void);
 
201
 
 
202
#ifdef __cplusplus
 
203
}
 
204
#endif
 
205
 
 
206
#endif