~gary/ubuntu/precise/lxc/bug-951150

« back to all changes in this revision

Viewing changes to .pc/0042-close-fds.patch/src/lxc/conf.h

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2012-02-13 14:03:25 UTC
  • Revision ID: package-import@ubuntu.com-20120213140325-z5dzhgngpptkrrfs
Tags: 0.7.5-3ubuntu25
0042-close-fds.patch: add a new --close-all-fds option.  Normally if
lxc-start is started with an open fd, it exits with failiure.  With
this option specified, the fds will be closed and startup will continue.
--daemon now implies --close-all-fds.  (LP: #931220)

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
#include <lxc/list.h>
 
30
 
 
31
#include <lxc/start.h> /* for lxc_handler */
 
32
 
 
33
enum {
 
34
        LXC_NET_EMPTY,
 
35
        LXC_NET_VETH,
 
36
        LXC_NET_MACVLAN,
 
37
        LXC_NET_PHYS,
 
38
        LXC_NET_VLAN,
 
39
        LXC_NET_MAXCONFTYPE,
 
40
};
 
41
 
 
42
/*
 
43
 * Defines the structure to configure an ipv4 address
 
44
 * @address   : ipv4 address
 
45
 * @broadcast : ipv4 broadcast address
 
46
 * @mask      : network mask
 
47
 */
 
48
struct lxc_inetdev {
 
49
        struct in_addr addr;
 
50
        struct in_addr bcast;
 
51
        int prefix;
 
52
};
 
53
 
 
54
struct lxc_route {
 
55
        struct in_addr addr;
 
56
};
 
57
 
 
58
/*
 
59
 * Defines the structure to configure an ipv6 address
 
60
 * @flags     : set the address up
 
61
 * @address   : ipv6 address
 
62
 * @broadcast : ipv6 broadcast address
 
63
 * @mask      : network mask
 
64
 */
 
65
struct lxc_inet6dev {
 
66
        struct in6_addr addr;
 
67
        struct in6_addr mcast;
 
68
        struct in6_addr acast;
 
69
        int prefix;
 
70
};
 
71
 
 
72
struct lxc_route6 {
 
73
        struct in6_addr addr;
 
74
};
 
75
 
 
76
struct ifla_veth {
 
77
        char *pair; /* pair name */
 
78
};
 
79
 
 
80
struct ifla_vlan {
 
81
        uint   flags;
 
82
        uint   fmask;
 
83
        ushort   vid;
 
84
        ushort   pad;
 
85
};
 
86
 
 
87
struct ifla_macvlan {
 
88
        int mode; /* private, vepa, bridge */
 
89
};
 
90
 
 
91
union netdev_p {
 
92
        struct ifla_veth veth_attr;
 
93
        struct ifla_vlan vlan_attr;
 
94
        struct ifla_macvlan macvlan_attr;
 
95
};
 
96
 
 
97
/*
 
98
 * Defines a structure to configure a network device
 
99
 * @link       : lxc.network.link, name of bridge or host iface to attach if any
 
100
 * @name       : lxc.network.name, name of iface on the container side
 
101
 * @flags      : flag of the network device (IFF_UP, ... )
 
102
 * @ipv4       : a list of ipv4 addresses to be set on the network device
 
103
 * @ipv6       : a list of ipv6 addresses to be set on the network device
 
104
 * @upscript   : a script filename to be executed during interface configuration
 
105
 */
 
106
struct lxc_netdev {
 
107
        int type;
 
108
        int flags;
 
109
        int ifindex;
 
110
        char *link;
 
111
        char *name;
 
112
        char *hwaddr;
 
113
        char *mtu;
 
114
        union netdev_p priv;
 
115
        struct lxc_list ipv4;
 
116
        struct lxc_list ipv6;
 
117
        char *upscript;
 
118
};
 
119
 
 
120
/*
 
121
 * Defines a generic struct to configure the control group.
 
122
 * It is up to the programmer to specify the right subsystem.
 
123
 * @subsystem : the targetted subsystem
 
124
 * @value     : the value to set
 
125
 */
 
126
struct lxc_cgroup {
 
127
        char *subsystem;
 
128
        char *value;
 
129
};
 
130
 
 
131
/*
 
132
 * Defines a structure containing a pty information for
 
133
 * virtualizing a tty
 
134
 * @name   : the path name of the slave pty side
 
135
 * @master : the file descriptor of the master
 
136
 * @slave  : the file descriptor of the slave
 
137
 */
 
138
struct lxc_pty_info {
 
139
        char name[MAXPATHLEN];
 
140
        int master;
 
141
        int slave;
 
142
        int busy;
 
143
};
 
144
 
 
145
/*
 
146
 * Defines the number of tty configured and contains the
 
147
 * instanciated ptys
 
148
 * @nbtty = number of configured ttys
 
149
 */
 
150
struct lxc_tty_info {
 
151
        int nbtty;
 
152
        struct lxc_pty_info *pty_info;
 
153
};
 
154
 
 
155
/*
 
156
 * Defines the structure to store the console information
 
157
 * @peer   : the file descriptor put/get console traffic
 
158
 * @name   : the file name of the slave pty
 
159
 */
 
160
struct lxc_console {
 
161
        int slave;
 
162
        int master;
 
163
        int peer;
 
164
        char *path;
 
165
        char name[MAXPATHLEN];
 
166
        struct termios *tios;
 
167
};
 
168
 
 
169
/*
 
170
 * Defines a structure to store the rootfs location, the
 
171
 * optionals pivot_root, rootfs mount paths
 
172
 * @rootfs     : a path to the rootfs
 
173
 * @pivot_root : a path to a pivot_root location to be used
 
174
 */
 
175
struct lxc_rootfs {
 
176
        char *path;
 
177
        char *mount;
 
178
        char *pivot;
 
179
};
 
180
 
 
181
/*
 
182
 * Defines the global container configuration
 
183
 * @rootfs     : root directory to run the container
 
184
 * @pivotdir   : pivotdir path, if not set default will be used
 
185
 * @mount      : list of mount points
 
186
 * @tty        : numbers of tty
 
187
 * @pts        : new pts instance
 
188
 * @mount_list : list of mount point (alternative to fstab file)
 
189
 * @network    : network configuration
 
190
 * @utsname    : container utsname
 
191
 * @fstab      : path to a fstab file format
 
192
 * @caps       : list of the capabilities
 
193
 * @tty_info   : tty data
 
194
 * @console    : console data
 
195
 * @ttydir     : directory (under /dev) in which to create console and ttys
 
196
 */
 
197
struct lxc_conf {
 
198
        char *fstab;
 
199
        int tty;
 
200
        int pts;
 
201
        int reboot;
 
202
        int need_utmp_watch;
 
203
        int personality;
 
204
        struct utsname *utsname;
 
205
        struct lxc_list cgroup;
 
206
        struct lxc_list network;
 
207
        struct lxc_list mount_list;
 
208
        struct lxc_list caps;
 
209
        struct lxc_tty_info tty_info;
 
210
        struct lxc_console console;
 
211
        struct lxc_rootfs rootfs;
 
212
        char *ttydir;
 
213
};
 
214
 
 
215
/*
 
216
 * Initialize the lxc configuration structure
 
217
 */
 
218
extern struct lxc_conf *lxc_conf_init(void);
 
219
 
 
220
extern int lxc_create_network(struct lxc_handler *handler);
 
221
extern void lxc_delete_network(struct lxc_list *networks);
 
222
extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
 
223
 
 
224
extern int lxc_create_tty(const char *name, struct lxc_conf *conf);
 
225
extern void lxc_delete_tty(struct lxc_tty_info *tty_info);
 
226
 
 
227
/*
 
228
 * Configure the container from inside
 
229
 */
 
230
 
 
231
extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf);
 
232
#endif