]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/lxc.h
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 #include <lxc/state.h>
36 Following code is for liblxc.
38 lxc/lxc.h will contain exports of liblxc
42 * Start the specified command inside a container
43 * @name : the name of the container
44 * @argv : an array of char * corresponding to the commande line
45 * Returns 0 on sucess, < 0 otherwise
47 extern int lxc_start(const char *name
, char *const argv
[], const char *rcfile
);
50 * Stop the container previously started with lxc_start, all
51 * the processes running inside this container will be killed.
52 * @name : the name of the container
53 * Returns 0 on success, < 0 otherwise
55 extern int lxc_stop(const char *name
);
58 * Open the monitoring mechanism for a specific container
59 * The function will return an fd corresponding to the events
60 * Returns a file descriptor on success, < 0 otherwise
62 extern int lxc_monitor_open(void);
65 * Read the state of the container if this one has changed
66 * The function will block until there is an event available
67 * @fd : the file descriptor provided by lxc_monitor_open
68 * @state : the variable which will be filled with the state
69 * Returns 0 if the monitored container has exited, > 0 if
70 * data was readen, < 0 otherwise
72 extern int lxc_monitor_read(int fd
, struct lxc_msg
*msg
);
75 * Close the fd associated with the monitoring
76 * @fd : the file descriptor provided by lxc_monitor_open
77 * Returns 0 on success, < 0 otherwise
79 extern int lxc_monitor_close(int fd
);
82 * Show the console of the container.
83 * @name : the name of container
84 * @tty : the tty number
85 * @fd : a pointer to a tty file descriptor
86 * Returns 0 on sucess, < 0 otherwise
88 extern int lxc_console(const char *name
, int ttynum
, int *fd
);
91 * Freeze all the tasks running inside the container <name>
92 * @name : the container name
93 * Returns 0 on success, < 0 otherwise
95 extern int lxc_freeze(const char *name
);
98 * Unfreeze all previously frozen tasks.
99 * @name : the name of the container
100 * Return 0 on sucess, < 0 otherwise
102 extern int lxc_unfreeze(const char *name
);
105 * Retrieve the container state
106 * @name : the name of the container
107 * Returns the state of the container on success, < 0 otherwise
109 extern lxc_state_t
lxc_state(const char *name
);
112 * Set a specified value for a specified subsystem. The specified
113 * subsystem must be fully specified, eg. "cpu.shares"
114 * @name : the name of the container
115 * @subsystem : the subsystem
116 * @value : the value to be set
117 * Returns 0 on success, < 0 otherwise
119 extern int lxc_cgroup_set(const char *name
, const char *subsystem
, const char *value
);
122 * Get a specified value for a specified subsystem. The specified
123 * subsystem must be fully specified, eg. "cpu.shares"
124 * @name : the name of the container
125 * @subsystem : the subsystem
126 * @value : the value to be set
127 * @len : the len of the value variable
128 * Returns the number of bytes read, < 0 on error
130 extern int lxc_cgroup_get(const char *name
, const char *subsystem
,
131 char *value
, size_t len
);
134 * Retrieve the error string associated with the error returned by
136 * @error : the value of the error
137 * Returns a string on success or NULL otherwise.
139 extern const char *lxc_strerror(int error
);
142 * Checkpoint a container
143 * @name : the name of the container being checkpointed
144 * @statefile: string object on which the container is checkpointed
145 * @flags : checkpoint flags (an ORed value)
146 * Returns 0 on success, < 0 otherwise
148 extern int lxc_checkpoint(const char *name
, const char *statefile
, int flags
);
149 #define LXC_FLAG_PAUSE 1
150 #define LXC_FLAG_HALT 2
153 * Restart a container
154 * @name : the name of the container being restarted
155 * @statefile: string object from which the container is restarted
156 * @rcfile: container configuration file.
157 * @flags : restart flags (an ORed value)
158 * Returns 0 on success, < 0 otherwise
160 extern int lxc_restart(const char *, const char *, const char *, int);
163 * Returns the version number of the library
165 extern const char const *lxc_version(void);