]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/start.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
9 #include <sys/socket.h>
13 #include "namespace.h"
17 /* Record the clone for namespaces flags that the container requested.
20 * - All clone flags that were requested.
23 * - The clone flags for namespaces to actually use when calling
24 * lxc_clone(): After the container has started ns_on_clone_flags will
25 * list the clone flags that were unshare()ed rather then clone()ed
26 * because of ordering requirements (e.g. e.g. CLONE_NEWNET and
27 * CLONE_NEWUSER) or implementation details.
30 * - The clone flags for the namespaces that the container will inherit
31 * from the parent. They are not recorded in the handler itself but
32 * are present in the container's config.
35 * - The clone flags for the namespaces that the container will share
36 * with another process. They are not recorded in the handler itself
37 * but are present in the container's config.
41 int ns_on_clone_flags
;
44 /* File descriptor to pin the rootfs for privileged containers. */
47 /* Signal file descriptor. */
50 /* List of file descriptors referring to the namespaces of the
51 * container. Note that these are not necessarily identical to
52 * the "clone_flags" handler field in case namespace inheritance is
57 /* Abstract unix domain SOCK_DGRAM socketpair to pass arbitrary data
58 * between child and parent.
62 /* The socketpair() fds used to wait on successful daemonized startup. */
63 int state_socket_pair
[2];
65 /* Socketpair to synchronize processes during container creation. */
68 /* Pointer to the name of the container. Do not free! */
71 /* Pointer to the path the container. Do not free! */
74 /* Whether the container's startup process euid is 0. */
77 /* Indicates whether should we close std{in,out,err} on start. */
80 /* The child's pid. */
83 /* The child's pidfd. */
86 /* The grandfather's pid when double-forking. */
89 /* The monitor's pid. */
92 int monitor_status_fd
;
94 /* Whether the child has already exited. */
97 /* The signal mask prior to setting up the signal file descriptor. */
100 /* The container's in-memory configuration. */
101 struct lxc_conf
*conf
;
103 /* A set of operations to be performed at various stages of the
106 struct lxc_operations
*ops
;
108 /* This holds the cgroup information. Note that the data here is
109 * specific to the cgroup driver used.
113 /* Data to be passed to handler ops. */
116 /* Current state of the container. */
119 /* The exit status of the container; not defined unless ->init_died ==
124 struct cgroup_ops
*cgroup_ops
;
127 struct execute_args
{
134 struct lxc_operations
{
135 int (*start
)(struct lxc_handler
*, void *);
136 int (*post_start
)(struct lxc_handler
*, void *);
139 extern int lxc_poll(const char *name
, struct lxc_handler
*handler
);
140 extern int lxc_set_state(const char *name
, struct lxc_handler
*handler
,
142 extern int lxc_serve_state_clients(const char *name
,
143 struct lxc_handler
*handler
,
145 extern void lxc_abort(struct lxc_handler
*handler
);
146 extern struct lxc_handler
*lxc_init_handler(const char *name
,
147 struct lxc_conf
*conf
,
150 extern void lxc_zero_handler(struct lxc_handler
*handler
);
151 extern void lxc_free_handler(struct lxc_handler
*handler
);
152 extern int lxc_init(const char *name
, struct lxc_handler
*handler
);
153 extern void lxc_fini(struct lxc_handler
*handler
);
155 /* lxc_check_inherited: Check for any open file descriptors and close them if
157 * @param[in] conf The container's configuration.
158 * @param[in] closeall Whether we should close all open file descriptors.
159 * @param[in] fds_to_ignore Array of file descriptors to ignore.
160 * @param[in] len_fds Length of fds_to_ignore array.
162 extern int lxc_check_inherited(struct lxc_conf
*conf
, bool closeall
,
163 int *fds_to_ignore
, size_t len_fds
);
164 extern int __lxc_start(struct lxc_handler
*, struct lxc_operations
*, void *,
165 const char *, bool, int *);
167 extern int resolve_clone_flags(struct lxc_handler
*handler
);