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
26 #include <netinet/in.h>
27 #include <sys/param.h>
32 #include <lxc/start.h> /* for lxc_handler */
44 * Defines the structure to configure an ipv4 address
45 * @address : ipv4 address
46 * @broadcast : ipv4 broadcast address
47 * @mask : network mask
60 * Defines the structure to configure an ipv6 address
61 * @flags : set the address up
62 * @address : ipv6 address
63 * @broadcast : ipv6 broadcast address
64 * @mask : network mask
68 struct in6_addr mcast
;
69 struct in6_addr acast
;
78 char *pair
; /* pair name */
89 int mode
; /* private, vepa, bridge */
93 struct ifla_veth veth_attr
;
94 struct ifla_vlan vlan_attr
;
95 struct ifla_macvlan macvlan_attr
;
99 * Defines a structure to configure a network device
100 * @link : lxc.network.link, name of bridge or host iface to attach if any
101 * @name : lxc.network.name, name of iface on the container side
102 * @flags : flag of the network device (IFF_UP, ... )
103 * @ipv4 : a list of ipv4 addresses to be set on the network device
104 * @ipv6 : a list of ipv6 addresses to be set on the network device
105 * @upscript : a script filename to be executed during interface configuration
116 struct lxc_list ipv4
;
117 struct lxc_list ipv6
;
118 struct in_addr
*ipv4_gateway
;
119 bool ipv4_gateway_auto
;
120 struct in6_addr
*ipv6_gateway
;
121 bool ipv6_gateway_auto
;
126 * Defines a generic struct to configure the control group.
127 * It is up to the programmer to specify the right subsystem.
128 * @subsystem : the targetted subsystem
129 * @value : the value to set
137 * Defines a structure containing a pty information for
139 * @name : the path name of the slave pty side
140 * @master : the file descriptor of the master
141 * @slave : the file descriptor of the slave
143 struct lxc_pty_info
{
144 char name
[MAXPATHLEN
];
151 * Defines the number of tty configured and contains the
153 * @nbtty = number of configured ttys
155 struct lxc_tty_info
{
157 struct lxc_pty_info
*pty_info
;
161 * Defines the structure to store the console information
162 * @peer : the file descriptor put/get console traffic
163 * @name : the file name of the slave pty
170 char name
[MAXPATHLEN
];
171 struct termios
*tios
;
175 * Defines a structure to store the rootfs location, the
176 * optionals pivot_root, rootfs mount paths
177 * @rootfs : a path to the rootfs
178 * @pivot_root : a path to a pivot_root location to be used
187 * Defines the global container configuration
188 * @rootfs : root directory to run the container
189 * @pivotdir : pivotdir path, if not set default will be used
190 * @mount : list of mount points
191 * @tty : numbers of tty
192 * @pts : new pts instance
193 * @mount_list : list of mount point (alternative to fstab file)
194 * @network : network configuration
195 * @utsname : container utsname
196 * @fstab : path to a fstab file format
197 * @caps : list of the capabilities
198 * @tty_info : tty data
199 * @console : console data
200 * @ttydir : directory (under /dev) in which to create console and ttys
209 struct utsname
*utsname
;
210 struct lxc_list cgroup
;
211 struct lxc_list network
;
212 struct lxc_list mount_list
;
213 struct lxc_list caps
;
214 struct lxc_tty_info tty_info
;
215 struct lxc_console console
;
216 struct lxc_rootfs rootfs
;
222 * Initialize the lxc configuration structure
224 extern struct lxc_conf
*lxc_conf_init(void);
226 extern int pin_rootfs(const char *rootfs
);
228 extern int lxc_create_network(struct lxc_handler
*handler
);
229 extern void lxc_delete_network(struct lxc_list
*networks
);
230 extern int lxc_assign_network(struct lxc_list
*networks
, pid_t pid
);
231 extern int lxc_find_gateway_addresses(struct lxc_handler
*handler
);
233 extern int lxc_create_tty(const char *name
, struct lxc_conf
*conf
);
234 extern void lxc_delete_tty(struct lxc_tty_info
*tty_info
);
237 * Configure the container from inside
240 extern int lxc_setup(const char *name
, struct lxc_conf
*lxc_conf
);