~ubuntu-branches/ubuntu/quantal/lxc/quantal-201208301614

« back to all changes in this revision

Viewing changes to src/lxc/conf.h

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2009-04-29 17:49:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090429174913-jvahs1ykizqtodje
Tags: upstream-0.6.2
ImportĀ upstreamĀ versionĀ 0.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include <sys/param.h>
 
28
 
 
29
enum {
 
30
        EMPTY,
 
31
        VETH,
 
32
        MACVLAN,
 
33
        PHYS,
 
34
        MAXCONFTYPE,
 
35
};
 
36
 
 
37
/*
 
38
 * Defines the structure to configure an ipv4 address
 
39
 * @address   : ipv4 address
 
40
 * @broadcast : ipv4 broadcast address
 
41
 * @mask      : network mask
 
42
 */
 
43
struct lxc_inetdev {
 
44
        struct in_addr addr;
 
45
        struct in_addr bcast;
 
46
        int prefix;
 
47
};
 
48
 
 
49
struct lxc_route {
 
50
        struct in_addr addr;
 
51
};
 
52
 
 
53
/*
 
54
 * Defines the structure to configure an ipv6 address
 
55
 * @flags     : set the address up
 
56
 * @address   : ipv6 address
 
57
 * @broadcast : ipv6 broadcast address
 
58
 * @mask      : network mask
 
59
 */
 
60
struct lxc_inet6dev {
 
61
        struct in6_addr addr;
 
62
        struct in6_addr bcast;
 
63
        struct in6_addr acast;
 
64
        int prefix;
 
65
};
 
66
 
 
67
struct lxc_route6 {
 
68
        struct in6_addr addr;
 
69
};
 
70
/*
 
71
 * Defines a structure to configure a network device
 
72
 * @ifname : network device name
 
73
 * @flags  : flag of the network device (IFF_UP, ... )
 
74
 * @ipv4   : a list of ipv4 addresses to be set on the network device
 
75
 * @ipv6   : a list of ipv6 addresses to be set on the network device
 
76
 */
 
77
struct lxc_netdev {
 
78
        int flags;
 
79
        char *ifname;
 
80
        char *newname;
 
81
        char *hwaddr;
 
82
        char *mtu;
 
83
        struct lxc_list ipv4;
 
84
        struct lxc_list ipv6;
 
85
        struct lxc_list route4;
 
86
        struct lxc_list route6;
 
87
};
 
88
 
 
89
/*
 
90
 * Defines the kind of the network to use
 
91
 * @type : the type of the network virtualization
 
92
 * @phys : phys configuration type
 
93
 * @veth : veth configuration type
 
94
 * @macvlan : macvlan configuration type
 
95
 */
 
96
struct lxc_network {
 
97
        int type;
 
98
        struct lxc_list netdev;
 
99
};
 
100
 
 
101
/*
 
102
 * Defines a generic struct to configure the control group.
 
103
 * It is up to the programmer to specify the right subsystem.
 
104
 * @subsystem : the targetted subsystem
 
105
 * @value     : the value to set
 
106
 */
 
107
struct lxc_cgroup {
 
108
        char *subsystem;
 
109
        char *value;
 
110
};
 
111
 
 
112
/*
 
113
 * Defines the global container configuration
 
114
 * @rootfs  : the root directory to run the container
 
115
 * @mount   : the list of mount points
 
116
 * @network : the network configuration
 
117
 * @utsname : the container utsname
 
118
 */
 
119
struct lxc_conf {
 
120
        char *rootfs;
 
121
        char *fstab;
 
122
        int tty;
 
123
        int pts;
 
124
        struct utsname *utsname;
 
125
        struct lxc_list cgroup;
 
126
        struct lxc_list networks;
 
127
};
 
128
 
 
129
/*
 
130
 * Defines a structure containing a pty information for
 
131
 * virtualizing a tty
 
132
 * @name   : the path name of the slave pty side
 
133
 * @master : the file descriptor of the master
 
134
 * @slave  : the file descriptor of the slave
 
135
 */
 
136
struct lxc_pty_info {
 
137
        char name[MAXPATHLEN];
 
138
        int master;
 
139
        int slave;
 
140
        int busy;
 
141
};
 
142
 
 
143
/*
 
144
 * Defines the number of tty configured and contains the
 
145
 * instanciated ptys
 
146
 * @nbtty = number of configured ttys
 
147
 */
 
148
struct lxc_tty_info {
 
149
        int nbtty;
 
150
        struct lxc_pty_info *pty_info;
 
151
};
 
152
 
 
153
/*
 
154
 * Initialize the lxc configuration structure
 
155
 */
 
156
extern int lxc_conf_init(struct lxc_conf *conf);
 
157
 
 
158
/*
 
159
 * Configure the external resources for the container
 
160
 */
 
161
extern int lxc_configure(const char *name, struct lxc_conf *conf);
 
162
 
 
163
/*
 
164
 * Remove the resources created by the configuration
 
165
 */
 
166
extern int lxc_unconfigure(const char *name);
 
167
 
 
168
extern int conf_create_network(const char *name, pid_t pid);
 
169
 
 
170
extern int conf_destroy_network(const char *name);
 
171
 
 
172
extern int lxc_create_tty(const char *name, struct lxc_tty_info *tty_info);
 
173
extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
 
174
 
 
175
/*
 
176
 * Configure the container from inside
 
177
 */
 
178
extern int lxc_setup(const char *name, const char *tty,
 
179
                     const struct lxc_tty_info *tty_info);
 
180
 
 
181
extern int conf_has(const char *name, const char *info);
 
182
 
 
183
#define conf_has_fstab(__name)   conf_has(__name, "fstab")
 
184
#define conf_has_rootfs(__name)  conf_has(__name, "rootfs")
 
185
#define conf_has_utsname(__name) conf_has(__name, "utsname")
 
186
#define conf_has_network(__name) conf_has(__name, "network")
 
187
#define conf_has_console(__name) conf_has(__name, "console")
 
188
#define conf_has_cgroup(__name)  conf_has(__name, "cgroup")
 
189
#define conf_has_tty(__name)     conf_has(__name, "tty")
 
190
#define conf_has_pts(__name)     conf_has(__name, "pts")
 
191
#endif