]>
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>
42 Following code is for liblxc.
44 lxc/lxc.h will contain exports of liblxc
48 * Start the specified command inside a system container
49 * @name : the name of the container
50 * @argv : an array of char * corresponding to the commande line
51 * @conf : configuration
52 * @backgrounded : whether or not the container is daemonized
53 * Returns 0 on success, < 0 otherwise
55 extern int lxc_start(const char *name
, char *const argv
[],
56 struct lxc_handler
*handler
, const char *lxcpath
,
57 bool backgrounded
, int *error_num
);
60 * Start the specified command inside an application container
61 * @name : the name of the container
62 * @argv : an array of char * corresponding to the commande line
63 * @quiet : if != 0 then lxc-init won't produce any output
64 * @conf : configuration
65 * @backgrounded : whether or not the container is daemonized
66 * Returns 0 on success, < 0 otherwise
68 extern int lxc_execute(const char *name
, char *const argv
[], int quiet
,
69 struct lxc_handler
*handler
, const char *lxcpath
,
70 bool backgrounded
, int *error_num
);
73 * Close the fd associated with the monitoring
74 * @fd : the file descriptor provided by lxc_monitor_open
75 * Returns 0 on success, < 0 otherwise
77 extern int lxc_monitor_close(int fd
);
80 * Freeze all the tasks running inside the container <name>
81 * @name : the container name
82 * Returns 0 on success, < 0 otherwise
84 extern int lxc_freeze(const char *name
, const char *lxcpath
);
87 * Unfreeze all previously frozen tasks.
88 * @name : the name of the container
89 * Return 0 on success, < 0 otherwise
91 extern int lxc_unfreeze(const char *name
, const char *lxcpath
);
94 * Retrieve the container state
95 * @name : the name of the container
96 * Returns the state of the container on success, < 0 otherwise
98 extern lxc_state_t
lxc_state(const char *name
, const char *lxcpath
);
101 * Set a specified value for a specified subsystem. The specified
102 * subsystem must be fully specified, eg. "cpu.shares"
103 * @filename : the cgroup attribute filename
104 * @value : the value to be set
105 * @name : the name of the container
106 * @lxcpath : lxc config path for container
107 * Returns 0 on success, < 0 otherwise
109 extern int lxc_cgroup_set(const char *filename
, const char *value
, const char *name
, const char *lxcpath
);
112 * Get a specified value for a specified subsystem. The specified
113 * subsystem must be fully specified, eg. "cpu.shares"
114 * @filename : the cgroup attribute filename
115 * @value : the value to be set
116 * @len : the len of the value variable
117 * @name : the name of the container
118 * @lxcpath : lxc config path for container
119 * Returns the number of bytes read, < 0 on error
121 extern int lxc_cgroup_get(const char *filename
, char *value
, size_t len
, const char *name
, const char *lxcpath
);
124 * Create and return a new lxccontainer struct.
126 extern struct lxc_container
*lxc_container_new(const char *name
, const char *configpath
);
129 * Returns 1 on success, 0 on failure.
131 extern int lxc_container_get(struct lxc_container
*c
);
134 * Put a lxccontainer struct reference.
135 * Return -1 on error.
136 * Return 0 if this was not the last reference.
137 * If it is the last reference, free the lxccontainer and return 1.
139 extern int lxc_container_put(struct lxc_container
*c
);
142 * Get a list of valid wait states.
143 * If states is NULL, simply return the number of states
145 extern int lxc_get_wait_states(const char **states
);
148 * Add a dependency to a container
150 extern int add_rdepend(struct lxc_conf
*lxc_conf
, char *rdepend
);
153 * Set a key/value configuration option. Requires that to take a lock on the
154 * in-memory config of the container.
156 extern int lxc_set_config_item_locked(struct lxc_conf
*conf
, const char *key
,