message: Add rlimits to manifest
diff: @@ -73,6 +73,8 @@ pub struct Manifest {
  pub capabilities: Option<HashSet<Capability>>,
  /// String containing group names to give to new container
  pub suppl_groups: Option<Vec<NonNullString>>,
  + /// Resource limits
  + pub rlimits: Option<HashMap<RLimitResource, RLimitValue>>,
  /// IO configuration
  pub io: Option<Io>,
  /// Optional custom data. The runtime doesnt use this.
  @@ -324,6 +326,65 @@ pub enum Output {
  Log { level: log::Level, tag: String },
  }
  +/// Resource limits. See setrlimit(2)
  +#[derive(Clone, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)]
  +#[serde(rename_all(serialize = "lowercase", deserialize = "lowercase"))]
  +pub enum RLimitResource {
  + /// Address space
  + AS,
  + /// Maximum size of core file
  + CORE,
  + /// CPU time limit in seconds
  + CPU,
  + /// The maximum size of the process's data segment (initialized data,
  + /// uninitialized data, and heap).
  + DATA,
  + /// The maximum size of files that the process may create
  + FSIZE,
  + /// A limit on the combined number of flock(2) locks and fcntl(2) leases that
  + /// this process may establish.
  + LOCKS,
  + /// The maximum number of bytes of memory that may be locked into RAM
  + MEMLOCK,
  + /// Specifies the limit on the number of bytes that can be allocated for
  + /// POSIX message queues for the real user ID of the calling process
  + MSGQUEUE,
  + /// Specifies a ceiling to which the process's nice value can be raised using
  + /// setpriority(2) or nice(2)
  + NICE,
  + /// Specifies a value one greater than the maximum file descriptor number
  + /// that can be opened by this process
  + NOFILE,
  + /// The maximum number of processes (or, more precisely on Linux, threads)
  + /// that can be created for the real user ID of the calling process
  + NPROC,
  + /// Specifies the limit (in pages) of the process's resident set (the number
  + /// of virtual pages resident in RAM)
  + RSS,
  + /// Specifies a ceiling on the real-time priority that may be set for this
  + /// process using sched_setscheduler(2) and sched_setparam(2).
  + RTPRIO,
  + /// Specifies a limit (in microseconds) on the amount of CPU time that a
  + /// process scheduled under a real-time scheduling policy may consume without
  + /// making a blocking system call
  + #[cfg(not(target_os = "android"))]
  + RTTIME,
  + /// Specifies the limit on the number of signals that may be queued for the
  + /// real user ID of the calling process
  + SIGPENDING,
  + /// The maximum size of the process stack, in bytes. Upon reaching this
  + /// limit, a SIGSEGV signal is generated
  + STACK,
  +}
  +
  +#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
  +pub struct RLimitValue {
  + /// Soft limit value for resource. None indicates `unlimited`.
  + pub soft: Option<u64>,
  + /// Hard limit value for resource. None indicates `unlimited`.
  + pub hard: Option<u64>,
  +}
  +
  mod mount_options {
  use super::{MountOption, MountOptions};
  use itertools::Itertools;
  @@ -489,6 +550,10 @@ capabilities:
  - CAP_NET_RAW
  - CAP_MKNOD
  - CAP_SYS_TIME
  +rlimits:
  + nproc:
  + soft: 1000
  + hard: 1000
  mounts:
  /dev:
  type: dev
  @@ -762,6 +827,10 @@ mounts:
  type: tmpfs
  size: 42
  autostart: relaxed
  +rlimits:
  + nproc:
  + soft: 100
  + hard: 1000
  cgroups:
  memory:
  limit_in_bytes: 30
  