]>
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 <daniel.lezcano at free.fr>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32 #include <sys/select.h>
33 #include <sys/types.h>
41 Following code is for liblxc.
43 lxc/lxc.h will contain exports of liblxc
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
54 extern int lxc_start(const char *name
, char *const argv
[], struct lxc_conf
*conf
,
55 const char *lxcpath
, bool backgrounded
);
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
66 extern int lxc_execute(const char *name
, char *const argv
[], int quiet
,
67 struct lxc_conf
*conf
, const char *lxcpath
,
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
75 extern int lxc_monitor_close(int fd
);
78 * Freeze all the tasks running inside the container <name>
79 * @name : the container name
80 * Returns 0 on success, < 0 otherwise
82 extern int lxc_freeze(const char *name
, const char *lxcpath
);
85 * Unfreeze all previously frozen tasks.
86 * @name : the name of the container
87 * Return 0 on success, < 0 otherwise
89 extern int lxc_unfreeze(const char *name
, const char *lxcpath
);
92 * Retrieve the container state
93 * @name : the name of the container
94 * Returns the state of the container on success, < 0 otherwise
96 extern lxc_state_t
lxc_state(const char *name
, const char *lxcpath
);
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
107 extern int lxc_cgroup_set(const char *filename
, const char *value
, const char *name
, const char *lxcpath
);
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
119 extern int lxc_cgroup_get(const char *filename
, char *value
, size_t len
, const char *name
, const char *lxcpath
);
122 * Retrieve the error string associated with the error returned by
124 * @error : the value of the error
125 * Returns a string on success or NULL otherwise.
127 extern const char *lxc_strerror(int error
);
130 * Create and return a new lxccontainer struct.
132 extern struct lxc_container
*lxc_container_new(const char *name
, const char *configpath
);
135 * Returns 1 on success, 0 on failure.
137 extern int lxc_container_get(struct lxc_container
*c
);
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.
145 extern int lxc_container_put(struct lxc_container
*c
);
148 * Get a list of valid wait states.
149 * If states is NULL, simply return the number of states
151 extern int lxc_get_wait_states(const char **states
);
154 * Add a dependency to a container
156 extern int add_rdepend(struct lxc_conf
*lxc_conf
, char *rdepend
);