Skip to main content

libcontainer/process/
args.rs

1use std::os::unix::prelude::RawFd;
2use std::path::PathBuf;
3use std::rc::Rc;
4
5use libcgroups::common::CgroupConfig;
6use nix::unistd::Pid;
7use oci_spec::runtime::Spec;
8
9use crate::container::Container;
10use crate::notify_socket::NotifyListener;
11use crate::syscall::syscall::SyscallType;
12use crate::user_ns::UserNamespaceConfig;
13use crate::workload::Executor;
14#[derive(Debug, Copy, Clone)]
15pub enum ContainerType {
16    InitContainer,
17    TenantContainer {
18        exec_notify_fd: RawFd,
19        /// PID of the init process in the landlord container
20        /// (the container that tenant containers are attached to)
21        landlord_init_pid: Option<Pid>,
22    },
23}
24
25#[derive(Clone)]
26pub struct ContainerArgs {
27    /// Indicates if an init or a tenant container should be created
28    pub container_type: ContainerType,
29    /// Interface to operating system primitives
30    pub syscall: SyscallType,
31    /// OCI compliant runtime spec
32    pub spec: Rc<Spec>,
33    /// Root filesystem of the container
34    pub rootfs: PathBuf,
35    /// Socket to communicate the file descriptor of the ptty
36    pub console_socket: Option<RawFd>,
37    /// The Unix Domain Socket to communicate container start
38    pub notify_listener: NotifyListener,
39    /// File descriptors preserved/passed to the container init process.
40    pub preserve_fds: i32,
41    /// Container state
42    pub container: Option<Container>,
43    /// Options for new namespace creation
44    pub user_ns_config: Option<UserNamespaceConfig>,
45    /// Cgroup Manager Config
46    pub cgroup_config: CgroupConfig,
47    /// If the container is to be run in detached mode
48    pub detached: bool,
49    /// Manage the functions that actually run on the container
50    pub executor: Box<dyn Executor>,
51    /// If do not use pivot root to jail process inside rootfs
52    pub no_pivot: bool,
53    // RawFd set to stdin of the container init process.
54    pub stdin: Option<RawFd>,
55    // RawFd set to stdout of the container init process.
56    pub stdout: Option<RawFd>,
57    // RawFd set to stderr of the container init process.
58    pub stderr: Option<RawFd>,
59    // Indicate if the init process should be a sibling of the main process.
60    pub as_sibling: bool,
61    /// File path used to communicate the PID of the
62    /// container process to the higher-level runtime.
63    pub pid_file: Option<PathBuf>,
64}