diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22412a479..49261896a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,10 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable + - name: Setup OCI runtime build env + run: | + sudo apt -y update + sudo apt install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev - name: Setup WasmEdge build env run: | curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- --version=0.11.2 @@ -35,10 +39,8 @@ jobs: - name: Validate docs run: ./scripts/validate-docs.sh - name: Run tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --all --verbose + run: | + sudo -E LD_LIBRARY_PATH=/home/runner/.wasmedge/lib /home/runner/.cargo/bin/cargo test --all --verbose e2e: needs: [build] diff --git a/Cargo.lock b/Cargo.lock index 8ebe009cb..8293bf13e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.8.3" @@ -48,19 +54,19 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.68" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "async-trait" -version = "0.1.62" +version = "0.1.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "689894c2db1ea643a50834b999abf1c110887402542955ff5451dab8f861f9ed" +checksum = "86ea188f25f0255d8f92797797c97ebf5631fa88178beb1a46fdf5622c9a00e4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.5", ] [[package]] @@ -90,7 +96,7 @@ version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", @@ -101,7 +107,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 1.0.109", ] [[package]] @@ -110,6 +116,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c70beb79cbb5ce9c4f8e20849978f34225931f665bb49efa6982875a4d5facb3" + [[package]] name = "block-buffer" version = "0.9.0" @@ -121,9 +133,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -142,44 +154,44 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cap-fs-ext" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff40fd8a96d57a204080e5debd621342612f6d6b60901201a51f518baf72691d" +checksum = "07d9cd7dc1d714d59974a6a68bed489c914b7b2620d1d4334d88d5ec9f29ebbd" dependencies = [ "cap-primitives", "cap-std", - "io-lifetimes 1.0.4", + "io-lifetimes 1.0.9", "windows-sys 0.45.0", ] [[package]] name = "cap-primitives" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9554a7698c8db4b7777f01b2237de111c5ecea169efb1190004d9069ceb289aa" +checksum = "8e41334d53bab60f94878253f8a950c231596c8bbb99b4f71b13223dd48e18c6" dependencies = [ "ambient-authority", "fs-set-times", "io-extras", - "io-lifetimes 1.0.4", + "io-lifetimes 1.0.9", "ipnet", "maybe-owned", - "rustix 0.36.7", + "rustix 0.36.11", "windows-sys 0.45.0", "winx", ] [[package]] name = "cap-rand" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "103e94d97d73504c5fa6ffb47135d5627ce5ff84a4ad37e8219103ddc291de24" +checksum = "6b5ddc7e3565e7cc4bf20d0c386b328f9e0f1b83fe0bcc0e055a1f08245e2aca" dependencies = [ "ambient-authority", "rand", @@ -187,26 +199,26 @@ dependencies = [ [[package]] name = "cap-std" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7b68a8ac703cc7bed0a46666a04b386cca214844897a69f599dcd82ea59422c" +checksum = "e9dd840c16dee1df417f3985d173a2bb6ef55d48ea3d4deddcef46f31c9e7028" dependencies = [ "cap-primitives", "io-extras", - "io-lifetimes 1.0.4", + "io-lifetimes 1.0.9", "ipnet", - "rustix 0.36.7", + "rustix 0.36.11", ] [[package]] name = "cap-time-ext" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "472931750f90fbf0731c886c2937521e25772942577a182e7ace5bc561d10e3b" +checksum = "77c39790e8e7455a92993bea5a2e947721c395cfbc344b74f092746c55441d76" dependencies = [ "cap-primitives", "once_cell", - "rustix 0.36.7", + "rustix 0.36.11", "winx", ] @@ -222,9 +234,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" dependencies = [ "jobserver", ] @@ -252,14 +264,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "js-sys", "num-integer", "num-traits", + "serde", "time 0.1.45", "wasm-bindgen", "winapi", @@ -267,9 +280,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" dependencies = [ "glob", "libc", @@ -282,7 +295,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee4e061ea30800291ca09663878f3953840a69b08ce244b3e8b26e894d9f60f" dependencies = [ - "bitflags", + "bitflags 1.3.2", "uapi", ] @@ -335,7 +348,7 @@ dependencies = [ "serde_json", "signal-hook", "thiserror", - "time 0.3.17", + "time 0.3.20", "uuid", ] @@ -345,7 +358,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "077ec778a0835d9d85502e8535362130187759b69eddabe2bdb3a68ffb575bd0" dependencies = [ - "protobuf", + "protobuf 2.28.0", "ttrpc", ] @@ -366,7 +379,7 @@ dependencies = [ "oci-spec 0.6.0", "pretty_assertions", "proc-mounts", - "protobuf", + "protobuf 2.28.0", "rand", "serde", "serde_json", @@ -387,9 +400,12 @@ dependencies = [ "containerd-shim", "containerd-shim-wasm", "libc", + "libcontainer", "log", + "nix 0.26.2", "oci-spec 0.6.0", "pretty_assertions", + "serde", "serde_json", "serial_test", "tempfile", @@ -554,9 +570,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -564,9 +580,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", @@ -575,22 +591,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.13" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if 1.0.0", "crossbeam-utils", - "memoffset 0.7.1", + "memoffset 0.8.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if 1.0.0", ] @@ -612,14 +628,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "cxx" -version = "1.0.87" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b61a7545f753a88bcbe0a70de1fcc0221e10bfc752f576754fa91e663db1622e" +checksum = "a9c00419335c41018365ddf7e4d5f1c12ee3659ddcf3e01974650ba1de73d038" dependencies = [ "cc", "cxxbridge-flags", @@ -629,9 +645,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.87" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f464457d494b5ed6905c63b0c4704842aba319084a0a3561cdc1359536b53200" +checksum = "fb8307ad413a98fff033c8545ecf133e3257747b3bae935e7602aab8aa92d4ca" dependencies = [ "cc", "codespan-reporting", @@ -639,31 +655,31 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 2.0.5", ] [[package]] name = "cxxbridge-flags" -version = "1.0.87" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43c7119ce3a3701ed81aca8410b9acf6fc399d2629d057b87e2efa4e63a3aaea" +checksum = "edc52e2eb08915cb12596d29d55f0b5384f00d697a646dbd269b6ecb0fbd9d31" [[package]] name = "cxxbridge-macro" -version = "1.0.87" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e07508b90551e610910fa648a1878991d367064997a596135b86df30daf07e" +checksum = "631569015d0d8d54e6c241733f944042623ab6df7bc3be7466874b05fcdb1c5f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.5", ] [[package]] name = "darling" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ "darling_core", "darling_macro", @@ -671,27 +687,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.109", ] [[package]] name = "darling_macro" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -707,6 +723,17 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "dbus" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b" +dependencies = [ + "libc", + "libdbus-sys", + "winapi", +] + [[package]] name = "derive-new" version = "0.5.9" @@ -715,7 +742,7 @@ checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -745,7 +772,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -757,7 +784,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -767,7 +794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" dependencies = [ "derive_builder_core 0.11.2", - "syn", + "syn 1.0.109", ] [[package]] @@ -777,7 +804,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" dependencies = [ "derive_builder_core 0.12.0", - "syn", + "syn 1.0.109", ] [[package]] @@ -801,7 +828,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", ] @@ -848,9 +875,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "env_logger" @@ -894,9 +921,9 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] @@ -908,7 +935,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ef1a30ae415c3a691a4f41afddc2dbcd6d70baf338368d85ebc1e8ed92cedb9" dependencies = [ "cfg-if 1.0.0", - "rustix 0.36.7", + "rustix 0.36.11", "windows-sys 0.45.0", ] @@ -924,14 +951,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e884668cd0c7480504233e951174ddc3b382f7c2666e3b7310b5c4e7b0c37f9" +checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -940,6 +967,22 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" @@ -961,16 +1004,16 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "857cf27edcb26c2a36d84b2954019573d335bb289876113aceacacdca47a4fd4" dependencies = [ - "io-lifetimes 1.0.4", - "rustix 0.36.7", + "io-lifetimes 1.0.9", + "rustix 0.36.11", "windows-sys 0.45.0", ] [[package]] name = "futures" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" +checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" dependencies = [ "futures-channel", "futures-core", @@ -983,9 +1026,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" dependencies = [ "futures-core", "futures-sink", @@ -993,48 +1036,61 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" [[package]] name = "futures-executor" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" +checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" dependencies = [ "futures-core", "futures-task", "futures-util", + "num_cpus", ] [[package]] name = "futures-io" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" +checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" + +[[package]] +name = "futures-macro" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ "futures-channel", "futures-core", "futures-io", + "futures-macro", "futures-sink", "futures-task", "memchr", @@ -1082,7 +1138,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1137,9 +1193,9 @@ dependencies = [ [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -1150,6 +1206,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -1164,16 +1226,16 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0c17cc76786e99f8d2f055c11159e7f0091c42474dcc3189fbab96072e873e6d" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] @@ -1228,7 +1290,7 @@ version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d79107d6e60d78351e11f0a2dc9d0eaf304a7efb592e92603783afb8479c7d97" dependencies = [ - "io-lifetimes 1.0.4", + "io-lifetimes 1.0.9", "windows-sys 0.45.0", ] @@ -1240,12 +1302,13 @@ checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" [[package]] name = "io-lifetimes" -version = "1.0.4" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -1256,14 +1319,14 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" [[package]] name = "is-terminal" -version = "0.4.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" dependencies = [ - "hermit-abi", - "io-lifetimes 1.0.4", - "rustix 0.36.7", - "windows-sys 0.42.0", + "hermit-abi 0.3.1", + "io-lifetimes 1.0.9", + "rustix 0.36.11", + "windows-sys 0.45.0", ] [[package]] @@ -1277,9 +1340,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "ittapi" @@ -1303,18 +1366,18 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -1339,9 +1402,62 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.141" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" + +[[package]] +name = "libcgroups" +version = "0.0.5" +source = "git+https://github.com/containers/youki?rev=edd63c84f903aa09510ef758ea6f617e0cb8b7e1#edd63c84f903aa09510ef758ea6f617e0cb8b7e1" +dependencies = [ + "anyhow", + "dbus", + "fixedbitset 0.4.2", + "log", + "nix 0.26.2", + "oci-spec 0.6.0", + "procfs", + "serde", +] + +[[package]] +name = "libcontainer" +version = "0.0.5" +source = "git+https://github.com/containers/youki?rev=edd63c84f903aa09510ef758ea6f617e0cb8b7e1#edd63c84f903aa09510ef758ea6f617e0cb8b7e1" +dependencies = [ + "anyhow", + "bitflags 2.1.0", + "caps", + "chrono", + "clone3", + "crossbeam-channel", + "fastrand", + "futures", + "libc", + "libcgroups", + "libseccomp", + "log", + "mio", + "nix 0.26.2", + "oci-spec 0.6.0", + "path-clean", + "prctl", + "procfs", + "rust-criu", + "serde", + "serde_json", + "syscalls", +] + +[[package]] +name = "libdbus-sys" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "9f8d7ae751e1cb825c840ae5e682f59b098cdfd213c350ac268b61449a5f58a0" +dependencies = [ + "pkg-config", +] [[package]] name = "libloading" @@ -1353,6 +1469,24 @@ dependencies = [ "winapi", ] +[[package]] +name = "libseccomp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21c57fd8981a80019807b7b68118618d29a87177c63d704fc96e6ecd003ae5b3" +dependencies = [ + "bitflags 1.3.2", + "libc", + "libseccomp-sys", + "pkg-config", +] + +[[package]] +name = "libseccomp-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a7cbbd4ad467251987c6e5b47d53b11a5a05add08f2447a9e2d70aef1e0d138" + [[package]] name = "link-cplusplus" version = "1.0.8" @@ -1420,7 +1554,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" dependencies = [ - "rustix 0.36.7", + "rustix 0.36.11", ] [[package]] @@ -1456,6 +1590,27 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.45.0", +] + [[package]] name = "multimap" version = "0.8.3" @@ -1468,7 +1623,7 @@ version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 1.0.0", "libc", @@ -1481,7 +1636,7 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 1.0.0", "libc", @@ -1494,7 +1649,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if 1.0.0", "libc", "memoffset 0.7.1", @@ -1520,7 +1675,7 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1548,7 +1703,7 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ - "hermit-abi", + "hermit-abi 0.2.6", "libc", ] @@ -1606,9 +1761,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -1637,15 +1792,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -1659,9 +1814,15 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + +[[package]] +name = "path-clean" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" [[package]] name = "peeking_take_while" @@ -1681,7 +1842,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" dependencies = [ - "fixedbitset", + "fixedbitset 0.2.0", "indexmap", ] @@ -1740,7 +1901,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1757,9 +1918,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" dependencies = [ "unicode-ident", ] @@ -1773,6 +1934,21 @@ dependencies = [ "partition-identity", ] +[[package]] +name = "procfs" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943ca7f9f29bab5844ecd8fdb3992c5969b6622bb9609b9502fef9b4310e3f1f" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "chrono", + "flate2", + "hex", + "lazy_static", + "rustix 0.36.11", +] + [[package]] name = "prost" version = "0.8.0" @@ -1811,7 +1987,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1830,13 +2006,39 @@ version = "2.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" +[[package]] +name = "protobuf" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55bad9126f378a853655831eb7363b7b01b81d19f8cb1218861086ca4a1a61e" +dependencies = [ + "once_cell", + "protobuf-support", + "thiserror", +] + [[package]] name = "protobuf-codegen" version = "2.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "033460afb75cf755fcfc16dfaed20b86468082a2ea24e05ac35ab4a099a017d6" dependencies = [ - "protobuf", + "protobuf 2.28.0", +] + +[[package]] +name = "protobuf-codegen" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd418ac3c91caa4032d37cb80ff0d44e2ebe637b2fb243b6234bf89cdac4901" +dependencies = [ + "anyhow", + "once_cell", + "protobuf 3.2.0", + "protobuf-parse", + "regex", + "tempfile", + "thiserror", ] [[package]] @@ -1845,18 +2047,52 @@ version = "2.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a29399fc94bcd3eeaa951c715f7bea69409b2445356b00519740bcd6ddd865" dependencies = [ - "protobuf", - "protobuf-codegen", + "protobuf 2.28.0", + "protobuf-codegen 2.28.0", ] [[package]] name = "protobuf-codegen-pure3" -version = "2.28.1" +version = "2.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b351add14db0721ad0842f4858aec11a5088684112ef163fc50f113c63e69b2e" +dependencies = [ + "protobuf 2.28.0", + "protobuf-codegen3", +] + +[[package]] +name = "protobuf-codegen3" +version = "2.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73c5878d0fa872bd7d61782c6aa2d2d56761ba4ed4514eb6992f5f83162f1d2f" +dependencies = [ + "protobuf 2.28.0", +] + +[[package]] +name = "protobuf-parse" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d39b14605eaa1f6a340aec7f320b34064feb26c93aec35d6a9a2272a8ddfa49" +dependencies = [ + "anyhow", + "indexmap", + "log", + "protobuf 3.2.0", + "protobuf-support", + "tempfile", + "thiserror", + "which", +] + +[[package]] +name = "protobuf-support" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0a3cf0a7de7570cb67bfb9a9a585b5841b49790a1be0ef104340a2110b91135" +checksum = "a5d4d7b8601c814cfb36bcebb79f0e61e45e1e93640cf778837833bbed05c372" dependencies = [ - "protobuf", - "protobuf-codegen", + "thiserror", ] [[package]] @@ -1870,9 +2106,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -1909,9 +2145,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ "either", "rayon-core", @@ -1919,9 +2155,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -1935,7 +2171,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1963,9 +2199,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "cce168fea28d3e05f158bda4576cf0c844d5045bc2cc3620fa0292ed5bb5814c" dependencies = [ "aho-corasick", "memchr", @@ -1974,17 +2210,20 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "rust-criu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +checksum = "4737b28406b3395359f485127073117a11cedc8942738b69ba6ab9a79432acbc" dependencies = [ - "winapi", + "anyhow", + "libc", + "protobuf 3.2.0", + "protobuf-codegen 3.2.0", ] [[package]] @@ -2005,7 +2244,7 @@ version = "0.35.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes 0.7.5", "libc", @@ -2015,25 +2254,25 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.7" +version = "0.36.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", - "io-lifetimes 1.0.4", + "io-lifetimes 1.0.9", "itoa", "libc", "linux-raw-sys 0.1.4", "once_cell", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "scopeguard" @@ -2043,41 +2282,52 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "771d4d9c4163ee138805e12c710dd365e4f44be8be0503cb1bb9eb989425d9c9" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.5", ] [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.5", +] + [[package]] name = "serial_test" version = "1.0.0" @@ -2100,7 +2350,7 @@ checksum = "079a83df15f85d89a68d64ae1238f142f172b1fa915d0d76b26a7cba1b659a69" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2129,9 +2379,9 @@ dependencies = [ [[package]] name = "sha256" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e334db67871c14c18fc066ad14af13f9fdf5f9a91c61af432d1e3a39c8c6a141" +checksum = "328169f167261957e83d82be47f9e36629e257c62308129033d7f7e7c173d180" dependencies = [ "hex", "sha2 0.9.9", @@ -2154,9 +2404,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" dependencies = [ "libc", "signal-hook-registry", @@ -2164,9 +2414,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -2212,27 +2462,49 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89c2d1c76a26822187a1fbb5964e3fff108bc208f02e820ab9dac1234f6b388a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syscalls" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5370cb0d74115b12ddd7feb517742dbaaf4aae9e3c10ff0edc7c19404935075b" +dependencies = [ + "cc", + "serde", + "serde_repr", +] + [[package]] name = "system-interface" version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f355df185d945435f24c51fda9bf01bea6acb6c0b753e1241e5cc05413a659d4" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cap-fs-ext", "cap-std", "fd-lock", - "io-lifetimes 1.0.4", - "rustix 0.36.7", + "io-lifetimes 1.0.9", + "rustix 0.36.11", "windows-sys 0.45.0", "winx", ] @@ -2250,22 +2522,21 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" dependencies = [ "cfg-if 1.0.0", "fastrand", - "libc", "redox_syscall", - "remove_dir_all", - "winapi", + "rustix 0.36.11", + "windows-sys 0.42.0", ] [[package]] @@ -2279,22 +2550,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.5", ] [[package]] @@ -2310,9 +2581,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ "serde", "time-core", @@ -2327,9 +2598,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" dependencies = [ "time-core", ] @@ -2379,7 +2650,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2401,7 +2672,7 @@ dependencies = [ "libc", "log", "nix 0.23.2", - "protobuf", + "protobuf 2.28.0", "protobuf-codegen-pure", "thiserror", ] @@ -2412,8 +2683,8 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cd69db981f94f86c5e27639294876b2f7a69f7cc4d59ce5178a185a79c18838" dependencies = [ - "protobuf", - "protobuf-codegen", + "protobuf 2.28.0", + "protobuf-codegen 2.28.0", "protobuf-codegen-pure3", "ttrpc-compiler", ] @@ -2428,8 +2699,8 @@ dependencies = [ "prost", "prost-build", "prost-types", - "protobuf", - "protobuf-codegen", + "protobuf 2.28.0", + "protobuf-codegen 2.28.0", "tempfile", ] @@ -2462,20 +2733,20 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 1.0.109", ] [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -2488,9 +2759,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" @@ -2550,10 +2821,10 @@ dependencies = [ "cap-time-ext", "fs-set-times", "io-extras", - "io-lifetimes 1.0.4", + "io-lifetimes 1.0.9", "is-terminal", "once_cell", - "rustix 0.36.7", + "rustix 0.36.11", "system-interface", "tracing", "wasi-common", @@ -2567,12 +2838,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be54f652e97bf4ffd98368386785ef80a70daf045ee307ec321be51b3ad7370c" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "cap-rand", "cap-std", "io-extras", "log", - "rustix 0.36.7", + "rustix 0.36.11", "thiserror", "tracing", "wasmtime", @@ -2595,9 +2866,9 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -2605,24 +2876,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2630,22 +2901,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wasm-encoder" @@ -2664,7 +2935,7 @@ checksum = "6f159a9a7d3d2301de2fc9cb88ad3459af9e95cbd5a0f57437efccc2b572a027" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2782,7 +3053,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.7", + "rustix 0.36.11", "serde", "sha2 0.10.6", "toml", @@ -2876,7 +3147,7 @@ checksum = "17e35d335dd2461c631ba24d2326d993bd3a4bdb4b0217e5bda4f518ba0e29f3" dependencies = [ "object", "once_cell", - "rustix 0.36.7", + "rustix 0.36.11", ] [[package]] @@ -2907,7 +3178,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand", - "rustix 0.36.7", + "rustix 0.36.11", "wasmtime-asm-macros 7.0.0", "wasmtime-environ", "wasmtime-jit-debug", @@ -2989,7 +3260,7 @@ checksum = "43991a6d0a435642831e40de3e412eb96950f1c9c72289e486db469ff7c4e53c" dependencies = [ "anyhow", "async-trait", - "bitflags", + "bitflags 1.3.2", "thiserror", "tracing", "wasmtime", @@ -3003,11 +3274,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "424062dad40b2020239ae2de27c962b5dfa6f36b9fe4ddfc3bcff3d5917d078f" dependencies = [ "anyhow", - "heck 0.4.0", + "heck 0.4.1", "proc-macro2", "quote", "shellexpand", - "syn", + "syn 1.0.109", "witx", ] @@ -3019,7 +3290,7 @@ checksum = "7dc0c6a4cbe4f073e7e24c0452fc58c2775574f3b8c89703148d6308d2531b16" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wiggle-generate", ] @@ -3054,6 +3325,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdacb41e6a96a052c6cb63a144f24900236121c6f63f4f8219fef5977ecb0c25" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.36.1" @@ -3074,12 +3354,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -3093,24 +3373,24 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.1", + "windows_x86_64_msvc 0.42.2", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" @@ -3120,9 +3400,9 @@ checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" @@ -3132,9 +3412,9 @@ checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" @@ -3144,9 +3424,9 @@ checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" @@ -3156,15 +3436,15 @@ checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" @@ -3174,9 +3454,9 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "winx" @@ -3184,8 +3464,8 @@ version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "129cd8ee937d535e1a239d9d3c9c0525af0454bc0967d9211a251be062513520" dependencies = [ - "bitflags", - "io-lifetimes 1.0.4", + "bitflags 1.3.2", + "io-lifetimes 1.0.9", "windows-sys 0.45.0", ] @@ -3237,9 +3517,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.5+zstd.1.5.2" +version = "2.0.7+zstd.1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc50ffce891ad571e9f9afe5039c4837bede781ac4bb13052ed7ae695518596" +checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index dae099aec..9d7990d64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,9 +28,11 @@ chrono = "0.4" nix = "0.26" cap-std = "1.0" thiserror = "1.0" -libc = "0.2.138" -oci-spec = "0.6" +libc = "0.2.141" +oci-spec = { version = "0.6.0", features = ["runtime"] } sha256 = "1.1" +# TODO: Wait for the release and use the crates.io one. +libcontainer = { git = "https://github.com/containers/youki", rev = "edd63c84f903aa09510ef758ea6f617e0cb8b7e1" } [profile.release] panic = "abort" diff --git a/Dockerfile b/Dockerfile index 86f909fe0..c7a5b4d40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ ENV WASMEDGE_INCLUDE_DIR=/root/.wasmedge/include ENV WASMEDGE_LIB_DIR=/root/.wasmedge/lib ENV LD_LIBRARY_PATH=/root/.wasmedge/lib RUN xx-apt-get install -y gcc g++ libc++6-dev zlib1g +RUN xx-apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev RUN rustup target add $(xx-info march)-unknown-$(xx-info os)-$(xx-info libc) RUN <>) -> Self; - // Start the instance and return the pid + /// Start the instance + /// The returned value should be a unique ID (such as a PID) for the instance. + /// Nothing internally should be using this ID, but it is returned to containerd where a user may want to use it. fn start(&self) -> Result; - // Send the specified signal to the instance + /// Send a signal to the instance fn kill(&self, signal: u32) -> Result<(), Error>; - // Delete the instance + /// delete any reference to the instance + /// This is called after the instance has exited. fn delete(&self) -> Result<(), Error>; - // wait for the instance to exit and send the exit code and exit timestamp to the provided sender. + /// wait for the instance to exit + /// The sender is used to send the exit code and time back to the caller + /// Ideally this would just be a blocking call with a normal result, however + /// because of how this is called from a thread it causes issues with lifetimes of the trait implementer. fn wait(&self, send: Sender<(u32, DateTime)>) -> Result<(), Error>; } ``` diff --git a/crates/containerd-shim-wasm/src/sandbox/instance.rs b/crates/containerd-shim-wasm/src/sandbox/instance.rs index 9a0b5f314..435e246fc 100644 --- a/crates/containerd-shim-wasm/src/sandbox/instance.rs +++ b/crates/containerd-shim-wasm/src/sandbox/instance.rs @@ -30,15 +30,18 @@ where stderr: Option, /// Path to the OCI bundle directory. bundle: Option, + /// Namespace for containerd + namespace: String, } impl InstanceConfig where E: Send + Sync + Clone, { - pub fn new(engine: E) -> Self { + pub fn new(engine: E, namespace: String) -> Self { Self { engine, + namespace, stdin: None, stdout: None, stderr: None, @@ -94,6 +97,11 @@ where pub fn get_engine(&self) -> E { self.engine.clone() } + + /// get the namespace for the instance + pub fn get_namespace(&self) -> String { + self.namespace.clone() + } } /// Represents a wasi module(s). @@ -235,7 +243,7 @@ mod noptests { #[test] fn test_op_kill_other() -> Result<(), Error> { - let nop = Nop::new("".to_string(), None); + let nop = Arc::new(Nop::new("".to_string(), None)); let err = nop.kill(SIGHUP as u32).unwrap_err(); match err { @@ -248,7 +256,7 @@ mod noptests { #[test] fn test_nop_delete_after_create() { - let nop = Nop::new("".to_string(), None); + let nop = Arc::new(Nop::new("".to_string(), None)); nop.delete().unwrap(); } } diff --git a/crates/containerd-shim-wasm/src/sandbox/mod.rs b/crates/containerd-shim-wasm/src/sandbox/mod.rs index e80748051..72d7ac2f3 100644 --- a/crates/containerd-shim-wasm/src/sandbox/mod.rs +++ b/crates/containerd-shim-wasm/src/sandbox/mod.rs @@ -16,5 +16,4 @@ pub use shim::{Cli as ShimCli, Local}; pub mod oci; -#[cfg(test)] -mod testutil; +pub mod testutil; diff --git a/crates/containerd-shim-wasm/src/sandbox/shim.rs b/crates/containerd-shim-wasm/src/sandbox/shim.rs index 22cf3e2fd..fa52a37b5 100644 --- a/crates/containerd-shim-wasm/src/sandbox/shim.rs +++ b/crates/containerd-shim-wasm/src/sandbox/shim.rs @@ -338,6 +338,7 @@ where instances: LocalInstances, events: Arc>, exit: Arc, + namespace: String, } #[cfg(test)] @@ -422,6 +423,7 @@ mod localtests { (), tx, Arc::new(ExitSignal::default()), + "test_namespace".into(), )); let mut _wrapped = LocalWithDescrutor::new(local.clone()); @@ -447,7 +449,12 @@ mod localtests { // When a cri sandbox is specified we just assume it's the sandbox container and treat it as such by not actually running the code (which is going to be wasm). let (etx, _erx) = channel(); let exit_signal = Arc::new(ExitSignal::default()); - let local = Arc::new(Local::::new((), etx, exit_signal)); + let local = Arc::new(Local::::new( + (), + etx, + exit_signal, + "test_namespace".into(), + )); let mut _wrapped = LocalWithDescrutor::new(local.clone()); @@ -610,7 +617,12 @@ mod localtests { fn test_task_lifecycle() -> Result<()> { let (etx, _erx) = channel(); // TODO: check events let exit_signal = Arc::new(ExitSignal::default()); - let local = Arc::new(Local::::new((), etx, exit_signal)); + let local = Arc::new(Local::::new( + (), + etx, + exit_signal, + "test_namespace".into(), + )); let mut _wrapped = LocalWithDescrutor::new(local.clone()); @@ -718,7 +730,12 @@ where E: Send + Sync + Clone, { /// Creates a new local task service. - pub fn new(engine: E, tx: Sender<(String, Box)>, exit: Arc) -> Self + pub fn new( + engine: E, + tx: Sender<(String, Box)>, + exit: Arc, + namespace: String, + ) -> Self where T: Instance + Sync + Send, E: Send + Sync + Clone, @@ -729,11 +746,12 @@ where instances: Arc::new(RwLock::new(HashMap::new())), events: Arc::new(Mutex::new(tx)), exit, + namespace, } } fn new_base(&self, id: String) -> InstanceData { - let cfg = InstanceConfig::new(self.engine.clone()); + let cfg = InstanceConfig::new(self.engine.clone(), self.namespace.clone()); InstanceData { instance: None, base: Some(Nop::new(id, None)), @@ -924,7 +942,7 @@ where } let engine = self.engine.clone(); - let mut builder = InstanceConfig::new(engine); + let mut builder = InstanceConfig::new(engine, self.namespace.clone()); builder .set_stdin(req.get_stdin().into()) .set_stdout(req.get_stdout().into()) @@ -1182,8 +1200,13 @@ where type Instance = T; fn new(namespace: String, _id: String, engine: E, publisher: RemotePublisher) -> Self { let (tx, rx) = channel::<(String, Box)>(); - forward_events(namespace, publisher, rx); - Local::::new(engine, tx.clone(), Arc::new(ExitSignal::default())) + forward_events(namespace.clone(), publisher, rx); + Local::::new( + engine, + tx.clone(), + Arc::new(ExitSignal::default()), + namespace, + ) } } @@ -1453,8 +1476,13 @@ where fn create_task_service(&self, publisher: RemotePublisher) -> Self::T { let (tx, rx) = channel::<(String, Box)>(); - forward_events(self.namespace.to_string(), publisher, rx); - Local::::new(self.engine.clone(), tx.clone(), self.exit.clone()) + forward_events(self.namespace.to_string().clone(), publisher, rx); + Local::::new( + self.engine.clone(), + tx.clone(), + self.exit.clone(), + self.namespace.clone(), + ) } fn delete_shim(&mut self) -> shim::Result { diff --git a/crates/containerd-shim-wasm/src/sandbox/testutil.rs b/crates/containerd-shim-wasm/src/sandbox/testutil.rs index a2c1f86d0..baa61ee61 100644 --- a/crates/containerd-shim-wasm/src/sandbox/testutil.rs +++ b/crates/containerd-shim-wasm/src/sandbox/testutil.rs @@ -41,6 +41,7 @@ pub fn run_test_with_sudo(test: &str) -> Result<()> { .map_err(Error::from) } +#[macro_export] macro_rules! function { () => {{ fn f() {} @@ -53,4 +54,4 @@ macro_rules! function { }}; } -pub(crate) use function; +pub use function; diff --git a/crates/containerd-shim-wasmedge/Cargo.toml b/crates/containerd-shim-wasmedge/Cargo.toml index 5e201e95b..5c95edf42 100644 --- a/crates/containerd-shim-wasmedge/Cargo.toml +++ b/crates/containerd-shim-wasmedge/Cargo.toml @@ -14,8 +14,11 @@ anyhow = { workspace = true } cap-std = { workspace = true } oci-spec = { workspace = true, features = ["runtime"] } thiserror = { workspace = true } +serde = { workspace = true } serde_json = { workspace = true } +nix = { workspace = true } libc = { workspace = true } +libcontainer = { workspace = true } [dev-dependencies] tempfile = "3.0" diff --git a/crates/containerd-shim-wasmedge/src/executor.rs b/crates/containerd-shim-wasmedge/src/executor.rs new file mode 100644 index 000000000..d04c1ea64 --- /dev/null +++ b/crates/containerd-shim-wasmedge/src/executor.rs @@ -0,0 +1,121 @@ +use anyhow::{bail, Result}; +use oci_spec::runtime::Spec; + +use libc::{dup, dup2, STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO}; +use libcontainer::workload::Executor; +use std::os::unix::io::RawFd; + +use wasmedge_sdk::{ + config::{CommonConfigOptions, ConfigBuilder, HostRegistrationConfigOptions}, + params, Vm, +}; + +static mut STDIN_FD: Option = None; +static mut STDOUT_FD: Option = None; +static mut STDERR_FD: Option = None; + +const EXECUTOR_NAME: &str = "wasmedge"; + +pub struct WasmEdgeExecutor { + pub stdin: Option, + pub stdout: Option, + pub stderr: Option, +} + +impl Executor for WasmEdgeExecutor { + fn exec(&self, spec: &Spec) -> Result<()> { + // parse wasi parameters + let args = get_args(spec); + if args.is_empty() { + bail!("args should not be empty") + } + + let mut cmd = args[0].clone(); + if let Some(stripped) = args[0].strip_prefix(std::path::MAIN_SEPARATOR) { + cmd = stripped.to_string(); + } + let envs = env_to_wasi(spec); + + // create configuration with `wasi` option enabled + let config = ConfigBuilder::new(CommonConfigOptions::default()) + .with_host_registration_config(HostRegistrationConfigOptions::default().wasi(true)) + .build()?; + + // create a vm with the config settings + let mut vm = Vm::new(Some(config))?; + + // initialize the wasi module with the parsed parameters + let mut wasi_instance = vm.wasi_module()?; + wasi_instance.initialize( + Some(args.iter().map(|s| s as &str).collect()), + Some(envs.iter().map(|s| s as &str).collect()), + None, + ); + + let mut vm = vm.register_module_from_file("main", cmd)?; + + if let Some(stdin) = self.stdin { + unsafe { + STDIN_FD = Some(dup(STDIN_FILENO)); + dup2(stdin, STDIN_FILENO); + } + } + if let Some(stdout) = self.stdout { + unsafe { + STDOUT_FD = Some(dup(STDOUT_FILENO)); + dup2(stdout, STDOUT_FILENO); + } + } + if let Some(stderr) = self.stderr { + unsafe { + STDERR_FD = Some(dup(STDERR_FILENO)); + dup2(stderr, STDERR_FILENO); + } + } + + let ins = vm.named_module("main")?; + + // TODO: How to get exit code? + // This was relatively straight forward in go, but wasi and wasmtime are totally separate things in rust + match ins + .func("_start") + .expect("Not found '_start' func in the 'main' module instance") + .call(&mut vm, params!()) + { + Ok(_) => std::process::exit(0), + Err(_) => std::process::exit(137), + }; + } + + fn can_handle(&self, _spec: &Spec) -> Result { + Ok(true) + } + + fn name(&self) -> &'static str { + EXECUTOR_NAME + } +} + +fn get_args(spec: &Spec) -> &[String] { + let p = match spec.process() { + None => return &[], + Some(p) => p, + }; + + match p.args() { + None => &[], + Some(args) => args.as_slice(), + } +} + +fn env_to_wasi(spec: &Spec) -> Vec { + let default = vec![]; + let env = spec + .process() + .as_ref() + .unwrap() + .env() + .as_ref() + .unwrap_or(&default); + env.to_vec() +} diff --git a/crates/containerd-shim-wasmedge/src/instance.rs b/crates/containerd-shim-wasmedge/src/instance.rs index 8a721fd83..2a9c2dd1a 100644 --- a/crates/containerd-shim-wasmedge/src/instance.rs +++ b/crates/containerd-shim-wasmedge/src/instance.rs @@ -1,44 +1,83 @@ -use anyhow::Context; -use chrono::{DateTime, Utc}; -use containerd_shim_wasm::sandbox::error::Error; -use containerd_shim_wasm::sandbox::exec; -use containerd_shim_wasm::sandbox::oci; -use containerd_shim_wasm::sandbox::{EngineGetter, Instance, InstanceConfig}; -use libc::{dup, dup2, SIGINT, SIGKILL, STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO}; -use log::{debug, error}; -use std::fs::OpenOptions; +use std::fs::{File, OpenOptions}; +use std::io::prelude::*; use std::io::ErrorKind; use std::os::unix::io::{IntoRawFd, RawFd}; -use std::path::Path; use std::sync::{ mpsc::Sender, {Arc, Condvar, Mutex}, }; use std::thread; +use anyhow::{bail, Context, Result}; +use chrono::{DateTime, Utc}; +use containerd_shim_wasm::sandbox::error::Error; +use containerd_shim_wasm::sandbox::{EngineGetter, Instance, InstanceConfig}; +use libc::{dup2, SIGINT, SIGKILL, STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO}; +use log::{debug, error}; +use nix::errno::Errno; +use nix::sys::wait::{waitid, Id as WaitID, WaitPidFlag, WaitStatus}; +use serde::{Deserialize, Serialize}; use wasmedge_sdk::{ config::{CommonConfigOptions, ConfigBuilder, HostRegistrationConfigOptions}, - params, PluginManager, Vm, + PluginManager, Vm, }; -use super::error::WasmRuntimeError; -use super::oci_utils; +use std::{ + fs, + path::{Path, PathBuf}, +}; + +use libcontainer::container::builder::ContainerBuilder; +use libcontainer::container::{Container, ContainerStatus}; +use libcontainer::signal::Signal; +use libcontainer::syscall::syscall::create_syscall; + +use crate::executor::WasmEdgeExecutor; static mut STDIN_FD: Option = None; static mut STDOUT_FD: Option = None; static mut STDERR_FD: Option = None; +static DEFAULT_CONTAINER_ROOT_DIR: &str = " /run/containerd/wasmedge"; + type ExitCode = (Mutex)>>, Condvar); pub struct Wasi { + id: String, + exit_code: Arc, - engine: Vm, stdin: String, stdout: String, stderr: String, bundle: String, - pidfd: Arc>>, + rootdir: PathBuf, +} + +fn construct_container_root>(root_path: P, container_id: &str) -> Result { + let root_path = fs::canonicalize(&root_path).with_context(|| { + format!( + "failed to canonicalize {} for container {}", + root_path.as_ref().display(), + container_id + ) + })?; + Ok(root_path.join(container_id)) +} + +fn load_container>(root_path: P, container_id: &str) -> Result { + let container_root = construct_container_root(root_path, container_id)?; + if !container_root.exists() { + bail!("container {} does not exist.", container_id) + } + + Container::load(container_root) + .with_context(|| format!("could not load state for container {container_id}")) +} + +fn container_exists>(root_path: P, container_id: &str) -> Result { + let container_root = construct_container_root(root_path, container_id)?; + Ok(container_root.exists()) } #[cfg(test)] @@ -69,7 +108,7 @@ mod tests { /// containerd can send an empty path or a non-existant path /// In both these cases we should just assume that the stdio stream was not setup (intentionally) /// Any other error is a real error. -pub fn maybe_open_stdio(path: &str) -> Result, Error> { +fn maybe_open_stdio(path: &str) -> Result, Error> { if path.is_empty() { return Ok(None); } @@ -82,13 +121,6 @@ pub fn maybe_open_stdio(path: &str) -> Result, Error> { } } -fn load_spec(bundle: String) -> Result { - let mut spec = oci::load(Path::new(&bundle).join("config.json").to_str().unwrap())?; - spec.canonicalize_rootfs(&bundle) - .map_err(|e| Error::Others(format!("error canonicalizing rootfs in spec: {}", e)))?; - Ok(spec) -} - pub fn reset_stdio() { unsafe { if STDIN_FD.is_some() { @@ -103,171 +135,170 @@ pub fn reset_stdio() { } } -pub fn prepare_module( - mut vm: Vm, - spec: &oci::Spec, - stdin_path: String, - stdout_path: String, - stderr_path: String, -) -> Result { - debug!("opening rootfs"); - let rootfs_path = oci::get_root(spec).to_str().unwrap(); - let root = format!("/:{}", rootfs_path); - let mut preopens = vec![root.as_str()]; - - debug!("opening mounts"); - let mut mounts = oci_utils::get_wasm_mounts(spec); - preopens.append(&mut mounts); - - let args = oci::get_args(spec); - let envs = oci_utils::env_to_wasi(spec); - - debug!("setting up wasi"); - let mut wasi_instance = vm.wasi_module()?; - wasi_instance.initialize( - Some(args.iter().map(|s| s as &str).collect()), - Some(envs.iter().map(|s| s as &str).collect()), - Some(preopens), - ); - - debug!("opening stdin"); - let stdin = maybe_open_stdio(&stdin_path).context("could not open stdin")?; - if stdin.is_some() { - unsafe { - STDIN_FD = Some(dup(STDIN_FILENO)); - dup2(stdin.unwrap(), STDIN_FILENO); - } - } +#[derive(Serialize, Deserialize)] +struct Options { + root: Option, +} - debug!("opening stdout"); - let stdout = maybe_open_stdio(&stdout_path).context("could not open stdout")?; - if stdout.is_some() { - unsafe { - STDOUT_FD = Some(dup(STDOUT_FILENO)); - dup2(stdout.unwrap(), STDOUT_FILENO); - } - } +fn determine_rootdir>(bundle: P, namespace: String) -> Result { + let mut file = match File::open(bundle.as_ref().join("options.json")) { + Ok(f) => f, + Err(err) => match err.kind() { + ErrorKind::NotFound => { + return Ok(<&str as Into>::into(DEFAULT_CONTAINER_ROOT_DIR).join(namespace)) + } + _ => return Err(err.into()), + }, + }; + let mut data = String::new(); + file.read_to_string(&mut data)?; + let options: Options = serde_json::from_str(&data)?; + Ok(options + .root + .unwrap_or(PathBuf::from(DEFAULT_CONTAINER_ROOT_DIR)) + .join(namespace)) +} - debug!("opening stderr"); - let stderr = maybe_open_stdio(&stderr_path).context("could not open stderr")?; - if stderr.is_some() { - unsafe { - STDERR_FD = Some(dup(STDERR_FILENO)); - dup2(stderr.unwrap(), STDERR_FILENO); - } - } +#[cfg(test)] +mod rootdirtest { + use super::*; + use tempfile::tempdir; - let mut cmd = args[0].clone(); - let stripped = args[0].strip_prefix(std::path::MAIN_SEPARATOR); - if let Some(strpd) = stripped { - cmd = strpd.to_string(); + #[test] + fn test_determine_rootdir_with_options_file() -> Result<(), Error> { + let namespace = "test_namespace"; + let dir = tempdir()?; + let rootdir = dir.path().join("runwasi"); + let opts = Options { + root: Some(rootdir.clone()), + }; + let opts_file = OpenOptions::new() + .read(true) + .create(true) + .truncate(true) + .write(true) + .open(dir.path().join("options.json"))?; + write!(&opts_file, "{}", serde_json::to_string(&opts)?)?; + let root = determine_rootdir(dir.path(), namespace.into())?; + assert_eq!(root, rootdir.join(namespace)); + return Ok(()); } - let mod_path = oci::get_root(spec).join(cmd); - - debug!("register module from file"); - let vm = vm.register_module_from_file("main", mod_path)?; - - Ok(vm) + #[test] + fn test_determine_rootdir_without_options_file() -> Result<(), Error> { + let dir = tempdir()?; + let namespace = "test_namespace"; + let root = determine_rootdir(dir.path(), namespace.into())?; + assert_eq!( + root, + PathBuf::from(DEFAULT_CONTAINER_ROOT_DIR).join(namespace) + ); + return Ok(()); + } } impl Instance for Wasi { type E = Vm; - fn new(_id: String, cfg: Option<&InstanceConfig>) -> Self { + fn new(id: String, cfg: Option<&InstanceConfig>) -> Self { let cfg = cfg.unwrap(); // TODO: handle error + let bundle = cfg.get_bundle().unwrap_or_default(); + let namespace = cfg.get_namespace(); Wasi { + id, + rootdir: determine_rootdir(bundle.as_str(), namespace).unwrap(), exit_code: Arc::new((Mutex::new(None), Condvar::new())), - engine: cfg.get_engine(), stdin: cfg.get_stdin().unwrap_or_default(), stdout: cfg.get_stdout().unwrap_or_default(), stderr: cfg.get_stderr().unwrap_or_default(), - bundle: cfg.get_bundle().unwrap_or_default(), - pidfd: Arc::new(Mutex::new(None)), + bundle, } } - fn start(&self) -> Result { - let engine = self.engine.clone(); - let stdin = self.stdin.clone(); - let stdout = self.stdout.clone(); - let stderr = self.stderr.clone(); + fn start(&self) -> Result { debug!("preparing module"); - let spec = load_spec(self.bundle.clone())?; - - let vm = prepare_module(engine, &spec, stdin, stdout, stderr) - .map_err(|e| Error::Others(format!("error setting up module: {}", e)))?; - - let cg = oci::get_cgroup(&spec)?; - - oci::setup_cgroup(cg.as_ref(), &spec) - .map_err(|e| Error::Others(format!("error setting up cgroups: {}", e)))?; - let res = unsafe { exec::fork(Some(cg.as_ref())) }?; - match res { - exec::Context::Parent(tid, pidfd) => { - let mut lr = self.pidfd.lock().unwrap(); - *lr = Some(pidfd.clone()); - - debug!("started wasi instance with tid {}", tid); - - let code = self.exit_code.clone(); - - let _ = thread::spawn(move || { - let (lock, cvar) = &*code; - let status = match pidfd.wait() { - Ok(status) => status, - Err(e) => { - error!("error waiting for pid {}: {}", tid, e); - cvar.notify_all(); - return; - } - }; - - debug!("wasi instance exited with status {}", status.status); - let mut ec = lock.lock().unwrap(); - *ec = Some((status.status, Utc::now())); - drop(ec); - cvar.notify_all(); - }); - Ok(tid) - } - exec::Context::Child => { - // child process - - // TODO: How to get exit code? - // This was relatively straight forward in go, but wasi and wasmtime are totally separate things in rust. - let _ret = match vm.run_func(Some("main"), "_start", params!()) { - Ok(_) => std::process::exit(0), - Err(_) => std::process::exit(137), - }; - } - } + + let syscall = create_syscall(); + + fs::create_dir_all(&self.rootdir)?; + + let mut container = ContainerBuilder::new(self.id.clone(), syscall.as_ref()) + .with_executor(vec![Box::new(WasmEdgeExecutor { + stdin: maybe_open_stdio(self.stdin.as_str()).context("could not open stdin")?, + stdout: maybe_open_stdio(self.stdout.as_str()).context("could not open stdout")?, + stderr: maybe_open_stdio(self.stderr.as_str()).context("could not open stderr")?, + })])? + .with_root_path(self.rootdir.clone())? + .as_init(&self.bundle) + .with_systemd(false) + .build()?; + + let code = self.exit_code.clone(); + let pid = container.pid().unwrap(); + container.start()?; + + thread::spawn(move || { + let (lock, cvar) = &*code; + + let status = match waitid(WaitID::Pid(pid), WaitPidFlag::WEXITED) { + Ok(WaitStatus::Exited(_, status)) => status, + Ok(WaitStatus::Signaled(_, sig, _)) => sig as i32, + Ok(_) => 0, + Err(e) => { + if e == Errno::ECHILD { + 0 + } else { + panic!("waitpid failed: {}", e); + } + } + } as u32; + let mut ec = lock.lock().unwrap(); + *ec = Some((status, Utc::now())); + drop(ec); + cvar.notify_all(); + }); + + Ok(pid.as_raw() as u32) } fn kill(&self, signal: u32) -> Result<(), Error> { if signal as i32 != SIGKILL && signal as i32 != SIGINT { - println!("{:?}", signal); return Err(Error::InvalidArgument( "only SIGKILL and SIGINT are supported".to_string(), )); } - let lr = self.pidfd.lock().unwrap(); - let fd = lr - .as_ref() - .ok_or_else(|| Error::FailedPrecondition("module is not running".to_string()))?; - fd.kill(SIGKILL as i32) + let mut container = load_container(&self.rootdir, self.id.as_str())?; + match container.kill(Signal::try_from(signal as i32)?, true) { + Ok(_) => Ok(()), + Err(e) => { + if container.status() == ContainerStatus::Stopped { + return Err(Error::Others("container not running".into())); + } + Err(Error::Others(e.to_string())) + } + } } fn delete(&self) -> Result<(), Error> { - let spec = match load_spec(self.bundle.clone()) { - Ok(spec) => spec, + match container_exists(&self.rootdir, self.id.as_str()) { + Ok(exists) => { + if !exists { + return Ok(()); + } + } Err(err) => { - error!("Could not load spec, skipping cgroup cleanup: {}", err); + error!("could not find the container, skipping cleanup: {}", err); return Ok(()); } - }; - let cg = oci::get_cgroup(&spec)?; - cg.delete()?; + } + match load_container(&self.rootdir, self.id.as_str()) { + Ok(mut container) => container.delete(true)?, + Err(err) => { + error!("could not find the container, skipping cleanup: {}", err); + return Ok(()); + } + } + Ok(()) } @@ -292,9 +323,13 @@ mod wasitest { use std::borrow::Cow; use std::fs::{create_dir, read_to_string, File}; use std::io::prelude::*; + use std::os::unix::fs::OpenOptionsExt; use std::sync::mpsc::channel; use std::time::Duration; + use containerd_shim_wasm::function; + use containerd_shim_wasm::sandbox::exec::has_cap_sys_admin; + use containerd_shim_wasm::sandbox::testutil::run_test_with_sudo; use oci_spec::runtime::{ProcessBuilder, RootBuilder, SpecBuilder}; use tempfile::{tempdir, TempDir}; @@ -347,8 +382,26 @@ mod wasitest { fn run_wasi_test(dir: &TempDir, wasmbytes: Cow<[u8]>) -> Result<(u32, DateTime), Error> { create_dir(dir.path().join("rootfs"))?; - - let mut f = File::create(dir.path().join("rootfs/hello.wasm"))?; + let rootdir = dir.path().join("runwasi"); + create_dir(&rootdir)?; + let opts = Options { + root: Some(rootdir), + }; + let opts_file = OpenOptions::new() + .read(true) + .create(true) + .truncate(true) + .write(true) + .open(dir.path().join("options.json"))?; + write!(&opts_file, "{}", serde_json::to_string(&opts)?)?; + + let wasm_path = dir.path().join("rootfs/hello.wasm"); + let mut f = OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .mode(0o755) + .open(wasm_path)?; f.write_all(&wasmbytes)?; let stdout = File::create(dir.path().join("stdout"))?; @@ -359,14 +412,14 @@ mod wasitest { .process( ProcessBuilder::default() .cwd("/") - .args(vec!["hello.wasm".to_string()]) + .args(vec!["./hello.wasm".to_string()]) .build()?, ) .build()?; spec.save(dir.path().join("config.json"))?; - let mut cfg = InstanceConfig::new(Wasi::new_engine()?); + let mut cfg = InstanceConfig::new(Wasi::new_engine()?, "test_namespace".into()); let cfg = cfg .set_bundle(dir.path().to_str().unwrap().to_string()) .set_stdout(dir.path().join("stdout").to_str().unwrap().to_string()); @@ -375,11 +428,8 @@ mod wasitest { wasi.start()?; - let w = wasi.clone(); let (tx, rx) = channel(); - thread::spawn(move || { - w.wait(tx).unwrap(); - }); + wasi.wait(tx).unwrap(); let res = match rx.recv_timeout(Duration::from_secs(10)) { Ok(res) => Ok(res), @@ -391,22 +441,32 @@ mod wasitest { ))); } }; - return res; + wasi.delete()?; + res } #[test] + #[serial] fn test_delete_after_create() { let config = ConfigBuilder::new(CommonConfigOptions::default()) .build() .unwrap(); let vm = Vm::new(Some(config)).unwrap(); - let i = Wasi::new("".to_string(), Some(&InstanceConfig::new(vm))); + let i = Wasi::new( + "".to_string(), + Some(&InstanceConfig::new(vm, "test_namespace".into())), + ); i.delete().unwrap(); } #[test] #[serial] fn test_wasi() -> Result<(), Error> { + if !has_cap_sys_admin() { + println!("running test with sudo: {}", function!()); + return run_test_with_sudo(function!()); + } + let dir = tempdir()?; let path = dir.path(); let wasmbytes = wat2wasm(WASI_HELLO_WAT).unwrap(); @@ -425,6 +485,11 @@ mod wasitest { #[test] #[serial] fn test_wasi_error() -> Result<(), Error> { + if !has_cap_sys_admin() { + println!("running test with sudo: {}", function!()); + return run_test_with_sudo(function!()); + } + let dir = tempdir()?; let wasmbytes = wat2wasm(WASI_RETURN_ERROR).unwrap(); diff --git a/crates/containerd-shim-wasmedge/src/lib.rs b/crates/containerd-shim-wasmedge/src/lib.rs index 32504a244..cd03ebddd 100644 --- a/crates/containerd-shim-wasmedge/src/lib.rs +++ b/crates/containerd-shim-wasmedge/src/lib.rs @@ -1,3 +1,4 @@ pub mod error; +pub mod executor; pub mod instance; pub mod oci_utils; diff --git a/crates/containerd-shim-wasmtime/src/instance.rs b/crates/containerd-shim-wasmtime/src/instance.rs index 83be8a2fb..883a97eb9 100644 --- a/crates/containerd-shim-wasmtime/src/instance.rs +++ b/crates/containerd-shim-wasmtime/src/instance.rs @@ -318,7 +318,10 @@ mod wasitest { fn test_delete_after_create() { let i = Wasi::new( "".to_string(), - Some(&InstanceConfig::new(Engine::default())), + Some(&InstanceConfig::new( + Engine::default(), + "test_namespace".into(), + )), ); i.delete().unwrap(); } @@ -346,7 +349,7 @@ mod wasitest { spec.save(dir.path().join("config.json"))?; - let mut cfg = InstanceConfig::new(Engine::default()); + let mut cfg = InstanceConfig::new(Engine::default(), "test_namespace".into()); let cfg = cfg .set_bundle(dir.path().to_str().unwrap().to_string()) .set_stdout(dir.path().join("stdout").to_str().unwrap().to_string()); diff --git a/test/k8s/Dockerfile b/test/k8s/Dockerfile index c21dfcd5a..62763168a 100644 --- a/test/k8s/Dockerfile +++ b/test/k8s/Dockerfile @@ -12,7 +12,7 @@ ENV PATH="/root/.cargo/bin:${PATH}" RUN rustup install stable WORKDIR /shim COPY . . -RUN apt-get update && apt-get install --no-install-recommends -y build-essential git clang +RUN apt-get update && apt-get install --no-install-recommends -y build-essential git clang pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev RUN curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- --version=0.11.2 RUN \ --mount=type=cache,target=/usr/local/cargo/registry \