1
0
mirror of https://github.com/containers/youki synced 2024-11-23 09:21:57 +01:00

merge with main

This commit is contained in:
yukang 2021-10-23 22:23:03 +08:00
commit 1999644f1b
158 changed files with 426 additions and 341 deletions

@ -17,7 +17,7 @@ jobs:
id: filter
with:
filters: |
./youki_integration_test: youki_integration_test/**
./integration_test: crates/integration_test/**
validate:
needs: [changes]
if: ${{ !contains(needs.changes.outputs.dirs, '[]') }}
@ -33,13 +33,9 @@ jobs:
override: true
- name: Cache youki
uses: Swatinem/rust-cache@v1
- name: Cache tests
uses: Swatinem/rust-cache@v1
with:
working-directory: ./youki_integration_test
- run: sudo apt-get -y update
- run: sudo apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev
- name: Validate tests on runc
run: cd ./youki_integration_test && ./run_tests.sh runc
run: cd ./crates/integration_test && ./run_tests.sh runc
- name: Validate tests on youki
run: cd ./youki_integration_test && ./run_tests.sh ./youki
run: cd ./crates/integration_test && ./run_tests.sh ./youki

@ -17,10 +17,11 @@ jobs:
id: filter
with:
filters: |
.: src/**
./youki_integration_test: youki_integration_test/**
./cgroups: cgroups/**
./seccomp: seccomp/**
./crates/youki: crates/youki/**
./crates/libcontainer: crates/libcontainer/**
./crates/libcgroups: crates/libcgroups/**
./crates/libseccomp: crates/libseccomp/**
./crates/integration_test: crates/integration_test/**
check:
needs: [changes]
if: ${{ !contains(needs.changes.outputs.dirs, '[]') }}
@ -37,10 +38,6 @@ jobs:
override: true
- name: Cache youki
uses: Swatinem/rust-cache@v1
- name: Cache cgroups
uses: Swatinem/rust-cache@v1
with:
working-directory: ./cgroups
- run: rustup component add rustfmt clippy
- run: sudo apt-get -y update
- run: sudo apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev
@ -63,10 +60,6 @@ jobs:
override: true
- name: Cache youki
uses: Swatinem/rust-cache@v1
- name: Cache cgroups
uses: Swatinem/rust-cache@v1
with:
working-directory: ./cgroups
- run: sudo apt-get -y update
- run: sudo apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev
- name: Run tests
@ -85,10 +78,6 @@ jobs:
components: llvm-tools-preview
- name: Cache youki
uses: Swatinem/rust-cache@v1
- name: Cache cgroups
uses: Swatinem/rust-cache@v1
with:
working-directory: ./cgroups
- name: install cargo-llvm-cov
env:
CARGO_LLVM_COV_VERSION: 0.1.5
@ -104,20 +93,10 @@ jobs:
cargo llvm-cov clean --workspace
cargo llvm-cov --no-report
cargo llvm-cov --no-run --lcov --output-path ./coverage.lcov
- name: Run Test Coverage for cgroups
working-directory: ./cgroups
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov --no-report
cargo llvm-cov --no-run --lcov --output-path ./coverage.lcov
- name: Upload Youki Code Coverage Results
uses: codecov/codecov-action@v2
with:
file: ./coverage.lcov
- name: Upload Cgroups Code Coverage Results
uses: codecov/codecov-action@v2
with:
file: ./cgroups/coverage.lcov
integration_tests:
runs-on: ubuntu-latest
strategy:
@ -138,10 +117,6 @@ jobs:
toolchain: ${{ matrix.rust }}
- name: Cache youki
uses: Swatinem/rust-cache@v1
- name: Cache cgroups
uses: Swatinem/rust-cache@v1
with:
working-directory: ./cgroups
- run: sudo apt-get -y update
- run: sudo apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev libelf-dev libseccomp-dev
- name: Build
@ -149,5 +124,5 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: '1.11.0'
- name: Run intetgration tests
- name: Run integration tests
run: ./integration_test.sh

2
.gitignore vendored

@ -1,4 +1,4 @@
youki
/tutorial
.idea/

347
Cargo.lock generated

@ -17,15 +17,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi",
]
[[package]]
name = "anyhow"
version = "1.0.43"
@ -102,28 +93,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cgroups"
version = "0.1.0"
dependencies = [
"anyhow",
"clap 2.33.3",
"dbus",
"env_logger 0.9.0",
"errno",
"libbpf-sys",
"libc",
"log",
"nix",
"oci-spec",
"procfs",
"quickcheck",
"rbpf",
"serde",
"serde_json",
"systemd",
]
[[package]]
name = "chrono"
version = "0.4.19"
@ -140,40 +109,28 @@ dependencies = [
[[package]]
name = "clap"
version = "2.33.3"
version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim 0.8.0",
"textwrap 0.11.0",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap"
version = "3.0.0-beta.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcd70aa5597dbc42f7217a543f9ef2768b2ef823ba29036072d30e1d88e98406"
dependencies = [
"bitflags",
"clap_derive",
"indexmap",
"lazy_static",
"os_str_bytes",
"strsim 0.10.0",
"textwrap 0.14.2",
"strsim",
"termcolor",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap_derive"
version = "3.0.0-beta.4"
version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b5bb0d655624a0b8770d1c178fb8ffcb1f91cc722cb08f451e3dc72465421ac"
checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1"
dependencies = [
"heck",
"proc-macro-error",
@ -201,6 +158,20 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "crossbeam"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.1"
@ -211,6 +182,40 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
"lazy_static",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.5"
@ -251,7 +256,7 @@ dependencies = [
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"strsim",
"syn",
]
@ -308,6 +313,12 @@ dependencies = [
"syn",
]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "env_logger"
version = "0.8.4"
@ -361,6 +372,18 @@ dependencies = [
"instant",
]
[[package]]
name = "filetime"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98"
dependencies = [
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"winapi",
]
[[package]]
name = "flate2"
version = "1.0.21"
@ -591,6 +614,26 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "integration_test"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"clap_derive",
"flate2",
"oci-spec 0.5.2 (git+https://github.com/containers/oci-spec-rs?rev=3d5132a18c305be59d58187201429d8f0243b513)",
"once_cell",
"procfs",
"rand",
"serde",
"serde_json",
"tar",
"test_framework",
"uuid",
"which",
]
[[package]]
name = "itoa"
version = "0.4.8"
@ -619,6 +662,56 @@ version = "0.2.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21"
[[package]]
name = "libcgroups"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"dbus",
"env_logger 0.9.0",
"errno",
"libbpf-sys",
"libc",
"log",
"nix",
"oci-spec 0.5.2 (git+https://github.com/containers/oci-spec-rs?rev=d6fb1e91742313cd0d0085937e2d6df5d4669720)",
"procfs",
"quickcheck",
"rbpf",
"serde",
"serde_json",
"systemd",
]
[[package]]
name = "libcontainer"
version = "0.0.1"
dependencies = [
"anyhow",
"caps",
"chrono",
"crossbeam-channel",
"dbus",
"fastrand",
"futures",
"libc",
"libcgroups",
"libseccomp",
"log",
"mio",
"nix",
"oci-spec 0.5.2 (git+https://github.com/containers/oci-spec-rs?rev=d6fb1e91742313cd0d0085937e2d6df5d4669720)",
"path-clean",
"prctl",
"procfs",
"quickcheck",
"serde",
"serde_json",
"serial_test",
"systemd",
]
[[package]]
name = "libdbus-sys"
version = "0.2.1"
@ -628,6 +721,14 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "libseccomp"
version = "0.1.0"
dependencies = [
"libc",
"pkg-config",
]
[[package]]
name = "libsystemd-sys"
version = "0.8.0"
@ -755,6 +856,18 @@ dependencies = [
"libc",
]
[[package]]
name = "oci-spec"
version = "0.5.2"
source = "git+https://github.com/containers/oci-spec-rs?rev=3d5132a18c305be59d58187201429d8f0243b513#3d5132a18c305be59d58187201429d8f0243b513"
dependencies = [
"derive_builder",
"getset",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "oci-spec"
version = "0.5.2"
@ -776,9 +889,9 @@ checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]]
name = "os_str_bytes"
version = "3.1.0"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6acbef58a60fe69ab50510a55bc8cdd4d6cf2283d27ad338f54cb52747a9cf2d"
checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85"
[[package]]
name = "parking_lot"
@ -811,16 +924,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd"
[[package]]
name = "pentacle"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e26ee4fbe38a973890ca68cace434e192d88f3703099fd64f799f3d6043ee7b6"
dependencies = [
"libc",
"log",
]
[[package]]
name = "pin-project-lite"
version = "0.2.7"
@ -839,6 +942,12 @@ version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb"
[[package]]
name = "ppv-lite86"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741"
[[package]]
name = "prctl"
version = "1.0.0"
@ -935,6 +1044,19 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
"rand_hc",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
@ -947,6 +1069,15 @@ dependencies = [
"getrandom",
]
[[package]]
name = "rand_hc"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
"rand_core",
]
[[package]]
name = "rbpf"
version = "0.1.0"
@ -997,14 +1128,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "seccomp"
version = "0.1.0"
dependencies = [
"libc",
"pkg-config",
]
[[package]]
name = "serde"
version = "1.0.130"
@ -1070,12 +1193,6 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.10.0"
@ -1109,12 +1226,14 @@ dependencies = [
]
[[package]]
name = "tabwriter"
version = "1.2.1"
name = "tar"
version = "0.4.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36205cfc997faadcc4b0b87aaef3fbedafe20d38d4959a7ca6ff803564051111"
checksum = "d6f5515d3add52e0bbdcad7b83c388bb36ba7b754dda3b5f5bc2d38640cdba5c"
dependencies = [
"unicode-width",
"filetime",
"libc",
"xattr",
]
[[package]]
@ -1127,19 +1246,21 @@ dependencies = [
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
name = "test_framework"
version = "0.1.0"
dependencies = [
"unicode-width",
"anyhow",
"crossbeam",
]
[[package]]
name = "textwrap"
version = "0.14.2"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
dependencies = [
"unicode-width",
]
[[package]]
name = "thiserror"
@ -1195,6 +1316,12 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55bcbb425141152b10d5693095950b51c3745d019363fc2929ffd8f61449b628"
[[package]]
name = "uuid"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
[[package]]
name = "vec_map"
version = "0.8.2"
@ -1213,6 +1340,17 @@ version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "which"
version = "4.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea187a8ef279bc014ec368c27a920da2024d2a711109bfbe3440585d5cf27ad9"
dependencies = [
"either",
"lazy_static",
"libc",
]
[[package]]
name = "winapi"
version = "0.3.9"
@ -1245,33 +1383,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "youki"
version = "0.0.1"
name = "xattr"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
dependencies = [
"anyhow",
"caps",
"cgroups",
"chrono",
"clap 3.0.0-beta.4",
"crossbeam-channel",
"dbus",
"fastrand",
"futures",
"libc",
"log",
"mio",
"nix",
"oci-spec",
"once_cell",
"path-clean",
"pentacle",
"prctl",
"procfs",
"quickcheck",
"seccomp",
"serde",
"serde_json",
"serial_test",
"systemd",
"tabwriter",
]

@ -1,58 +1,8 @@
[package]
name = "youki"
version = "0.0.1"
authors = ["utam0k <k0ma@utam0k.jp>"]
edition = "2021"
description = "A container runtime written in Rust"
[workspace]
members = [
"cgroups",
"seccomp",
]
exclude = [
"youki_integration_test",
"crates/*"
]
[features]
default = ["systemd_cgroups"]
systemd_cgroups = ["systemd"]
[dependencies.clap]
version = "3.0.0-beta.4"
default-features = false
features = ["std", "suggestions", "derive", "cargo"]
[dependencies]
nix = "0.22.0"
procfs = "0.11.0"
# Waiting for new caps release, replace git with version on release
caps = { git = "https://github.com/lucab/caps-rs", rev = "cb54844", features = ["serde_support"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
prctl = "1.0.0"
libc = "0.2.84"
log = "0.4"
anyhow = "1.0"
mio = { version = "0.7.13", features = ["os-ext", "os-poll"] }
chrono = { version="0.4", features = ["serde"] }
once_cell = "1.6.0"
futures = { version = "0.3", features = ["thread-pool"] }
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "d6fb1e91742313cd0d0085937e2d6df5d4669720" }
cgroups = { version = "0.1.0", path = "./cgroups" }
systemd = { version = "0.8", default-features = false, optional = true }
dbus = "0.9.2"
tabwriter = "1"
fastrand = "1.4.1"
crossbeam-channel = "0.5"
seccomp = { version = "0.1.0", path = "./seccomp" }
pentacle = "1.0.0"
path-clean = "0.1.0"
[dev-dependencies]
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "d6fb1e91742313cd0d0085937e2d6df5d4669720", features = ["proptests"] }
quickcheck = "1"
serial_test = "0.5.1"
[profile.release]
lto = true

@ -11,4 +11,6 @@ fi
cargo build --verbose $TGT $1
rm -f youki
rm -f youki_integration_test
cp target/$TARGET/$VERSION/youki .
cp target/$TARGET/$VERSION/integration_test ./youki_integration_test

@ -1,5 +1,5 @@
[package]
name = "youki_integration_test"
name = "integration_test"
version = "0.1.0"
edition = "2021"
@ -12,18 +12,13 @@ features = ["std", "suggestions", "derive"]
version = "=3.0.0-beta.2"
default-features = true
[workspace]
members = [
"test_framework",
]
[dependencies]
procfs = "0.11.0"
uuid = "0.8"
rand = "0.8.0"
tar = "0.4"
flate2 = "1.0"
test_framework = { path = "./test_framework"}
test_framework = { path = "../test_framework"}
anyhow = "1.0"
once_cell = "1.8.0"
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "3d5132a18c305be59d58187201429d8f0243b513" }

@ -1,10 +1,9 @@
#!/bin/bash
cd ..
./build.sh
cp ./youki ./youki_integration_test
cd ./youki_integration_test
cd ../../
./build.sh
cp ./youki ./crates/integration_test
cp ./youki_integration_test ./crates/integration_test
cd ./crates/integration_test
RUNTIME=./youki
if [[ -n "$1" ]]; then
RUNTIME="$1"

@ -1,5 +1,5 @@
[package]
name = "cgroups"
name = "libcgroups"
version = "0.1.0"
edition = "2018"
autoexamples = false
@ -26,7 +26,7 @@ libc = { version = "0.2.84", optional = true }
[dev-dependencies]
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "d6fb1e91742313cd0d0085937e2d6df5d4669720", features = ["proptests"] }
quickcheck = "1"
clap = "2"
clap = "3.0.0-beta.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.9"

@ -307,7 +307,7 @@ fn extract_page_size(dir_name: &str) -> Result<String> {
/// Parses this string slice into an u64
/// # Example
/// ```
/// use cgroups::stats::parse_value;
/// use libcgroups::stats::parse_value;
///
/// let value = parse_value("32").unwrap();
/// assert_eq!(value, 32);
@ -322,7 +322,7 @@ pub fn parse_value(value: &str) -> Result<u64> {
/// # Example
/// ```no_run
/// use std::path::Path;
/// use cgroups::stats::parse_single_value;
/// use libcgroups::stats::parse_single_value;
///
/// let value = parse_single_value(&Path::new("memory.current")).unwrap();
/// assert_eq!(value, 32);
@ -397,7 +397,7 @@ pub fn parse_nested_keyed_data(file_path: &Path) -> Result<HashMap<String, Vec<S
/// Parses a file that is structed according to the nested keyed format
/// # Example
/// ```
/// use cgroups::stats::parse_device_number;
/// use libcgroups::stats::parse_device_number;
///
/// let (major, minor) = parse_device_number("8:0").unwrap();
/// assert_eq!((major, minor), (8, 0));

@ -0,0 +1,38 @@
[package]
name = "libcontainer"
version = "0.0.1"
authors = ["youki team"]
edition = "2018"
description = "Library for container creation"
[features]
default = ["systemd_cgroups"]
systemd_cgroups = ["systemd"]
[dependencies]
anyhow = "1.0"
caps = { git = "https://github.com/lucab/caps-rs", rev = "cb54844", features = ["serde_support"] }
chrono = { version="0.4", features = ["serde"] }
crossbeam-channel = "0.5"
dbus = "0.9.2"
fastrand = "1.4.1"
futures = { version = "0.3", features = ["thread-pool"] }
libc = "0.2.84"
log = "0.4"
mio = { version = "0.7.13", features = ["os-ext", "os-poll"] }
nix = "0.22.0"
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "d6fb1e91742313cd0d0085937e2d6df5d4669720" }
path-clean = "0.1.0"
procfs = "0.11.0"
prctl = "1.0.0"
libcgroups = { version = "0.1.0", path = "../libcgroups" }
libseccomp = { version = "0.1.0", path = "../libseccomp" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
systemd = { version = "0.8", default-features = false, optional = true }
[dev-dependencies]
oci-spec = { git = "https://github.com/containers/oci-spec-rs", rev = "d6fb1e91742313cd0d0085937e2d6df5d4669720", features = ["proptests"] }
quickcheck = "1"
serial_test = "0.5.1"

@ -24,8 +24,8 @@ pub struct ContainerBuilder<'a> {
/// # Example
///
/// ```no_run
/// use youki::container::builder::ContainerBuilder;
/// use youki::syscall::syscall::create_syscall;;
/// use libcontainer::container::builder::ContainerBuilder;
/// use libcontainer::syscall::syscall::create_syscall;;
///
/// ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
/// .with_root_path("/run/containers/youki")
@ -41,8 +41,8 @@ impl<'a> ContainerBuilder<'a> {
/// # Example
///
/// ```no_run
/// use youki::container::builder::ContainerBuilder;
/// use youki::syscall::syscall::create_syscall;;
/// use libcontainer::container::builder::ContainerBuilder;
/// use libcontainer::syscall::syscall::create_syscall;;
///
/// let builder = ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref());
/// ```
@ -63,8 +63,8 @@ impl<'a> ContainerBuilder<'a> {
/// # Example
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
/// # use youki::syscall::syscall::create_syscall;
/// # use libcontainer::container::builder::ContainerBuilder;
/// # use libcontainer::syscall::syscall::create_syscall;
///
/// ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
/// .as_tenant()
@ -80,8 +80,8 @@ impl<'a> ContainerBuilder<'a> {
/// # Example
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
/// # use youki::syscall::syscall::create_syscall;
/// # use libcontainer::container::builder::ContainerBuilder;
/// # use libcontainer::syscall::syscall::create_syscall;
///
/// ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
/// .as_init("/var/run/docker/bundle")
@ -97,8 +97,8 @@ impl<'a> ContainerBuilder<'a> {
/// # Example
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
/// # use youki::syscall::syscall::create_syscall;
/// # use libcontainer::container::builder::ContainerBuilder;
/// # use libcontainer::syscall::syscall::create_syscall;
///
/// ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
/// .with_root_path("/run/containers/youki");
@ -113,8 +113,8 @@ impl<'a> ContainerBuilder<'a> {
/// # Example
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
/// # use youki::syscall::syscall::create_syscall;
/// # use libcontainer::container::builder::ContainerBuilder;
/// # use libcontainer::syscall::syscall::create_syscall;
///
/// ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
/// .with_pid_file(Some("/var/run/docker.pid"));
@ -129,8 +129,8 @@ impl<'a> ContainerBuilder<'a> {
/// # Example
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
/// # use youki::syscall::syscall::create_syscall;
/// # use libcontainer::container::builder::ContainerBuilder;
/// # use libcontainer::syscall::syscall::create_syscall;
///
/// ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
/// .with_console_socket(Some("/var/run/docker/sock.tty"));
@ -145,8 +145,8 @@ impl<'a> ContainerBuilder<'a> {
/// # Example
///
/// ```no_run
/// # use youki::container::builder::ContainerBuilder;
/// # use youki::syscall::syscall::create_syscall;
/// # use libcontainer::container::builder::ContainerBuilder;
/// # use libcontainer::syscall::syscall::create_syscall;
///
/// ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
/// .with_preserved_fds(5);

@ -55,7 +55,7 @@ impl<'a> ContainerBuilderImpl<'a> {
fn run_container(&mut self) -> Result<()> {
let linux = self.spec.linux().as_ref().context("no linux in spec")?;
let cgroups_path = utils::get_cgroup_path(linux.cgroups_path(), &self.container_id);
let cmanager = cgroups::common::create_cgroup_manager(&cgroups_path, self.use_systemd)?;
let cmanager = libcgroups::common::create_cgroup_manager(&cgroups_path, self.use_systemd)?;
let process = self.spec.process().as_ref().context("No process in spec")?;
if self.init {
@ -136,7 +136,7 @@ impl<'a> ContainerBuilderImpl<'a> {
fn cleanup_container(&self) -> Result<()> {
let linux = self.spec.linux().as_ref().context("no linux in spec")?;
let cgroups_path = utils::get_cgroup_path(linux.cgroups_path(), &self.container_id);
let cmanager = cgroups::common::create_cgroup_manager(&cgroups_path, self.use_systemd)?;
let cmanager = libcgroups::common::create_cgroup_manager(&cgroups_path, self.use_systemd)?;
let mut errors = Vec::new();
if let Err(e) = cmanager.remove().context("failed to remove cgroup") {

@ -2,7 +2,7 @@ use super::{Container, ContainerStatus};
use crate::hooks;
use crate::utils;
use anyhow::{bail, Context, Result};
use cgroups;
use libcgroups;
use nix::sys::signal;
use std::fs;
@ -12,8 +12,8 @@ impl Container {
/// # Example
///
/// ```no_run
/// use youki::container::builder::ContainerBuilder;
/// use youki::syscall::syscall::create_syscall;;
/// use libcontainer::container::builder::ContainerBuilder;
/// use libcontainer::syscall::syscall::create_syscall;;
///
/// # fn main() -> anyhow::Result<()> {
/// let mut container = ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
@ -61,8 +61,9 @@ impl Container {
let use_systemd = self
.systemd()
.context("container state does not contain cgroup manager")?;
let cmanager = cgroups::common::create_cgroup_manager(&cgroups_path, use_systemd)
.context("failed to create cgroup manager")?;
let cmanager =
libcgroups::common::create_cgroup_manager(&cgroups_path, use_systemd)
.context("failed to create cgroup manager")?;
cmanager.remove().with_context(|| {
format!("failed to remove cgroup {}", cgroups_path.display())
})?;

@ -11,8 +11,8 @@ impl Container {
/// # Example
///
/// ```no_run
/// use youki::container::builder::ContainerBuilder;
/// use youki::syscall::syscall::create_syscall;;
/// use libcontainer::container::builder::ContainerBuilder;
/// use libcontainer::syscall::syscall::create_syscall;;
///
/// # fn main() -> anyhow::Result<()> {
/// let mut container = ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
@ -42,7 +42,7 @@ impl Container {
.systemd()
.context("Could not determine cgroup manager")?;
let cgroup_manager = cgroups::common::create_cgroup_manager(cgroups_path, use_systemd)?;
let cgroup_manager = libcgroups::common::create_cgroup_manager(cgroups_path, use_systemd)?;
match stats {
true => {
let stats = cgroup_manager.stats()?;

@ -9,8 +9,8 @@ impl Container {
/// # Example
///
/// ```no_run
/// use youki::container::builder::ContainerBuilder;
/// use youki::syscall::syscall::create_syscall;;
/// use libcontainer::container::builder::ContainerBuilder;
/// use libcontainer::syscall::syscall::create_syscall;;
/// use nix::sys::signal::Signal;
///
/// # fn main() -> anyhow::Result<()> {

@ -2,7 +2,7 @@ use crate::utils;
use super::{Container, ContainerStatus};
use anyhow::{bail, Context, Result};
use cgroups::common::FreezerState;
use libcgroups::common::FreezerState;
impl Container {
/// Suspends all processes within the container
@ -10,8 +10,8 @@ impl Container {
/// # Example
///
/// ```no_run
/// use youki::container::builder::ContainerBuilder;
/// use youki::syscall::syscall::create_syscall;;
/// use libcontainer::container::builder::ContainerBuilder;
/// use libcontainer::syscall::syscall::create_syscall;;
///
/// # fn main() -> anyhow::Result<()> {
/// let mut container = ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
@ -46,7 +46,7 @@ impl Container {
let use_systemd = self
.systemd()
.context("container state does not contain cgroup manager")?;
let cmanager = cgroups::common::create_cgroup_manager(cgroups_path, use_systemd)?;
let cmanager = libcgroups::common::create_cgroup_manager(cgroups_path, use_systemd)?;
cmanager.freeze(FreezerState::Frozen)?;
log::debug!("saving paused status");

@ -3,7 +3,7 @@ use crate::utils;
use super::{Container, ContainerStatus};
use anyhow::{bail, Context, Result};
use cgroups::common::FreezerState;
use libcgroups::common::FreezerState;
impl Container {
/// Resumes all processes within the container
@ -11,8 +11,8 @@ impl Container {
/// # Example
///
/// ```no_run
/// use youki::container::builder::ContainerBuilder;
/// use youki::syscall::syscall::create_syscall;;
/// use libcontainer::container::builder::ContainerBuilder;
/// use libcontainer::syscall::syscall::create_syscall;;
///
/// # fn main() -> anyhow::Result<()> {
/// let mut container = ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())
@ -49,7 +49,7 @@ impl Container {
let use_systemd = self
.systemd()
.context("container state does not contain cgroup manager")?;
let cmanager = cgroups::common::create_cgroup_manager(cgroups_path, use_systemd)?;
let cmanager = libcgroups::common::create_cgroup_manager(cgroups_path, use_systemd)?;
// resume the frozen container
cmanager.freeze(FreezerState::Thawed)?;

@ -13,8 +13,8 @@ impl Container {
/// # Example
///
/// ```no_run
/// use youki::container::builder::ContainerBuilder;
/// use youki::syscall::syscall::create_syscall;;
/// use libcontainer::container::builder::ContainerBuilder;
/// use libcontainer::syscall::syscall::create_syscall;;
///
/// # fn main() -> anyhow::Result<()> {
/// let mut container = ContainerBuilder::new("74f1a4cb3801".to_owned(), create_syscall().as_ref())

@ -148,7 +148,7 @@ impl State {
///
/// ```
/// # use std::path::Path;
/// # use youki::container::State;
/// # use libcontainer::container::State;
///
/// let container_root = Path::new("/var/run/containers/container");
/// let state_file = State::file_path(&container_root);

@ -1,10 +1,8 @@
pub mod apparmor;
pub mod capabilities;
pub mod commands;
pub mod container;
pub mod dbus;
pub mod hooks;
pub mod logger;
pub mod namespaces;
pub mod notify_socket;
pub mod process;

Some files were not shown because too many files have changed in this diff Show More