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