From 6a4fb7aac65b19c3a93dd2f073953d3578af9a45 Mon Sep 17 00:00:00 2001 From: Xuewei Niu Date: Wed, 15 Nov 2023 15:23:41 +0800 Subject: [PATCH 1/2] Support adding vhost-net network devices Argument `virnets` receives a JSON string of `NetworkInterfaceConfig`, rather than `VirtioNetDeviceConfigInfo`. It allows user to add any network devices according to item's backend type. Signed-off-by: Xuewei Niu --- Cargo.lock | 1208 ++++++++++++++++++++++++++++++++--------- Cargo.toml | 1 + README.md | 65 ++- src/api_client.rs | 6 +- src/api_server.rs | 9 +- src/cli_instance.rs | 14 +- src/parser/args.rs | 4 +- src/vmm_comm_trait.rs | 9 +- 8 files changed, 1016 insertions(+), 300 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 627e64c..e124cbc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,21 +2,27 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.69" @@ -59,19 +65,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "backtrace" -version = "0.3.67" +name = "base64" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bitflags" @@ -79,6 +76,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "blake3" version = "1.3.3" @@ -102,6 +105,12 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + [[package]] name = "byteorder" version = "1.4.3" @@ -139,13 +148,27 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.48.5", +] + [[package]] name = "clap" version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex", "is-terminal", @@ -164,7 +187,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -191,6 +214,16 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -246,23 +279,22 @@ dependencies = [ [[package]] name = "dbs-address-space" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bcc37dc0b8ffae1c5911d13ae630dc7a9020fa0de0edd178d6ab71daf56c8fc" +version = "0.3.0" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "arc-swap", + "lazy_static", "libc", "nix 0.23.2", "thiserror", "vm-memory", - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] [[package]] name = "dbs-allocator" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543711b94b4bc1437d2ebb45f856452e96a45a67ab39f8dcf8c887c2a3701004" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "thiserror", ] @@ -270,8 +302,7 @@ dependencies = [ [[package]] name = "dbs-arch" version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194c844946cd1d13f7a9eb29b84afbc5354578eee2b06fea96226bc3872e7424" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "kvm-bindings", "kvm-ioctls", @@ -279,14 +310,13 @@ dependencies = [ "memoffset", "thiserror", "vm-memory", - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] [[package]] name = "dbs-boot" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a74a8c05a1674d3032e610b4f201c7440c345559bad3dfe6b455ce195785108" +version = "0.4.0" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "dbs-arch", "kvm-bindings", @@ -321,14 +351,13 @@ dependencies = [ "slog-stdlog", "slog-term", "thiserror", - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] [[package]] name = "dbs-device" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ecea44b4bc861c0c2ccb51868bea781286dc70e40ae46b54d4511e690a654a" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "thiserror", ] @@ -336,36 +365,34 @@ dependencies = [ [[package]] name = "dbs-interrupt" version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eb2c5bb9f8f123ace33b1b2e8d53dd2d87331ee770ad1f82e56c3382c6bed6d" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "dbs-arch", "dbs-device", "kvm-bindings", "kvm-ioctls", "libc", - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] [[package]] name = "dbs-legacy-devices" version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4d089ac1c4d186c8133be59de09462e9793f7add10017c5b040318a3a7f431f" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "dbs-device", "dbs-utils", + "libc", "log", "serde", "vm-superio", - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] [[package]] name = "dbs-upcall" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "699e62afa444ae4b00d474fd91bc37785ba050acdfbe179731c81898e32efc3f" +version = "0.3.0" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "anyhow", "dbs-utils", @@ -378,8 +405,7 @@ dependencies = [ [[package]] name = "dbs-utils" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb6ff873451b76e22789af7fbe1d0478c42c717f817e66908be7a3a2288068c" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "anyhow", "event-manager", @@ -388,14 +414,13 @@ dependencies = [ "serde", "thiserror", "timerfd", - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] [[package]] name = "dbs-virtio-devices" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88e5c6c48b766afb95851b04b6b193871a59d0b2a3ed19990d4f8f651ae5c668" +version = "0.3.1" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ "byteorder", "caps", @@ -409,26 +434,39 @@ dependencies = [ "kvm-ioctls", "libc", "log", - "nix 0.23.2", + "nix 0.24.3", "nydus-api", - "nydus-blobfs", "nydus-rafs", + "nydus-storage", "rlimit", + "sendfd", "serde", "serde_json", "thiserror", "threadpool", + "vhost", "virtio-bindings", "virtio-queue", "vm-memory", - "vmm-sys-util 0.11.1", + "vmm-sys-util", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -459,8 +497,9 @@ dependencies = [ [[package]] name = "dragonball" version = "0.1.0" -source = "git+https://github.com/kata-containers/kata-containers?branch=main#ee5dda012b3a8dca08eb1eea32ddac37b5355fd6" +source = "git+https://github.com/kata-containers/kata-containers?branch=main#f18794d88079840a48c5080221563377142a3339" dependencies = [ + "anyhow", "arc-swap", "bytes", "crossbeam-channel", @@ -474,6 +513,8 @@ dependencies = [ "dbs-upcall", "dbs-utils", "dbs-virtio-devices", + "derivative", + "fuse-backend-rs", "kvm-bindings", "kvm-ioctls", "lazy_static", @@ -481,6 +522,8 @@ dependencies = [ "linux-loader", "log", "nix 0.24.3", + "procfs 0.12.0", + "prometheus", "seccompiler", "serde", "serde_derive", @@ -488,9 +531,19 @@ dependencies = [ "slog", "slog-scope", "thiserror", + "tracing", "virtio-queue", "vm-memory", - "vmm-sys-util 0.11.1", + "vmm-sys-util", +] + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", ] [[package]] @@ -499,7 +552,7 @@ version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20df693c700404f7e19d4d6fae6b15215d2913c27955d2b9d6f2c0f537511cd0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", ] @@ -514,6 +567,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -531,9 +594,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "377fa591135fbe23396a18e2655a6d5481bf7c5823cdfa3cc81b01a229cbe640" dependencies = [ "libc", - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + [[package]] name = "filetime" version = "0.2.20" @@ -542,8 +611,8 @@ checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" dependencies = [ "cfg-if", "libc", - "redox_syscall", - "windows-sys", + "redox_syscall 0.2.16", + "windows-sys 0.45.0", ] [[package]] @@ -557,14 +626,44 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fuse-backend-rs" -version = "0.10.2" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08af89cb80a7c5693bd63a2b1ee7ac31a307670977c18fda036b3aa94be8c47f" +checksum = "f85357722be4bf3d0b7548bedf7499686c77628c2c61cb99c6519463f7a9e5f0" dependencies = [ "arc-swap", - "bitflags", + "bitflags 1.3.2", "caps", "core-foundation-sys", "lazy_static", @@ -572,25 +671,9 @@ dependencies = [ "log", "mio", "nix 0.24.3", - "tokio-uring", "virtio-queue", "vm-memory", - "vmm-sys-util 0.10.0", -] - -[[package]] -name = "futures" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", + "vmm-sys-util", ] [[package]] @@ -600,7 +683,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" dependencies = [ "futures-core", - "futures-sink", ] [[package]] @@ -609,34 +691,12 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" -[[package]] -name = "futures-executor" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - [[package]] name = "futures-io" version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" 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", -] - [[package]] name = "futures-sink" version = "0.3.27" @@ -655,11 +715,8 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" dependencies = [ - "futures-channel", "futures-core", "futures-io", - "futures-macro", - "futures-sink", "futures-task", "memchr", "pin-project-lite", @@ -689,10 +746,29 @@ dependencies = [ ] [[package]] -name = "gimli" -version = "0.27.2" +name = "h2" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" @@ -730,12 +806,129 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "http" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + [[package]] name = "httpdate" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "io-lifetimes" version = "1.0.6" @@ -743,7 +936,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -752,10 +945,16 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd1e1a01cfb924fd8c5c43b6827965db394f5a3a16c599ce03452266e1cf984c" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", ] +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + [[package]] name = "is-terminal" version = "0.4.4" @@ -764,8 +963,8 @@ checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" dependencies = [ "hermit-abi 0.3.3", "io-lifetimes", - "rustix", - "windows-sys", + "rustix 0.36.9", + "windows-sys 0.45.0", ] [[package]] @@ -783,13 +982,22 @@ dependencies = [ "libc", ] +[[package]] +name = "js-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "kvm-bindings" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efe70e65a5b092161d17f5005b66e5eefe7a94a70c332e755036fc4af78c4e79" dependencies = [ - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] [[package]] @@ -800,7 +1008,7 @@ checksum = "c3a321cabd827642499c77e27314f388dd83a717a5ca716b86476fb947f73ae4" dependencies = [ "kvm-bindings", "libc", - "vmm-sys-util 0.11.1", + "vmm-sys-util", ] [[package]] @@ -809,22 +1017,11 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "leaky-bucket" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e0d52231827974ba682f6257fd42a2f79749689f7ca0d763e198a0f7051c91" -dependencies = [ - "parking_lot", - "tokio", - "tracing", -] - [[package]] name = "libc" -version = "0.2.140" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libz-sys" @@ -841,9 +1038,9 @@ dependencies = [ [[package]] name = "linux-loader" -version = "0.6.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62a2f912deca034ec34b0a43a390059ea98daac40e440ebe8bea88f3315fe168" +checksum = "b9259ddbfbb52cc918f6bbc60390004ddd0228cf1d85f402009ff2b3d95de83f" dependencies = [ "vm-memory", ] @@ -854,6 +1051,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +[[package]] +name = "linux-raw-sys" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" + [[package]] name = "lock_api" version = "0.4.9" @@ -908,6 +1111,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "miniz_oxide" version = "0.6.2" @@ -926,16 +1135,34 @@ dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] -name = "nix" -version = "0.23.2" +name = "native-tls" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ - "bitflags", + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nix" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +dependencies = [ + "bitflags 1.3.2", "cc", "cfg-if", "libc", @@ -948,12 +1175,21 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset", ] +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.15.0" @@ -975,110 +1211,77 @@ dependencies = [ [[package]] name = "nydus-api" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1899def1a22ed32b1d60de4e444f525c4023a208ee0d1136a65399cff82837ce" +checksum = "c64c62d8a36c10b654b87246a39861b2c05f68e96ab3b2f002f5a54f406d5e0e" dependencies = [ "libc", "log", - "nydus-error", "serde", "serde_json", "toml", ] -[[package]] -name = "nydus-blobfs" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784cf6e1319da7a94734987dcc71d2940f74231256922431a505c832fc778dd3" -dependencies = [ - "fuse-backend-rs", - "libc", - "log", - "nydus-api", - "nydus-error", - "nydus-rafs", - "nydus-storage", - "serde", - "serde_json", - "vm-memory", -] - -[[package]] -name = "nydus-error" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae2ec1efd1589377dbefca6b1047294c71b2fbab164d93319f97b20faae92001" -dependencies = [ - "backtrace", - "httpdate", - "libc", - "log", - "serde", - "serde_json", -] - [[package]] name = "nydus-rafs" -version = "0.2.2" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ace6945daa16842e72e9fe7647e2b8715856f50f07350cce82bd68db1ed02c" +checksum = "adde865ef71c91c5f139c4c05ca5aedb6fbd53f530d646b13409ac5220b85467" dependencies = [ "anyhow", "arc-swap", - "bitflags", - "blake3", + "bitflags 1.3.2", "fuse-backend-rs", - "futures", "lazy_static", "libc", "log", - "lz4-sys", "nix 0.24.3", "nydus-api", - "nydus-error", "nydus-storage", "nydus-utils", "serde", "serde_json", - "spmc", "vm-memory", ] [[package]] name = "nydus-storage" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08bc5ea9054fca2ec8b19dcce25ea600679b7fbf035aad86cfe4a659002c88b" +checksum = "4023f15303dbbda47797d07e9acd2045862ce82c7e28cd66f70b09bda5584cbb" dependencies = [ "arc-swap", - "bitflags", + "base64", + "bitflags 1.3.2", "fuse-backend-rs", "hex", + "hmac", + "httpdate", "lazy_static", - "leaky-bucket", "libc", "log", "nix 0.24.3", "nydus-api", - "nydus-error", "nydus-utils", + "reqwest", "serde", "serde_json", + "sha1", "tar", "tokio", + "url", "vm-memory", ] [[package]] name = "nydus-utils" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1e681d7207a1ec500323d5ca39ebb7e381fc4f14db5ff0c532c18ff1226a81f" +checksum = "c1f7bcde0f3906cf49101f2d40e485b0155eee97e3358eefd4783448c4f69c96" dependencies = [ "blake3", "flate2", + "httpdate", "lazy_static", "libc", "libz-sys", @@ -1086,7 +1289,8 @@ dependencies = [ "lz4", "lz4-sys", "nix 0.24.3", - "nydus-error", + "nydus-api", + "openssl", "serde", "serde_json", "sha2", @@ -1095,19 +1299,64 @@ dependencies = [ ] [[package]] -name = "object" -version = "0.30.3" +name = "once_cell" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "openssl" +version = "0.10.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" dependencies = [ - "memchr", + "bitflags 2.4.1", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", ] [[package]] -name = "once_cell" -version = "1.17.1" +name = "openssl-macros" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-src" +version = "300.1.6+3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439fac53e092cd7442a3660c85dde4643ab3b5bd39040912388dcdabf6b88085" +dependencies = [ + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" +dependencies = [ + "cc", + "libc", + "openssl-src", + "pkg-config", + "vcpkg", +] [[package]] name = "os_str_bytes" @@ -1133,11 +1382,17 @@ checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", - "windows-sys", + "windows-sys 0.45.0", ] +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1165,7 +1420,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -1189,6 +1444,57 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "procfs" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0941606b9934e2d98a3677759a971756eb821f75764d0e0d26946d08e74d9104" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "chrono", + "flate2", + "hex", + "lazy_static", + "libc", +] + +[[package]] +name = "procfs" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de8dacb0873f77e6aefc6d71e044761fcc68060290f5b1089fcdf84626bb69" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "hex", + "lazy_static", + "rustix 0.36.9", +] + +[[package]] +name = "prometheus" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" +dependencies = [ + "cfg-if", + "fnv", + "lazy_static", + "libc", + "memchr", + "parking_lot", + "procfs 0.14.2", + "protobuf", + "thiserror", +] + +[[package]] +name = "protobuf" +version = "2.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" + [[package]] name = "quote" version = "1.0.26" @@ -1204,7 +1510,16 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", ] [[package]] @@ -1214,10 +1529,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.2.16", "thiserror", ] +[[package]] +name = "reqwest" +version = "0.11.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "rlimit" version = "0.7.0" @@ -1227,24 +1580,31 @@ dependencies = [ "libc", ] -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - [[package]] name = "rustix" version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" dependencies = [ - "bitflags", - "errno", + "bitflags 1.3.2", + "errno 0.2.8", "io-lifetimes", "libc", - "linux-raw-sys", - "windows-sys", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", +] + +[[package]] +name = "rustix" +version = "0.38.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" +dependencies = [ + "bitflags 2.4.1", + "errno 0.3.6", + "libc", + "linux-raw-sys 0.4.11", + "windows-sys 0.48.0", ] [[package]] @@ -1260,10 +1620,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] -name = "scoped-tls" -version = "1.0.1" +name = "schannel" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +dependencies = [ + "windows-sys 0.48.0", +] [[package]] name = "scopeguard" @@ -1280,6 +1643,38 @@ dependencies = [ "libc", ] +[[package]] +name = "security-framework" +version = "2.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "sendfd" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604b71b8fc267e13bb3023a2c901126c8f349393666a6d98ac1ae5729b701798" +dependencies = [ + "libc", +] + [[package]] name = "serde" version = "1.0.156" @@ -1297,7 +1692,7 @@ checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1311,6 +1706,29 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.6" @@ -1400,12 +1818,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "spmc" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a8428da277a8e3a15271d79943e80ccc2ef254e78813a166a08d65e4c3ece5" - [[package]] name = "strsim" version = "0.10.0" @@ -1429,6 +1841,38 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tar" version = "0.4.38" @@ -1440,6 +1884,19 @@ dependencies = [ "xattr", ] +[[package]] +name = "tempfile" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall 0.4.1", + "rustix 0.38.24", + "windows-sys 0.48.0", +] + [[package]] name = "term" version = "0.7.0" @@ -1477,7 +1934,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1534,9 +1991,24 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0664936efa25f2bbe03ca25b62c50f5f492abec07e59d6dcf45131014b33483f" dependencies = [ - "rustix", + "rustix 0.36.9", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", ] +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.26.0" @@ -1544,13 +2016,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", + "bytes", "libc", + "memchr", "mio", "num_cpus", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1561,23 +2035,33 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] -name = "tokio-uring" -version = "0.4.0" +name = "tokio-native-tls" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d5e02bb137e030b3a547c65a3bd2f1836d66a97369fdcc69034002b10e155ef" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ - "io-uring", - "libc", - "scoped-tls", - "slab", - "socket2", + "native-tls", "tokio", ] +[[package]] +name = "tokio-util" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.11" @@ -1587,6 +2071,12 @@ dependencies = [ "serde", ] +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -1607,7 +2097,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1619,18 +2109,50 @@ dependencies = [ "once_cell", ] +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + [[package]] name = "typenum" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + [[package]] name = "unicode-ident" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "vcpkg" version = "0.2.15" @@ -1643,6 +2165,18 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "vhost" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6769e8dbf5276b4376439fbf36bb880d203bf614bf7ef444198edc24b5a9f35" +dependencies = [ + "bitflags 1.3.2", + "libc", + "vm-memory", + "vmm-sys-util", +] + [[package]] name = "virtio-bindings" version = "0.1.0" @@ -1651,14 +2185,14 @@ checksum = "3ff512178285488516ed85f15b5d0113a7cdb89e9e8a760b269ae4f02b84bd6b" [[package]] name = "virtio-queue" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435dd49c7b38419729afd43675850c7b5dc4728f2fabd70c7a9079a331e4f8c6" +checksum = "3ba81e2bcc21c0d2fc5e6683e79367e26ad219197423a498df801d79d5ba77bd" dependencies = [ "log", "virtio-bindings", "vm-memory", - "vmm-sys-util 0.10.0", + "vmm-sys-util", ] [[package]] @@ -1669,9 +2203,9 @@ checksum = "f43fb5a6bd1a7d423ad72802801036719b7546cf847a103f8fe4575f5b0d45a6" [[package]] name = "vm-memory" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583f213899e8a5eea23d9c507252d4bed5bc88f0ecbe0783262f80034630744b" +checksum = "688a70366615b45575a424d9c665561c1b5ab2224d494f706b6a6812911a827c" dependencies = [ "arc-swap", "libc", @@ -1686,22 +2220,21 @@ checksum = "a4b5231d334edbc03b22704caa1a022e4c07491d6df736593f26094df8b04a51" [[package]] name = "vmm-sys-util" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08604d7be03eb26e33b3cee3ed4aef2bf550b305d1cca60e84da5d28d3790b62" +checksum = "dd64fe09d8e880e600c324e7d664760a17f56e9672b7495a86381b49e4f72f46" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", ] [[package]] -name = "vmm-sys-util" -version = "0.11.1" +name = "want" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd64fe09d8e880e600c324e7d664760a17f56e9672b7495a86381b49e4f72f46" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "bitflags", - "libc", + "try-lock", ] [[package]] @@ -1710,6 +2243,82 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.12", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.12", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" + +[[package]] +name = "web-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1741,13 +2350,31 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -1756,13 +2383,28 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "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 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -1771,42 +2413,94 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_i686_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "xattr" version = "0.2.3" diff --git a/Cargo.toml b/Cargo.toml index 7771c08..81466cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ dragonball = { git = "https://github.com/kata-containers/kata-containers", branc "virtio-fs", "virtio-vsock", "virtio-net", + "vhost-net", "hotplug", "dbs-upcall", ] } diff --git a/README.md b/README.md index b77089f..3b18b02 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ > > [[简体中文版]](README_zh.md) -# 1. Examples: +## Examples See all options: @@ -12,7 +12,7 @@ See all options: ./dbs-cli --help ``` -A simple example: +### Basic examples ```bash ./dbs-cli create \ @@ -68,9 +68,9 @@ Create a virtio-vsock tunnel for Guest-to-Host communication. --vsock /tmp/vsock.sock ``` -Create virtio-net devices. +Create virtio-blk devices. -> The type of the `--virnets` receives an array of VirtioNetDeviceConfigInfo in the +> The type of the `--virblks` receives an array of BlockDeviceConfigInfo in the > format of JSON. ``` @@ -79,26 +79,47 @@ Create virtio-net devices. --kernel-path ~/path/to/kernel/vmlinux.bin \ --rootfs ~/path/to/rootfs/bionic.rootfs.ext4 \ --boot-args "console=ttyS0 console=ttyS1 earlyprintk=ttyS1 tty0 reboot=k debug panic=1 pci=off root=/dev/vda1" \ - --virnets "[{\"iface_id\":\"eth0\",\"host_dev_name\":\"tap0\",\"num_queues\":2,\"queue_size\":0,\"guest_mac\":\"43:2D:9C:13:71:48\",\"allow_duplicate_mac\":true}]" + --virblks '[{"drive_id":"testblk","device_type":"RawBlock","path_on_host":"/path/to/test.img","is_root_device":false,"is_read_only":false,"is_direct":false,"no_drop":false,"num_queues":1,"queue_size":1024}]' ``` -Create virtio-blk devices. +### Networking -> The type of the `--virblks` receives an array of BlockDeviceConfigInfo in the -> format of JSON. +Start a Dragonball VMM with a virtio-based network device. `--virnets` +receives an array of `NetworkInterfaceConfig` in the format of JSON. ``` -./dbs-cli create \ - --log-file dbs-cli.log --log-level ERROR \ - --kernel-path ~/path/to/kernel/vmlinux.bin \ - --rootfs ~/path/to/rootfs/bionic.rootfs.ext4 \ - --boot-args "console=ttyS0 console=ttyS1 earlyprintk=ttyS1 tty0 reboot=k debug panic=1 pci=off root=/dev/vda1" \ - --virblks '[{"drive_id":"testblk","device_type":"RawBlock","path_on_host":"/path/to/test.img","is_root_device":false,"is_read_only":false,"is_direct":false,"no_drop":false,"num_queues":1,"queue_size":1024}]' +--virnets '[{"guest_mac":"43:2D:9C:13:71:48","backend":{"type":"vhost","iface_id":"eth0","host_dev_name":"tap0","allow_duplicate_mac":true}}]' ``` -# 2. Usage +The supported network devices include: -## 1. Create API Server and Update VM +``` +// Virtio-net +{ + "guest_mac": "43:2D:9C:13:71:48", + "backend": { + "type": "virtio", + "iface_id": "eth0", + "host_dev_name": "tap0", + "allow_duplicate_mac": true + } +} + +// Vhost-net +{ + "guest_mac": "43:2D:9C:13:71:48", + "backend": { + "type": "vhost", + "iface_id": "eth0", + "host_dev_name": "tap0", + "allow_duplicate_mac": true + } +} +``` + +## Advanced Usage + +### Create API Server and Update VM An API Server could be created by adding `--api-sock-path [socket path]` into dbs-cli creation command. @@ -110,6 +131,8 @@ Cpu Hotplug via API Server: Create hot-plug virtio-net devices via API Server: +**TODO: Needs to be updated** + > The type of the `--hotplug-virnets` receives an array of > VirtioNetDeviceConfigInfo in the format of JSON. @@ -132,11 +155,11 @@ sudo ./dbs-cli \ TODO : add document for hot-plug virtio-fs -## 2. Exit vm +### Exit VM -> If you want to exit vm, just input `reboot` in vm's console. +If you want to exit vm, just input `reboot` in vm's console. -## 3. For developers +### For developers If you wish to modify some details or debug to figure out the fault of codes, you can do as follow to see whether the program act expectedly or not. @@ -152,7 +175,7 @@ To see some help: cargo run -- --help ``` -## 3. Some off-topic remarks +### Some off-topic remarks Regarding the dependency issue of the upstream library, it is recommended to build the `build` target of Makefile to avoid it temporally. @@ -162,6 +185,6 @@ make build If the self-defined `dragonball` dependency is supposed to be used, please refer to [dependency document](docs/dependency.md) -# License +## License `DBS-CLI` is licensed under [Apache License](http://www.apache.org/licenses/LICENSE-2.0), Version 2.0. diff --git a/src/api_client.rs b/src/api_client.rs index d8f7810..bfac8f5 100644 --- a/src/api_client.rs +++ b/src/api_client.rs @@ -36,11 +36,11 @@ fn request_cpu_resize(vcpu_resize_num: usize) -> Value { }) } -/// Insert virtio-net devices -fn request_virtio_net(virtio_net_config: &str) -> Value { +/// Insert virtio network devices +fn request_virtio_net(net_config: &str) -> Value { json!({ "action": "insert_virnets", - "config": virtio_net_config, + "config": net_config, }) } diff --git a/src/api_server.rs b/src/api_server.rs index 609a8c3..797fcdd 100644 --- a/src/api_server.rs +++ b/src/api_server.rs @@ -9,10 +9,9 @@ use std::sync::{Arc, Mutex}; use anyhow::{anyhow, Context, Result}; use crossbeam_channel::{Receiver, Sender}; -use dragonball::api::v1::{VmmRequest, VmmResponse}; +use dragonball::api::v1::{NetworkInterfaceConfig, VmmRequest, VmmResponse}; use dragonball::device_manager::blk_dev_mgr::BlockDeviceConfigInfo; use dragonball::device_manager::fs_dev_mgr::FsMountConfigInfo; -use dragonball::device_manager::virtio_net_dev_mgr::VirtioNetDeviceConfigInfo; use dragonball::vcpu::VcpuResizeInfo; use serde_json::Value; use vmm_sys_util::eventfd::EventFd; @@ -85,11 +84,11 @@ impl ApiServer { Some(config_json) => config_json, None => return Err(anyhow!("The config of virtio-net device is required")), }; - let configs: Vec = serde_json::from_str(config_json) - .context("Parse virtio-net device config from json")?; + let configs: Vec = serde_json::from_str(config_json) + .context("Parse NetworkInterfaceConfig from JSON")?; for config in configs.iter() { self.insert_virnet(config.clone()) - .context("Insert a virtio-net device to the Dragonball")?; + .context("Insert a virtio device to the Dragonball")?; } } Some("insert_virblks") => { diff --git a/src/cli_instance.rs b/src/cli_instance.rs index b00341c..343a5b2 100644 --- a/src/cli_instance.rs +++ b/src/cli_instance.rs @@ -17,11 +17,10 @@ use vmm_sys_util::eventfd::EventFd; use dragonball::{ api::v1::{ - BlockDeviceConfigInfo, BootSourceConfig, InstanceInfo, VmmRequest, VmmResponse, - VsockDeviceConfigInfo, + BlockDeviceConfigInfo, BootSourceConfig, InstanceInfo, NetworkInterfaceConfig, VmmRequest, + VmmResponse, VsockDeviceConfigInfo, }, device_manager::fs_dev_mgr::FsDeviceConfigInfo, - device_manager::virtio_net_dev_mgr::VirtioNetDeviceConfigInfo, vm::{CpuTopology, VmConfigInfo}, }; @@ -154,12 +153,15 @@ impl CliInstance { .expect("failed to set vsock socket path"); } + // Virtio devices if !args.virnets.is_empty() { - let configs: Vec = serde_json::from_str(&args.virnets) - .expect("failed to parse virtio-net devices from JSON"); + let configs: Vec = serde_json::from_str(&args.virnets) + .unwrap_or_else(|err| { + panic!("Failed to parse NetworkInterfaceConfig from JSON: {}", err) + }); for config in configs.into_iter() { self.insert_virnet(config) - .expect("failed to insert a virtio-net device"); + .expect("Failed to insert a virtio device"); } } diff --git a/src/parser/args.rs b/src/parser/args.rs index 2d775c9..b97cb5a 100644 --- a/src/parser/args.rs +++ b/src/parser/args.rs @@ -148,9 +148,7 @@ pub struct CreateArgs { long, value_parser, default_value = "", - help = r#"Insert virtio-net devices into the Dragonball. -The type of it is an array of VirtioNetDeviceConfigInfo, e.g. - --virnets '[{"iface_id":"eth0","host_dev_name":"tap0","num_queues":2,"queue_size":0,"allow_duplicate_mac":true}]'"#, + help = r#"Insert virtio devices into the Dragonball before launched. The supported devices are virtio-net and vhost-net."#, display_order = 2 )] pub virnets: String, diff --git a/src/vmm_comm_trait.rs b/src/vmm_comm_trait.rs index 33d71b2..aba98f8 100644 --- a/src/vmm_comm_trait.rs +++ b/src/vmm_comm_trait.rs @@ -6,11 +6,10 @@ use std::sync::{Arc, Mutex}; use dragonball::{ api::v1::{ - BlockDeviceConfigInfo, BootSourceConfig, VmmAction, VmmActionError, VmmData, VmmRequest, - VmmResponse, VsockDeviceConfigInfo, + BlockDeviceConfigInfo, BootSourceConfig, NetworkInterfaceConfig, VmmAction, VmmActionError, + VmmData, VmmRequest, VmmResponse, VsockDeviceConfigInfo, }, device_manager::fs_dev_mgr::{FsDeviceConfigInfo, FsMountConfigInfo}, - device_manager::virtio_net_dev_mgr::VirtioNetDeviceConfigInfo, vcpu::VcpuResizeInfo, vm::VmConfigInfo, }; @@ -135,9 +134,9 @@ pub trait VMMComm { Ok(()) } - fn insert_virnet(&self, config: VirtioNetDeviceConfigInfo) -> Result<()> { + fn insert_virnet(&self, config: NetworkInterfaceConfig) -> Result<()> { self.handle_request(Request::Sync(VmmAction::InsertNetworkDevice(config))) - .context("Request to insert a virtio-net device")?; + .context("Request to insert a virtio device")?; Ok(()) } From d2637b30626bfa08c4b2dd8c329685bd83c071b2 Mon Sep 17 00:00:00 2001 From: Xuewei Niu Date: Thu, 23 Nov 2023 10:56:16 +0800 Subject: [PATCH 2/2] Minor changes for studychao's comments - Errors have net device type and name. - Formating the import blocks of "vmm_comm_trait.rs". Signed-off-by: Xuewei Niu --- src/api_server.rs | 9 +++++++-- src/utils.rs | 14 ++++++++++++++ src/vmm_comm_trait.rs | 34 ++++++++++++++++++++-------------- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/api_server.rs b/src/api_server.rs index 797fcdd..8003f29 100644 --- a/src/api_server.rs +++ b/src/api_server.rs @@ -16,6 +16,7 @@ use dragonball::vcpu::VcpuResizeInfo; use serde_json::Value; use vmm_sys_util::eventfd::EventFd; +use crate::utils; use crate::vmm_comm_trait::VMMComm; pub struct ApiServer { @@ -87,8 +88,12 @@ impl ApiServer { let configs: Vec = serde_json::from_str(config_json) .context("Parse NetworkInterfaceConfig from JSON")?; for config in configs.iter() { - self.insert_virnet(config.clone()) - .context("Insert a virtio device to the Dragonball")?; + self.insert_virnet(config.clone()).with_context(|| { + format!( + "Insert a {} device to the Dragonball", + utils::net_device_name(config) + ) + })?; } } Some("insert_virblks") => { diff --git a/src/utils.rs b/src/utils.rs index b8e4f72..63a1c0a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,3 +1,4 @@ +use dragonball::api::v1::NetworkInterfaceConfig; use slog::Drain; use slog::*; use slog_scope::set_global_logger; @@ -25,3 +26,16 @@ pub fn setup_db_log(log_file_path: &String, log_level: &str) { guard.cancel_reset(); slog_stdlog::init().unwrap(); } + +#[inline] +/// Get net device name from `NetworkInterfaceConfig`. +pub(crate) fn net_device_name(config: &NetworkInterfaceConfig) -> String { + match &config.backend { + dragonball::api::v1::Backend::Virtio(config) => { + format!("virtio-net({})", config.host_dev_name) + } + dragonball::api::v1::Backend::Vhost(config) => { + format!("vhost-net({})", config.host_dev_name) + } + } +} diff --git a/src/vmm_comm_trait.rs b/src/vmm_comm_trait.rs index aba98f8..55d889a 100644 --- a/src/vmm_comm_trait.rs +++ b/src/vmm_comm_trait.rs @@ -1,18 +1,17 @@ -use crossbeam_channel::{Receiver, Sender}; -use vmm_sys_util::eventfd::EventFd; - -use anyhow::{anyhow, Context, Result}; use std::sync::{Arc, Mutex}; -use dragonball::{ - api::v1::{ - BlockDeviceConfigInfo, BootSourceConfig, NetworkInterfaceConfig, VmmAction, VmmActionError, - VmmData, VmmRequest, VmmResponse, VsockDeviceConfigInfo, - }, - device_manager::fs_dev_mgr::{FsDeviceConfigInfo, FsMountConfigInfo}, - vcpu::VcpuResizeInfo, - vm::VmConfigInfo, +use anyhow::{anyhow, Context, Result}; +use crossbeam_channel::{Receiver, Sender}; +use dragonball::api::v1::{ + BlockDeviceConfigInfo, BootSourceConfig, NetworkInterfaceConfig, VmmAction, VmmActionError, + VmmData, VmmRequest, VmmResponse, VsockDeviceConfigInfo, }; +use dragonball::device_manager::fs_dev_mgr::{FsDeviceConfigInfo, FsMountConfigInfo}; +use dragonball::vcpu::VcpuResizeInfo; +use dragonball::vm::VmConfigInfo; +use vmm_sys_util::eventfd::EventFd; + +use crate::utils; pub enum Request { Sync(VmmAction), @@ -135,8 +134,15 @@ pub trait VMMComm { } fn insert_virnet(&self, config: NetworkInterfaceConfig) -> Result<()> { - self.handle_request(Request::Sync(VmmAction::InsertNetworkDevice(config))) - .context("Request to insert a virtio device")?; + self.handle_request(Request::Sync(VmmAction::InsertNetworkDevice( + config.clone(), + ))) + .with_context(|| { + format!( + "Request to insert a {} device", + utils::net_device_name(&config) + ) + })?; Ok(()) }