]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/lxc_conf.h
Add cgroup support, the configuration file should be specified with the format:
[mirror_lxc.git] / src / lxc / lxc_conf.h
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>
27
28 enum {
29 EMPTY,
30 VETH,
31 MACVLAN,
32 PHYS,
33 MAXCONFTYPE,
34 };
35
36 /*
37 * Defines the structure to configure an ipv4 address
38 * @address : ipv4 address
39 * @broadcast : ipv4 broadcast address
40 * @mask : network mask
41 */
42 struct lxc_inetdev {
43 struct in_addr addr;
44 struct in_addr bcast;
45 int prefix;
46 };
47
48 struct lxc_route {
49 struct in_addr addr;
50 };
51
52 /*
53 * Defines the structure to configure an ipv6 address
54 * @flags : set the address up
55 * @address : ipv6 address
56 * @broadcast : ipv6 broadcast address
57 * @mask : network mask
58 */
59 struct lxc_inet6dev {
60 struct in6_addr addr;
61 struct in6_addr bcast;
62 struct in6_addr acast;
63 int prefix;
64 };
65
66 struct lxc_route6 {
67 struct in6_addr addr;
68 };
69 /*
70 * Defines a structure to configure a network device
71 * @ifname : network device name
72 * @flags : flag of the network device (IFF_UP, ... )
73 * @ipv4 : a list of ipv4 addresses to be set on the network device
74 * @ipv6 : a list of ipv6 addresses to be set on the network device
75 */
76 struct lxc_netdev {
77 int flags;
78 char *ifname;
79 char *newname;
80 char *hwaddr;
81 struct lxc_list ipv4;
82 struct lxc_list ipv6;
83 struct lxc_list route4;
84 struct lxc_list route6;
85 };
86
87 /*
88 * Defines the kind of the network to use
89 * @type : the type of the network virtualization
90 * @phys : phys configuration type
91 * @veth : veth configuration type
92 * @macvlan : macvlan configuration type
93 */
94 struct lxc_network {
95 int type;
96 struct lxc_list netdev;
97 };
98
99 /*
100 * Defines a generic struct to configure the control group.
101 * It is up to the programmer to specify the right subsystem.
102 * @subsystem : the targetted subsystem
103 * @value : the value to set
104 */
105 struct lxc_cgroup {
106 char *subsystem;
107 char *value;
108 };
109
110 /*
111 * Defines the global container configuration
112 * @rootfs : the root directory to run the container
113 * @mount : the list of mount points
114 * @network : the network configuration
115 * @utsname : the container utsname
116 */
117 struct lxc_conf {
118 char *rootfs;
119 char *fstab;
120 struct utsname *utsname;
121 struct lxc_list cgroup;
122 struct lxc_list networks;
123 };
124
125 /*
126 * Configure the external resources for the container
127 */
128 extern int lxc_configure(const char *name, struct lxc_conf *conf);
129
130 /*
131 * Remove the resources created by the configuration
132 */
133 extern int lxc_unconfigure(const char *name);
134
135 extern int conf_create_network(const char *name, pid_t pid);
136
137 extern int conf_destroy_network(const char *name);
138
139 /*
140 * Configure the container from inside
141 */
142 extern int lxc_setup(const char *name);
143
144 extern int conf_has(const char *name, const char *info);
145
146 #define conf_has_fstab(__name) conf_has(__name, "fstab")
147 #define conf_has_rootfs(__name) conf_has(__name, "rootfs")
148 #define conf_has_utsname(__name) conf_has(__name, "utsname")
149 #define conf_has_network(__name) conf_has(__name, "network")
150 #define conf_has_cgroup(__name) conf_has(__name, "cgroup")
151
152 #endif