]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/start.h
2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
8 * Serge Hallyn <serge@hallyn.com>
9 * Christian Brauner <christian.brauner@ubuntu.com>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <sys/param.h>
31 #include <sys/socket.h>
35 #include "namespace.h"
39 /* Record the clone for namespaces flags that the container requested.
42 * - All clone flags that were requested.
45 * - The clone flags for namespaces to actually use when calling
46 * lxc_clone(): After the container has started ns_on_clone_flags will
47 * list the clone flags that were unshare()ed rather then clone()ed
48 * because of ordering requirements (e.g. e.g. CLONE_NEWNET and
49 * CLONE_NEWUSER) or implementation details.
52 * - The clone flags for the namespaces that the container will inherit
53 * from the parent. They are not recorded in the handler itself but
54 * are present in the container's config.
57 * - The clone flags for the namespaces that the container will share
58 * with another process. They are not recorded in the handler itself
59 * but are present in the container's config.
63 int ns_on_clone_flags
;
66 /* File descriptor to pin the rootfs for privileged containers. */
69 /* Signal file descriptor. */
72 /* List of file descriptors referring to the namespaces of the
73 * container. Note that these are not necessarily identical to
74 * the "clone_flags" handler field in case namespace inheritance is
79 /* Abstract unix domain SOCK_DGRAM socketpair to pass arbitrary data
80 * between child and parent.
84 /* The socketpair() fds used to wait on successful daemonized startup. */
85 int state_socket_pair
[2];
87 /* Socketpair to synchronize processes during container creation. */
90 /* Pointer to the name of the container. Do not free! */
93 /* Pointer to the path the container. Do not free! */
96 /* Whether the container's startup process euid is 0. */
99 /* Indicates whether should we close std{in,out,err} on start. */
102 /* The child's pid. */
105 /* Whether the child has already exited. */
108 /* The signal mask prior to setting up the signal file descriptor. */
111 /* The container's in-memory configuration. */
112 struct lxc_conf
*conf
;
114 /* A set of operations to be performed at various stages of the
117 struct lxc_operations
*ops
;
119 /* This holds the cgroup information. Note that the data here is
120 * specific to the cgroup driver used.
124 /* Data to be passed to handler ops. */
127 /* Current state of the container. */
130 /* The exit status of the container; not defined unless ->init_died ==
135 struct cgroup_ops
*cgroup_ops
;
138 struct execute_args
{
145 struct lxc_operations
{
146 int (*start
)(struct lxc_handler
*, void *);
147 int (*post_start
)(struct lxc_handler
*, void *);
150 extern int lxc_poll(const char *name
, struct lxc_handler
*handler
);
151 extern int lxc_set_state(const char *name
, struct lxc_handler
*handler
,
153 extern int lxc_serve_state_clients(const char *name
,
154 struct lxc_handler
*handler
,
156 extern void lxc_abort(const char *name
, struct lxc_handler
*handler
);
157 extern struct lxc_handler
*lxc_init_handler(const char *name
,
158 struct lxc_conf
*conf
,
161 extern void lxc_zero_handler(struct lxc_handler
*handler
);
162 extern void lxc_free_handler(struct lxc_handler
*handler
);
163 extern int lxc_init(const char *name
, struct lxc_handler
*handler
);
164 extern void lxc_fini(const char *name
, struct lxc_handler
*handler
);
166 /* lxc_check_inherited: Check for any open file descriptors and close them if
168 * @param[in] conf The container's configuration.
169 * @param[in] closeall Whether we should close all open file descriptors.
170 * @param[in] fds_to_ignore Array of file descriptors to ignore.
171 * @param[in] len_fds Length of fds_to_ignore array.
173 extern int lxc_check_inherited(struct lxc_conf
*conf
, bool closeall
,
174 int *fds_to_ignore
, size_t len_fds
);
175 extern int __lxc_start(const char *, struct lxc_handler
*,
176 struct lxc_operations
*, void *, const char *, bool,
179 extern int resolve_clone_flags(struct lxc_handler
*handler
);