diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5e01b90..4b212224 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: #os: [macos-latest, windows-latest, ubuntu-latest] - os: [macos-latest, ubuntu-latest] + os: [ubuntu-latest] steps: - name: Checkout diff --git a/Cargo.lock b/Cargo.lock index ccc3f8af..9190368f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ "actix-service", "actix-utils", "ahash", - "base64", + "base64 0.13.0", "bitflags", "brotli", "bytes", @@ -63,7 +63,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -194,7 +194,7 @@ checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -227,7 +227,7 @@ dependencies = [ "actix-tls", "actix-utils", "ahash", - "base64", + "base64 0.13.0", "bytes", "cfg-if", "cookie", @@ -254,6 +254,24 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bigdecimal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1e50562e37200edf7c6c43e54a08e64a5553bfb59d9c297d5572512aa517256" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -275,7 +293,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c92fed694fd5a7468c971538351c61b9c115f1ae6ed411cd2800f0f299403a4b" dependencies = [ - "base64", + "base64 0.13.0", "bollard-stubs", "bytes", "chrono", @@ -307,7 +325,7 @@ checksum = "ed2f2e73fffe9455141e170fb9c1feb0ac521ec7e7dcd47a7cab72a658490fb8" dependencies = [ "chrono", "serde", - "serde_with", + "serde_with 1.11.0", ] [[package]] @@ -355,6 +373,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +[[package]] +name = "bytesize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" +dependencies = [ + "serde", +] + [[package]] name = "bytestring" version = "1.1.0" @@ -560,7 +587,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.109", ] [[package]] @@ -577,7 +604,7 @@ checksum = "747b608fecf06b0d72d440f27acc99288207324b793be2c17991839f3d4995ea" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -586,8 +613,18 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.13.0", + "darling_macro 0.13.0", +] + +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -601,7 +638,21 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.11.1", + "syn 2.0.43", ] [[package]] @@ -610,9 +661,20 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" dependencies = [ - "darling_core", + "darling_core 0.13.0", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core 0.20.10", + "quote", + "syn 2.0.43", ] [[package]] @@ -631,7 +693,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.109", ] [[package]] @@ -715,7 +777,7 @@ dependencies = [ "heck 0.4.0", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -744,6 +806,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.1" @@ -908,7 +976,7 @@ dependencies = [ "proc-macro-hack", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1011,7 +1079,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.1", "slab", "tokio", "tokio-util 0.7.3", @@ -1024,6 +1092,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "heck" version = "0.3.3" @@ -1206,7 +1280,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", + "serde", ] [[package]] @@ -1536,6 +1622,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1643,7 +1740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.1", ] [[package]] @@ -1663,7 +1760,7 @@ checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1723,7 +1820,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 1.0.109", ] [[package]] @@ -1784,7 +1881,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1813,9 +1910,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.59" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1862,7 +1959,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2116,31 +2213,40 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.145" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] +[[package]] +name = "serde_bytes" +version = "0.11.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.43", ] [[package]] name = "serde_json" -version = "1.0.70" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e277c495ac6cd1a01a58d0a0c574568b4d1ddf14f59965c6a58b8d96400b54f3" +checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9" dependencies = [ - "itoa 0.4.8", + "itoa 1.0.2", "ryu", "serde", ] @@ -2165,7 +2271,25 @@ checksum = "ad6056b4cb69b6e43e3a0f055def223380baecc99da683884f205bf347f7c4b3" dependencies = [ "rustversion", "serde", - "serde_with_macros", + "serde_with_macros 1.5.1", +] + +[[package]] +name = "serde_with" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.1", + "indexmap 2.4.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros 3.8.1", + "time 0.3.11", ] [[package]] @@ -2174,10 +2298,22 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12e47be9471c72889ebafb5e14d5ff930d89ae7a67bbdb5f8abb564f845a927e" dependencies = [ - "darling", + "darling 0.13.0", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "serde_with_macros" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +dependencies = [ + "darling 0.20.10", + "proc-macro2", + "quote", + "syn 2.0.43", ] [[package]] @@ -2186,7 +2322,7 @@ version = "0.9.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8613d593412a0deb7bbd8de9d908efff5a0cb9ccd8f62c641e7b2ed2f57291d1" dependencies = [ - "indexmap", + "indexmap 1.9.1", "itoa 1.0.2", "ryu", "serde", @@ -2266,6 +2402,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "structopt" version = "0.3.25" @@ -2287,7 +2429,26 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.0", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", ] [[package]] @@ -2301,6 +2462,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tar" version = "0.4.37" @@ -2381,7 +2553,7 @@ checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2403,6 +2575,7 @@ dependencies = [ "itoa 1.0.2", "libc", "num_threads", + "serde", "time-macros", ] @@ -2465,7 +2638,7 @@ checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2532,7 +2705,7 @@ checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2758,7 +2931,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -2780,7 +2953,7 @@ checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3032,6 +3205,25 @@ dependencies = [ "libc", ] +[[package]] +name = "ya-client-model" +version = "0.7.0" +source = "git+https://github.com/golemfactory/ya-client.git?rev=c74a2b323a7fc5f077d5ff5c229bd1e1e709513a#c74a2b323a7fc5f077d5ff5c229bd1e1e709513a" +dependencies = [ + "bigdecimal", + "bytesize", + "chrono", + "derive_more", + "rand 0.8.4", + "serde", + "serde_bytes", + "serde_json", + "serde_with 3.8.1", + "strum", + "strum_macros", + "thiserror", +] + [[package]] name = "ya-runtime-api" version = "0.6.0" @@ -3078,7 +3270,7 @@ source = "git+https://github.com/golemfactory/ya-runtime-sdk.git?rev=0395b0c704e dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3104,6 +3296,7 @@ dependencies = [ "tokio-byteorder", "url", "uuid", + "ya-client-model", "ya-runtime-sdk", ] diff --git a/README.md b/README.md index 5231c72d..f1d26246 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ Prerequisites: Recommendation: use the Rust toolchain installer from [https://rustup.rs/](https://rustup.rs/) -- `musl-gcc` +- `musl-gcc` and `gperf` On a Ubuntu system, execute in terminal: ```bash - sudo apt install musl musl-tools + sudo apt install musl musl-tools gperf ``` Git checkout: diff --git a/gvmkit/src/image_builder.rs b/gvmkit/src/image_builder.rs index c26e573e..6caebc91 100644 --- a/gvmkit/src/image_builder.rs +++ b/gvmkit/src/image_builder.rs @@ -153,7 +153,7 @@ async fn repack( let squashfs_image = "prekucki/squashfs-tools:latest"; let squashfs_cont = "sqfs-tools"; - let start_cmd = vec!["tail", "-f", "/dev/null"]; // prevent container from exiting + let start_cmd = ["tail", "-f", "/dev/null"]; // prevent container from exiting let options = ContainerOptions { image_name: squashfs_image.to_owned(), container_name: squashfs_cont.to_owned(), diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index c1caf7c9..df722304 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -7,20 +7,64 @@ license = "GPL-3.0" [package.metadata.deb] assets = [ - ["target/release/ya-runtime-vm", "usr/lib/yagna/plugins/ya-runtime-vm/", "755"], - ["conf/ya-runtime-vm.json", "usr/lib/yagna/plugins/", "644"], + [ + "target/release/ya-runtime-vm", + "usr/lib/yagna/plugins/ya-runtime-vm/", + "755", + ], + [ + "conf/ya-runtime-vm.json", + "usr/lib/yagna/plugins/", + "644", + ], # self-test.gvmi is downloaded by .github/workflows/release.yml from https://github.com/golemfactory/ya-self-test-img/releases - ["image/self-test.gvmi", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "644"], + [ + "image/self-test.gvmi", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "644", + ], - ["poc/runtime/vmrt", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "755"], - ["poc/runtime/vgabios-stdvga.bin", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "644"], - ["poc/runtime/bios-256k.bin", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "644"], - ["poc/runtime/kvmvapic.bin", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "644"], - ["poc/runtime/linuxboot_dma.bin", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "644"], - ["poc/runtime/efi-virtio.rom", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "644"], + [ + "poc/runtime/vmrt", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "755", + ], + [ + "poc/runtime/vgabios-stdvga.bin", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "644", + ], + [ + "poc/runtime/bios-256k.bin", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "644", + ], + [ + "poc/runtime/kvmvapic.bin", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "644", + ], + [ + "poc/runtime/linuxboot_dma.bin", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "644", + ], + [ + "poc/runtime/efi-virtio.rom", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "644", + ], - ["init-container/initramfs.cpio.gz", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "644"], - ["init-container/vmlinuz-virt", "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", "644"], + [ + "init-container/initramfs.cpio.gz", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "644", + ], + [ + "init-container/vmlinuz-virt", + "usr/lib/yagna/plugins/ya-runtime-vm/runtime/", + "644", + ], ] [dependencies.ya-runtime-sdk] @@ -42,10 +86,22 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "1.0" strip-ansi-escapes = "0.1.0" structopt = "0.3" -tokio = { version = "1.21.2", features = ["fs", "io-std", "io-util", "macros", "process", "rt", "rt-multi-thread", "sync", "time", "net"] } +tokio = { version = "1.21.2", features = [ + "fs", + "io-std", + "io-util", + "macros", + "process", + "rt", + "rt-multi-thread", + "sync", + "time", + "net", +] } tokio-byteorder = "0.3" uuid = { version = "1.1", features = ["v4"] } url = "2.3" +ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "c74a2b323a7fc5f077d5ff5c229bd1e1e709513a" } [dev-dependencies] env_logger = "0.10" diff --git a/runtime/examples/commands.rs b/runtime/examples/commands.rs index 11656176..6b2e2259 100644 --- a/runtime/examples/commands.rs +++ b/runtime/examples/commands.rs @@ -128,10 +128,7 @@ async fn main() -> anyhow::Result<()> { { let run = server::RunProcess { bin: "/bin/ls".to_string(), - args: vec!["ls", "-al", "."] - .iter() - .map(|s| s.to_string()) - .collect(), + args: ["ls", "-al", "."].iter().map(|s| s.to_string()).collect(), work_dir: "/".to_string(), stdout: None, stderr: None, @@ -165,10 +162,12 @@ async fn main() -> anyhow::Result<()> { .pid; log::info!("pid: {}", pid); - c.kill_process(server::KillProcess { + let fut = c.kill_process(server::KillProcess { pid, signal: 0, // TODO }); + std::mem::drop(fut); + events.process_died(pid).notified().await; } diff --git a/runtime/src/cpu.rs b/runtime/src/cpu.rs index 2ec1c820..49c65cf9 100644 --- a/runtime/src/cpu.rs +++ b/runtime/src/cpu.rs @@ -131,49 +131,46 @@ fn cpu_features(info: &CpuId) -> anyhow::Result> { (has_tm, TM), (has_pbe, PBE) ); - capabilities.extend( - flags!( - ext_features, - (has_fsgsbase, FSGSBASE), - (has_tsc_adjust_msr, ADJUST_MSR), - (has_bmi1, BMI1), - (has_hle, HLE), - (has_avx2, AVX2), - (has_fdp, FDP), - (has_smep, SMEP), - (has_bmi2, BMI2), - (has_rep_movsb_stosb, REP_MOVSB_STOSB), - (has_invpcid, INVPCID), - (has_rtm, RTM), - (has_rdtm, RDTM), - (has_fpu_cs_ds_deprecated, DEPRECATE_FPU_CS_DS), - (has_mpx, MPX), - (has_rdta, RDTA), - (has_rdseed, RDSEED), - (has_adx, ADX), - (has_smap, SMAP), - (has_clflushopt, CLFLUSHOPT), - (has_processor_trace, PROCESSOR_TRACE), - (has_sha, SHA), - (has_sgx, SGX), - (has_avx512f, AVX512F), - (has_avx512dq, AVX512DQ), - (has_avx512_ifma, AVX512_IFMA), - (has_avx512pf, AVX512PF), - (has_avx512er, AVX512ER), - (has_avx512cd, AVX512CD), - (has_avx512bw, AVX512BW), - (has_avx512vl, AVX512VL), - (has_clwb, CLWB), - (has_prefetchwt1, PREFETCHWT1), - (has_umip, UMIP), - (has_pku, PKU), - (has_ospke, OSPKE), - (has_rdpid, RDPID), - (has_sgx_lc, SGX_LC) - ) - .into_iter(), - ); + capabilities.extend(flags!( + ext_features, + (has_fsgsbase, FSGSBASE), + (has_tsc_adjust_msr, ADJUST_MSR), + (has_bmi1, BMI1), + (has_hle, HLE), + (has_avx2, AVX2), + (has_fdp, FDP), + (has_smep, SMEP), + (has_bmi2, BMI2), + (has_rep_movsb_stosb, REP_MOVSB_STOSB), + (has_invpcid, INVPCID), + (has_rtm, RTM), + (has_rdtm, RDTM), + (has_fpu_cs_ds_deprecated, DEPRECATE_FPU_CS_DS), + (has_mpx, MPX), + (has_rdta, RDTA), + (has_rdseed, RDSEED), + (has_adx, ADX), + (has_smap, SMAP), + (has_clflushopt, CLFLUSHOPT), + (has_processor_trace, PROCESSOR_TRACE), + (has_sha, SHA), + (has_sgx, SGX), + (has_avx512f, AVX512F), + (has_avx512dq, AVX512DQ), + (has_avx512_ifma, AVX512_IFMA), + (has_avx512pf, AVX512PF), + (has_avx512er, AVX512ER), + (has_avx512cd, AVX512CD), + (has_avx512bw, AVX512BW), + (has_avx512vl, AVX512VL), + (has_clwb, CLWB), + (has_prefetchwt1, PREFETCHWT1), + (has_umip, UMIP), + (has_pku, PKU), + (has_ospke, OSPKE), + (has_rdpid, RDPID), + (has_sgx_lc, SGX_LC) + )); Ok(capabilities) } diff --git a/runtime/src/deploy.rs b/runtime/src/deploy.rs index 81b6851b..aec7a02d 100644 --- a/runtime/src/deploy.rs +++ b/runtime/src/deploy.rs @@ -72,7 +72,7 @@ impl Deployment { .env .as_ref() .map(|v| v.iter().map(|s| s.as_str()).collect()) - .unwrap_or_else(Vec::new) + .unwrap_or_default() } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index fcebe01c..420861cd 100755 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -9,6 +9,7 @@ use bollard_stubs::models::ContainerConfig; use futures::future::FutureExt; use futures::lock::Mutex; use futures::TryFutureExt; +use std::collections::HashMap; use std::convert::TryFrom; use std::env; use std::path::{Component, Path, PathBuf}; @@ -20,6 +21,8 @@ use tokio::{ io::{self, AsyncWriteExt}, }; use url::Url; +use uuid::Uuid; +use ya_client_model::activity::exe_script_command::VolumeInfo; use crate::{ cpu::CpuInfo, @@ -27,7 +30,7 @@ use crate::{ guest_agent_comm::{RedirectFdType, RemoteCommandResult}, vmrt::{start_vmrt, RuntimeData}, }; -use ya_runtime_sdk::runtime_api::deploy::ContainerEndpoint; +use ya_runtime_sdk::runtime_api::deploy::{ContainerEndpoint, ContainerVolume}; use ya_runtime_sdk::{ runtime_api::{ @@ -72,6 +75,8 @@ pub struct Cli { /// PCI device identifier #[structopt(long, env = "YA_RUNTIME_VM_PCI_DEVICE")] pci_device: Option>, + #[structopt(long, env = "YA_RUNTIME_VOLUME_OVERRIDE")] + volume_override: Option, #[structopt(flatten)] test_config: TestConfig, } @@ -253,8 +258,12 @@ async fn deploy(workdir: PathBuf, cli: Cli) -> anyhow::Result>(&vo_str)) + .transpose()?; - let deployment = Deployment::try_from_input( + let mut deployment = Deployment::try_from_input( package_file, cli.cpu_cores, (cli.mem_gib * 1024.) as usize, @@ -263,6 +272,20 @@ async fn deploy(workdir: PathBuf, cli: Cli) -> anyhow::Result