]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/conf.h
shutdown the container when powering off the container
[mirror_lxc.git] / src / lxc / conf.h
CommitLineData
0ad19a3f 1/*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2008
5 *
6 * Authors:
7 * Daniel Lezcano <dlezcano at fr.ibm.com>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23#ifndef _conf_h
24#define _conf_h
25
26#include <netinet/in.h>
b0a33c1e 27#include <sys/param.h>
0ad19a3f 28
00b3c2e2
CLG
29#include <lxc/list.h>
30
13954cce 31enum {
24654103
DL
32 LXC_NET_EMPTY,
33 LXC_NET_VETH,
34 LXC_NET_MACVLAN,
35 LXC_NET_PHYS,
36 LXC_NET_VLAN,
37 LXC_NET_MAXCONFTYPE,
0ad19a3f 38};
39
40/*
41 * Defines the structure to configure an ipv4 address
42 * @address : ipv4 address
43 * @broadcast : ipv4 broadcast address
44 * @mask : network mask
45 */
46struct lxc_inetdev {
47 struct in_addr addr;
48 struct in_addr bcast;
49 int prefix;
50};
51
52struct lxc_route {
53 struct in_addr addr;
54};
55
56/*
57 * Defines the structure to configure an ipv6 address
58 * @flags : set the address up
59 * @address : ipv6 address
60 * @broadcast : ipv6 broadcast address
61 * @mask : network mask
62 */
63struct lxc_inet6dev {
64 struct in6_addr addr;
65 struct in6_addr bcast;
66 struct in6_addr acast;
67 int prefix;
68};
69
70struct lxc_route6 {
71 struct in6_addr addr;
72};
26c39028 73
e892973e
DL
74struct ifla_veth {
75 char *pair; /* pair name */
76};
77
26c39028
JHS
78struct ifla_vlan {
79 uint flags;
80 uint fmask;
81 ushort vid;
82 ushort pad;
83};
84
e892973e
DL
85struct ifla_macvlan {
86 int mode; /* private, vepa, bridge */
87};
88
f6cc1de1 89union netdev_p {
e892973e 90 struct ifla_veth veth_attr;
f6cc1de1 91 struct ifla_vlan vlan_attr;
e892973e 92 struct ifla_macvlan macvlan_attr;
f6cc1de1
JHS
93};
94
0ad19a3f 95/*
96 * Defines a structure to configure a network device
9d083402
MT
97 * @link : lxc.network.link, name of bridge or host iface to attach if any
98 * @name : lxc.network.name, name of iface on the container side
0ad19a3f 99 * @flags : flag of the network device (IFF_UP, ... )
100 * @ipv4 : a list of ipv4 addresses to be set on the network device
101 * @ipv6 : a list of ipv6 addresses to be set on the network device
102 */
103struct lxc_netdev {
5f4535a3 104 int type;
0ad19a3f 105 int flags;
82d5ae15 106 int ifindex;
9d083402
MT
107 char *link;
108 char *name;
0ad19a3f 109 char *hwaddr;
442cbbe6 110 char *mtu;
f6cc1de1 111 union netdev_p priv;
0ad19a3f 112 struct lxc_list ipv4;
113 struct lxc_list ipv6;
0ad19a3f 114};
115
116/*
576f946d 117 * Defines a generic struct to configure the control group.
118 * It is up to the programmer to specify the right subsystem.
119 * @subsystem : the targetted subsystem
120 * @value : the value to set
0ad19a3f 121 */
122struct lxc_cgroup {
576f946d 123 char *subsystem;
124 char *value;
0ad19a3f 125};
126
b0a33c1e 127/*
128 * Defines a structure containing a pty information for
129 * virtualizing a tty
130 * @name : the path name of the slave pty side
131 * @master : the file descriptor of the master
132 * @slave : the file descriptor of the slave
133 */
134struct lxc_pty_info {
135 char name[MAXPATHLEN];
136 int master;
137 int slave;
138 int busy;
139};
140
141/*
142 * Defines the number of tty configured and contains the
143 * instanciated ptys
144 * @nbtty = number of configured ttys
145 */
146struct lxc_tty_info {
147 int nbtty;
148 struct lxc_pty_info *pty_info;
149};
150
63376d7d
DL
151/*
152 * Defines the structure to store the console information
153 * @peer : the file descriptor put/get console traffic
154 * @name : the file name of the slave pty
155 */
156struct lxc_console {
157 int slave;
158 int master;
159 int peer;
28a4b0e5 160 char *path;
63376d7d 161 char name[MAXPATHLEN];
e0dc0de7 162 struct termios *tios;
63376d7d
DL
163};
164
571e6ec8
DL
165/*
166 * Defines the global container configuration
63376d7d
DL
167 * @rootfs : root directory to run the container
168 * @pivotdir : pivotdir path, if not set default will be used
169 * @mount : list of mount points
170 * @tty : numbers of tty
171 * @pts : new pts instance
172 * @mount_list : list of mount point (alternative to fstab file)
173 * @network : network configuration
174 * @utsname : container utsname
175 * @fstab : path to a fstab file format
176 * @caps : list of the capabilities
177 * @tty_info : tty data
178 * @console : console data
571e6ec8
DL
179 */
180struct lxc_conf {
571e6ec8 181 char *rootfs;
bf601689 182 char *pivotdir;
571e6ec8
DL
183 char *fstab;
184 int tty;
185 int pts;
186 struct utsname *utsname;
187 struct lxc_list cgroup;
5f4535a3 188 struct lxc_list network;
e7938e9e 189 struct lxc_list mount_list;
81810dd1 190 struct lxc_list caps;
571e6ec8 191 struct lxc_tty_info tty_info;
63376d7d 192 struct lxc_console console;
571e6ec8
DL
193};
194
089cd8b8
DL
195/*
196 * Initialize the lxc configuration structure
197 */
7b379ab3 198extern struct lxc_conf *lxc_conf_init(void);
089cd8b8 199
82d5ae15 200extern int lxc_create_network(struct lxc_list *networks);
7fef7a06 201extern void lxc_delete_network(struct lxc_list *networks);
82d5ae15 202extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
0ad19a3f 203
5e4a62bf 204extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
b0a33c1e 205extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
206
0ad19a3f 207/*
208 * Configure the container from inside
209 */
88d5514d
DL
210
211struct lxc_handler;
212
571e6ec8 213extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
0ad19a3f 214
0ad19a3f 215#endif