From feb79e439205d9db8bfdfa40d0109e8325b82a9a Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 15 Mar 2023 14:20:04 +0100 Subject: [PATCH 1/4] Renamed some crates and changed their version to 0.1.0 --- CHANGELOG.md | 2 +- Cargo.lock | 138 +++++++++--------- Cargo.toml | 4 +- examples/wasi.rs | 2 +- examples/wasi_manual_setup.rs | 2 +- examples/wasi_pipes.rs | 2 +- lib/c-api/Cargo.toml | 8 +- lib/c-api/src/wasm_c_api/wasi/mod.rs | 8 +- lib/cli/Cargo.toml | 32 ++-- lib/cli/src/commands/run.rs | 10 +- lib/cli/src/commands/run/wasi.rs | 18 +-- lib/sys-utils/Cargo.toml | 4 +- lib/sys-utils/tests/fd_mmap_memory.rs | 8 +- lib/vfs/Cargo.toml | 4 +- lib/vfs/src/lib.rs | 2 +- lib/vfs/src/union_fs.rs | 4 +- lib/vnet/Cargo.toml | 4 +- lib/wasi-experimental-io-devices/Cargo.toml | 14 +- lib/wasi-experimental-io-devices/src/lib.rs | 4 +- .../src/link-ext.rs | 10 +- lib/wasi-local-networking/Cargo.toml | 8 +- lib/wasi-local-networking/src/lib.rs | 2 +- lib/wasi-types/Cargo.toml | 8 +- lib/wasi/Cargo.toml | 28 ++-- lib/wasi/README.md | 2 +- lib/wasi/src/bin_factory/binary_package.rs | 4 +- lib/wasi/src/bin_factory/exec.rs | 2 +- lib/wasi/src/bin_factory/mod.rs | 2 +- lib/wasi/src/bin_factory/module_cache.rs | 2 +- lib/wasi/src/fs/fd.rs | 4 +- lib/wasi/src/fs/inode_guard.rs | 6 +- lib/wasi/src/fs/mod.rs | 36 ++--- lib/wasi/src/lib.rs | 22 +-- lib/wasi/src/net/mod.rs | 4 +- lib/wasi/src/net/socket.rs | 14 +- .../src/os/command/builtins/cmd_wasmer.rs | 2 +- lib/wasi/src/os/command/mod.rs | 2 +- lib/wasi/src/os/console/mod.rs | 21 ++- lib/wasi/src/os/task/process.rs | 2 +- lib/wasi/src/os/task/signal.rs | 2 +- lib/wasi/src/os/task/task_join_handle.rs | 2 +- lib/wasi/src/os/task/thread.rs | 2 +- lib/wasi/src/os/tty/mod.rs | 4 +- lib/wasi/src/runners/container.rs | 2 +- lib/wasi/src/runners/wcgi/handler.rs | 2 +- lib/wasi/src/runners/wcgi/runner.rs | 2 +- lib/wasi/src/runtime/mod.rs | 6 +- lib/wasi/src/state/builder.rs | 16 +- lib/wasi/src/state/env.rs | 10 +- lib/wasi/src/state/func_env.rs | 2 +- lib/wasi/src/state/mod.rs | 13 +- lib/wasi/src/state/types.rs | 6 +- lib/wasi/src/syscalls/legacy/snapshot0.rs | 2 +- lib/wasi/src/syscalls/mod.rs | 12 +- lib/wasi/src/syscalls/unix/mod.rs | 2 +- lib/wasi/src/syscalls/wasi/fd_read.rs | 4 +- lib/wasi/src/syscalls/wasi/path_open.rs | 6 +- lib/wasi/src/syscalls/wasi/poll_oneoff.rs | 2 +- lib/wasi/src/syscalls/wasix/fd_pipe.rs | 2 +- lib/wasi/src/syscalls/wasix/proc_spawn.rs | 2 +- lib/wasi/src/syscalls/wasix/sock_send_file.rs | 4 +- lib/wasi/src/utils/mod.rs | 2 +- lib/wasi/src/wapm/mod.rs | 4 +- lib/wasi/tests/runners.rs | 8 +- lib/wasi/tests/stdio.rs | 4 +- tests/lib/wast/Cargo.toml | 4 +- tests/lib/wast/src/wasi_wast.rs | 22 +-- 67 files changed, 300 insertions(+), 300 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9c485b35e..51d03c0a5a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -898,7 +898,7 @@ Special thanks to [@ethanfrey](https://github.com/ethanfrey), [@AdamSLevy](https - [#992](https://github.com/wasmerio/wasmer/pull/992) Updates WAPM version to 0.4.1, fix arguments issue introduced in #990 - [#990](https://github.com/wasmerio/wasmer/pull/990) Default wasmer CLI to `run`. Wasmer will now attempt to parse unrecognized command line options as if they were applied to the run command: `wasmer mywasm.wasm --dir=.` now works! - [#987](https://github.com/wasmerio/wasmer/pull/987) Fix `runtime-c-api` header files when compiled by gnuc. -- [#957](https://github.com/wasmerio/wasmer/pull/957) Change the meaning of `wasmer_wasi::is_wasi_module` to detect any type of WASI module, add support for new wasi snapshot_preview1 +- [#957](https://github.com/wasmerio/wasmer/pull/957) Change the meaning of `wasmer_wasix::is_wasi_module` to detect any type of WASI module, add support for new wasi snapshot_preview1 - [#934](https://github.com/wasmerio/wasmer/pull/934) Simplify float expressions in the LLVM backend. ## 0.10.2 - 2019-11-18 diff --git a/Cargo.lock b/Cargo.lock index c8233284dee..98b84372c7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4369,6 +4369,51 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "virtfs" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "bytes", + "derivative", + "filetime", + "fs_extra", + "indexmap", + "lazy_static", + "libc", + "pin-project-lite", + "slab", + "tempfile", + "thiserror", + "tokio", + "tracing", + "typetag", + "webc", +] + +[[package]] +name = "virtnet" +version = "0.1.0" +dependencies = [ + "async-trait", + "bytes", + "thiserror", + "tracing", +] + +[[package]] +name = "virtnet-native" +version = "0.1.0" +dependencies = [ + "async-trait", + "bytes", + "libc", + "tokio", + "tracing", + "virtnet", +] + [[package]] name = "void" version = "1.0.2" @@ -4798,6 +4843,7 @@ dependencies = [ "paste", "thiserror", "typetag", + "virtfs", "wasmer", "wasmer-compiler", "wasmer-compiler-cranelift", @@ -4807,8 +4853,7 @@ dependencies = [ "wasmer-inline-c", "wasmer-middlewares", "wasmer-types", - "wasmer-vfs", - "wasmer-wasi", + "wasmer-wasix", "webc", ] @@ -4893,6 +4938,9 @@ dependencies = [ "tracing-subscriber 0.3.16", "unix_mode", "url", + "virtfs", + "virtnet", + "virtnet-native", "walkdir", "wasm-coredump-builder", "wasmer", @@ -4906,12 +4954,9 @@ dependencies = [ "wasmer-registry", "wasmer-toml", "wasmer-types", - "wasmer-vfs", "wasmer-vm", - "wasmer-vnet", - "wasmer-wasi", - "wasmer-wasi-experimental-io-devices", - "wasmer-wasi-local-networking", + "wasmer-wasix", + "wasmer-wasix-experimental-io-devices", "wasmer-wasm-interface", "wasmer-wast", "wasmparser 0.51.4", @@ -5157,7 +5202,7 @@ dependencies = [ [[package]] name = "wasmer-sys-utils" -version = "3.2.0-alpha.1" +version = "0.1.0" dependencies = [ "libc", "region", @@ -5166,7 +5211,7 @@ dependencies = [ "wasmer", "wasmer-types", "wasmer-vm", - "wasmer-wasi", + "wasmer-wasix", ] [[package]] @@ -5202,29 +5247,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "wasmer-vfs" -version = "3.2.0-alpha.1" -dependencies = [ - "anyhow", - "async-trait", - "bytes", - "derivative", - "filetime", - "fs_extra", - "indexmap", - "lazy_static", - "libc", - "pin-project-lite", - "slab", - "tempfile", - "thiserror", - "tokio", - "tracing", - "typetag", - "webc", -] - [[package]] name = "wasmer-vm" version = "3.2.0-alpha.1" @@ -5251,18 +5273,8 @@ dependencies = [ ] [[package]] -name = "wasmer-vnet" -version = "3.2.0-alpha.1" -dependencies = [ - "async-trait", - "bytes", - "thiserror", - "tracing", -] - -[[package]] -name = "wasmer-wasi" -version = "3.2.0-alpha.1" +name = "wasmer-wasix" +version = "0.1.0" dependencies = [ "anyhow", "async-trait", @@ -5301,6 +5313,9 @@ dependencies = [ "tracing-wasm", "typetag", "urlencoding", + "virtfs", + "virtnet", + "virtnet-native", "wai-bindgen-wasmer", "waker-fn", "wasm-bindgen", @@ -5309,11 +5324,8 @@ dependencies = [ "wasmer-compiler", "wasmer-emscripten", "wasmer-types", - "wasmer-vfs", "wasmer-vm", - "wasmer-vnet", - "wasmer-wasi-local-networking", - "wasmer-wasi-types", + "wasmer-wasix-types", "wcgi", "wcgi-host", "webc", @@ -5322,8 +5334,8 @@ dependencies = [ ] [[package]] -name = "wasmer-wasi-experimental-io-devices" -version = "3.2.0-alpha.1" +name = "wasmer-wasix-experimental-io-devices" +version = "0.1.0" dependencies = [ "minifb", "nix 0.25.1", @@ -5331,25 +5343,13 @@ dependencies = [ "serde", "tracing", "typetag", - "wasmer-wasi", - "wasmer-wasi-types", -] - -[[package]] -name = "wasmer-wasi-local-networking" -version = "3.2.0-alpha.1" -dependencies = [ - "async-trait", - "bytes", - "libc", - "tokio", - "tracing", - "wasmer-vnet", + "wasmer-wasix", + "wasmer-wasix-types", ] [[package]] -name = "wasmer-wasi-types" -version = "3.2.0-alpha.1" +name = "wasmer-wasix-types" +version = "0.1.0" dependencies = [ "anyhow", "bitflags", @@ -5390,9 +5390,9 @@ dependencies = [ "tempfile", "thiserror", "tokio", + "virtfs", "wasmer", - "wasmer-vfs", - "wasmer-wasi", + "wasmer-wasix", "wast 38.0.1", ] @@ -5424,7 +5424,7 @@ dependencies = [ "wasmer-emscripten", "wasmer-middlewares", "wasmer-types", - "wasmer-wasi", + "wasmer-wasix", "wasmer-wast", ] diff --git a/Cargo.toml b/Cargo.toml index 2ed45f1da93..a482900c96f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ wasmer-compiler-cranelift = { version = "=3.2.0-alpha.1", path = "lib/compiler-c wasmer-compiler-singlepass = { version = "=3.2.0-alpha.1", path = "lib/compiler-singlepass", optional = true } wasmer-compiler-llvm = { version = "=3.2.0-alpha.1", path = "lib/compiler-llvm", optional = true } wasmer-emscripten = { version = "=3.2.0-alpha.1", path = "lib/emscripten", optional = true } -wasmer-wasi = { version = "=3.2.0-alpha.1", path = "lib/wasi", optional = true } +wasmer-wasix = { version = "0.1.0", path = "lib/wasi", optional = true } wasmer-wast = { version = "=3.2.0-alpha.1", path = "tests/lib/wast", optional = true } wasi-test-generator = { version = "=3.2.0-alpha.1", path = "tests/wasi-wast", optional = true } wasmer-cache = { version = "=3.2.0-alpha.1", path = "lib/cache", optional = true } @@ -106,7 +106,7 @@ engine = ["universal"] universal = [] cache = ["wasmer-cache"] wast = ["wasmer-wast"] -wasi = ["wasmer-wasi"] +wasi = ["wasmer-wasix"] emscripten = ["wasmer-emscripten"] wat = ["wasmer/wat"] compiler = ["wasmer/compiler", "wasmer-compiler/translator"] diff --git a/examples/wasi.rs b/examples/wasi.rs index 15c537a94fa..7ba99086411 100644 --- a/examples/wasi.rs +++ b/examples/wasi.rs @@ -18,7 +18,7 @@ use std::io::Read; use wasmer::{Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_wasi::{Pipe, WasiEnv}; +use wasmer_wasix::{Pipe, WasiEnv}; fn main() -> Result<(), Box> { let wasm_path = concat!( diff --git a/examples/wasi_manual_setup.rs b/examples/wasi_manual_setup.rs index 60a1f95b2a5..9967b5cec45 100644 --- a/examples/wasi_manual_setup.rs +++ b/examples/wasi_manual_setup.rs @@ -17,7 +17,7 @@ use wasmer::{Instance, Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_wasi::WasiEnv; +use wasmer_wasix::WasiEnv; fn main() -> Result<(), Box> { let wasm_path = concat!( diff --git a/examples/wasi_pipes.rs b/examples/wasi_pipes.rs index ff10933ae19..2629e398291 100644 --- a/examples/wasi_pipes.rs +++ b/examples/wasi_pipes.rs @@ -14,7 +14,7 @@ use std::io::{Read, Write}; use wasmer::{Module, Store}; use wasmer_compiler_cranelift::Cranelift; -use wasmer_wasi::{Pipe, WasiEnv}; +use wasmer_wasix::{Pipe, WasiEnv}; fn main() -> Result<(), Box> { let wasm_path = concat!( diff --git a/lib/c-api/Cargo.toml b/lib/c-api/Cargo.toml index 04413d379ac..83f1c67d786 100644 --- a/lib/c-api/Cargo.toml +++ b/lib/c-api/Cargo.toml @@ -29,9 +29,9 @@ wasmer-compiler-llvm = { version = "=3.2.0-alpha.1", path = "../compiler-llvm", wasmer-emscripten = { version = "=3.2.0-alpha.1", path = "../emscripten", optional = true } wasmer-compiler = { version = "=3.2.0-alpha.1", path = "../compiler" } wasmer-middlewares = { version = "=3.2.0-alpha.1", path = "../middlewares", optional = true } -wasmer-wasi = { version = "=3.2.0-alpha.1", path = "../wasi", features = ["host-fs", "host-vnet"], optional = true } +wasmer-wasix = { version = "0.1.0", path = "../wasi", features = ["host-fs", "host-vnet"], optional = true } wasmer-types = { version = "=3.2.0-alpha.1", path = "../types" } -wasmer-vfs = { version = "=3.2.0-alpha.1", path = "../vfs", optional = true, default-features = false, features = ["static-fs"] } +virtfs = { version = "0.1.0", path = "../vfs", optional = true, default-features = false, features = ["static-fs"] } webc = { version = "5.0.0-rc.5", optional = true } enumset = "1.0.2" cfg-if = "1.0" @@ -59,7 +59,7 @@ default = [ "middlewares", ] wat = ["wasmer-api/wat"] -wasi = ["wasmer-wasi"] +wasi = ["wasmer-wasix"] middlewares = [ "compiler", "wasmer-middlewares", @@ -92,7 +92,7 @@ wasmer-artifact-load = ["wasmer-compiler/wasmer-artifact-load"] wasmer-artifact-create = ["wasmer-compiler/wasmer-artifact-create"] static-artifact-load = ["wasmer-compiler/static-artifact-load"] static-artifact-create = ["wasmer-compiler/static-artifact-create"] -webc_runner = ["wasmer-wasi/webc_runner", "wasmer-vfs", "webc"] +webc_runner = ["wasmer-wasix/webc_runner", "virtfs", "webc"] # Deprecated features. jit = ["compiler"] diff --git a/lib/c-api/src/wasm_c_api/wasi/mod.rs b/lib/c-api/src/wasm_c_api/wasi/mod.rs index 4b8afc1bb2b..f0c7389d629 100644 --- a/lib/c-api/src/wasm_c_api/wasi/mod.rs +++ b/lib/c-api/src/wasm_c_api/wasi/mod.rs @@ -18,9 +18,9 @@ use std::os::raw::c_char; use std::slice; #[cfg(feature = "webc_runner")] use wasmer_api::{AsStoreMut, Imports, Module}; -use wasmer_wasi::{ - default_fs_backing, get_wasi_version, wasmer_vfs::AsyncReadExt, Pipe, VirtualTaskManager, - WasiEnv, WasiEnvBuilder, WasiFile, WasiFunctionEnv, WasiVersion, +use wasmer_wasix::{ + default_fs_backing, get_wasi_version, virtfs::AsyncReadExt, Pipe, VirtualTaskManager, WasiEnv, + WasiEnvBuilder, WasiFile, WasiFunctionEnv, WasiVersion, }; #[derive(Debug)] @@ -248,7 +248,7 @@ fn prepare_webc_env( len: usize, package_name: &str, ) -> Option<(WasiFunctionEnv, Imports)> { - use wasmer_vfs::static_fs::StaticFileSystem; + use virtfs::static_fs::StaticFileSystem; use webc::v1::{FsEntryType, WebC}; let slice = unsafe { std::slice::from_raw_parts(bytes, len) }; diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index fa6a0875e9f..0c616ca6d5f 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -32,16 +32,16 @@ wasmer-compiler-singlepass = { version = "=3.2.0-alpha.1", path = "../compiler-s wasmer-compiler-llvm = { version = "=3.2.0-alpha.1", path = "../compiler-llvm", optional = true } wasmer-emscripten = { version = "=3.2.0-alpha.1", path = "../emscripten", optional = true } wasmer-vm = { version = "=3.2.0-alpha.1", path = "../vm" } -wasmer-wasi = { version = "=3.2.0-alpha.1", path = "../wasi", optional = true } -wasmer-wasi-experimental-io-devices = { version = "=3.2.0-alpha.1", path = "../wasi-experimental-io-devices", optional = true, features = ["link_external_libs"] } -wasmer-wasi-local-networking = { version = "=3.2.0-alpha.1", path = "../wasi-local-networking", optional = true } +wasmer-wasix = { version = "0.1.0", path = "../wasi", optional = true } +wasmer-wasix-experimental-io-devices = { version = "0.1.0", path = "../wasi-experimental-io-devices", optional = true, features = ["link_external_libs"] } +virtnet-native = { version = "0.1.0", path = "../wasi-local-networking", optional = true } wasmer-wast = { version = "=3.2.0-alpha.1", path = "../../tests/lib/wast", optional = true } wasmer-cache = { version = "=3.2.0-alpha.1", path = "../cache", optional = true } wasmer-types = { version = "=3.2.0-alpha.1", path = "../types", features = ["enable-serde"] } wasmer-registry = { version = "=4.0.0", path = "../registry" } wasmer-object = { version = "=3.2.0-alpha.1", path = "../object", optional = true } -wasmer-vfs = { version = "=3.2.0-alpha.1", path = "../vfs", default-features = false, features = ["host-fs"] } -wasmer-vnet = { version = "=3.2.0-alpha.1", path = "../vnet" } +virtfs = { version = "0.1.0", path = "../vfs", default-features = false, features = ["host-fs"] } +virtnet = { version = "0.1.0", path = "../vnet" } wasmer-wasm-interface = { version = "3.2.0-alpha.1", path = "../wasm-interface" } wasmparser = "0.51.4" atty = "0.2" @@ -116,14 +116,22 @@ default = [ cache = ["wasmer-cache"] cache-blake3-pure = ["wasmer-cache/blake3-pure"] wast = ["wasmer-wast"] -wasi = ["wasmer-wasi", "wasmer-wasi-local-networking"] +wasi = ["wasmer-wasix", "virtnet-native"] emscripten = ["wasmer-emscripten"] wat = ["wasmer/wat"] -webc_runner = ["wasi", "wasmer-wasi/webc_runner", "wasmer-wasi/webc_runner_rt_wasi", "wasmer-wasi/webc_runner_rt_wcgi", "wasmer-wasi/webc_runner_rt_emscripten", "nuke-dir", "webc"] +webc_runner = [ + "wasi", + "wasmer-wasix/webc_runner", + "wasmer-wasix/webc_runner_rt_wasi", + "wasmer-wasix/webc_runner_rt_wcgi", + "wasmer-wasix/webc_runner_rt_emscripten", + "nuke-dir", + "webc" +] compiler = [ "wasmer-compiler/translator", "wasmer-compiler/compiler", - "wasmer-wasi/compiler" + "wasmer-wasix/compiler" ] wasmer-artifact-create = ["compiler", "wasmer/wasmer-artifact-load", @@ -149,7 +157,7 @@ static-artifact-load = ["compiler", ] experimental-io-devices = [ - "wasmer-wasi-experimental-io-devices", + "wasmer-wasix-experimental-io-devices", "wasi" ] singlepass = [ @@ -164,8 +172,8 @@ llvm = [ "wasmer-compiler-llvm", "compiler", ] -debug = ["tracing", "wasmer-wasi/logging"] -disable-all-logging = ["wasmer-wasi/disable-all-logging", "log/release_max_level_off"] +debug = ["tracing", "wasmer-wasix/logging"] +disable-all-logging = ["wasmer-wasix/disable-all-logging", "log/release_max_level_off"] headless = [] headless-minimal = ["headless", "disable-all-logging", "wasi"] tracing = [ "dep:tracing", "tracing-subscriber" ] @@ -175,7 +183,7 @@ enable-serde = [ "wasmer/enable-serde", "wasmer-vm/enable-serde", "wasmer-compiler/enable-serde", - "wasmer-wasi/enable-serde", + "wasmer-wasix/enable-serde", ] [target.'cfg(target_os = "windows")'.dependencies] diff --git a/lib/cli/src/commands/run.rs b/lib/cli/src/commands/run.rs index e5b1f4e78b7..3e8b9787f13 100644 --- a/lib/cli/src/commands/run.rs +++ b/lib/cli/src/commands/run.rs @@ -21,7 +21,7 @@ use wasmer::*; use wasmer_cache::{Cache, FileSystemCache, Hash}; use wasmer_types::Type as ValueType; #[cfg(feature = "webc_runner")] -use wasmer_wasi::runners::{Runner, WapmContainer}; +use wasmer_wasix::runners::{Runner, WapmContainer}; #[cfg(feature = "wasi")] mod wasi; @@ -288,7 +288,7 @@ impl RunWithPathBuf { #[cfg(feature = "wasi")] let ret = { use std::collections::BTreeSet; - use wasmer_wasi::WasiVersion; + use wasmer_wasix::WasiVersion; let wasi_versions = Wasi::get_versions(&module); match wasi_versions { @@ -387,14 +387,14 @@ impl RunWithPathBuf { .with_context(|| format!("No metadata found for the command, \"{id}\""))?; let (store, _compiler_type) = self.store.get_store()?; - let mut runner = wasmer_wasi::runners::wasi::WasiRunner::new(store); + let mut runner = wasmer_wasix::runners::wasi::WasiRunner::new(store); runner.set_args(args.to_vec()); if runner.can_run_command(id, command).unwrap_or(false) { return runner.run_cmd(&container, id).context("WASI runner failed"); } let (store, _compiler_type) = self.store.get_store()?; - let mut runner = wasmer_wasi::runners::emscripten::EmscriptenRunner::new(store); + let mut runner = wasmer_wasix::runners::emscripten::EmscriptenRunner::new(store); runner.set_args(args.to_vec()); if runner.can_run_command(id, command).unwrap_or(false) { return runner @@ -402,7 +402,7 @@ impl RunWithPathBuf { .context("Emscripten runner failed"); } - let mut runner = wasmer_wasi::runners::wcgi::WcgiRunner::new(id); + let mut runner = wasmer_wasix::runners::wcgi::WcgiRunner::new(id); let (store, _compiler_type) = self.store.get_store()?; runner .config() diff --git a/lib/cli/src/commands/run/wasi.rs b/lib/cli/src/commands/run/wasi.rs index 7f609d6e3e7..2b64de47507 100644 --- a/lib/cli/src/commands/run/wasi.rs +++ b/lib/cli/src/commands/run/wasi.rs @@ -4,11 +4,11 @@ use std::collections::HashMap; use std::path::PathBuf; use std::sync::Arc; use std::{collections::BTreeSet, path::Path}; +use virtfs::FileSystem; +use virtfs::{DeviceFile, PassthruFileSystem, RootFileSystemBuilder}; use wasmer::{AsStoreMut, Instance, Module, RuntimeError, Value}; -use wasmer_vfs::FileSystem; -use wasmer_vfs::{DeviceFile, PassthruFileSystem, RootFileSystemBuilder}; -use wasmer_wasi::types::__WASI_STDIN_FILENO; -use wasmer_wasi::{ +use wasmer_wasix::types::__WASI_STDIN_FILENO; +use wasmer_wasix::{ default_fs_backing, get_wasi_versions, PluggableRuntimeImplementation, WasiEnv, WasiError, WasiFunctionEnv, WasiVersion, }; @@ -121,11 +121,9 @@ impl Wasi { let mut rt = PluggableRuntimeImplementation::default(); if self.networking { - rt.set_networking_implementation( - wasmer_wasi_local_networking::LocalNetworking::default(), - ); + rt.set_networking_implementation(virtnet_native::LocalNetworking::default()); } else { - rt.set_networking_implementation(wasmer_vnet::UnsupportedVirtualNetworking::default()); + rt.set_networking_implementation(virtnet::UnsupportedVirtualNetworking::default()); } let engine = store.as_store_mut().engine().clone(); @@ -138,7 +136,7 @@ impl Wasi { .uses(self.uses.clone()) .map_commands(map_commands); - let mut builder = if wasmer_wasi::is_wasix_module(module) { + let mut builder = if wasmer_wasix::is_wasix_module(module) { // If we preopen anything from the host then shallow copy it over let root_fs = RootFileSystemBuilder::new() .with_tty(Box::new(DeviceFile::new(__WASI_STDIN_FILENO))) @@ -169,7 +167,7 @@ impl Wasi { }; if self.http_client { - let caps = wasmer_wasi::http::HttpClientCapabilityV1::new_allow_all(); + let caps = wasmer_wasix::http::HttpClientCapabilityV1::new_allow_all(); builder.capabilities_mut().http_client = caps; } diff --git a/lib/sys-utils/Cargo.toml b/lib/sys-utils/Cargo.toml index 998ec902065..edc0f4a7641 100644 --- a/lib/sys-utils/Cargo.toml +++ b/lib/sys-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmer-sys-utils" -version = "3.2.0-alpha.1" +version = "0.1.0" description = "Wasmer utilities for a sys environment." categories = ["wasm"] keywords = ["wasm", "webassembly"] @@ -19,7 +19,7 @@ region = { version = "3.0" } libc = { version = "^0.2", default-features = false } [dev-dependencies] -wasmer-wasi = { path = "../wasi", version = "=3.2.0-alpha.1" } +wasmer-wasix = { path = "../wasi", version = "0.1.0" } wasmer = { path = "../api", version = "=3.2.0-alpha.1", default-features = false, features = ["sys", "compiler", "cranelift"] } tracing-subscriber = { version = "0.3.16", features = ["fmt"] } tracing = "0.1.37" diff --git a/lib/sys-utils/tests/fd_mmap_memory.rs b/lib/sys-utils/tests/fd_mmap_memory.rs index 7e2c44418dd..f2584a43730 100644 --- a/lib/sys-utils/tests/fd_mmap_memory.rs +++ b/lib/sys-utils/tests/fd_mmap_memory.rs @@ -3,8 +3,8 @@ // use wasmer::{BaseTunables, Engine, Module, Store, Tunables}; // use wasmer_vm::VMMemory; -// use wasmer_wasi::{ -// bin_factory::spawn_exec_module, wasmer_vfs::host_fs::File, BusSpawnedProcessJoin, +// use wasmer_wasix::{ +// bin_factory::spawn_exec_module, virtfs::host_fs::File, BusSpawnedProcessJoin, // PluggableRuntimeImplementation, WasiControlPlane, WasiEnv, WasiRuntime, // WasiState, // }; @@ -101,9 +101,9 @@ // // .clone(); // // Generate an `ImportObject`. -// // let instance = wasmer_wasi::build_wasi_instance(&module, &mut wasi_env, &mut store).unwrap(); +// // let instance = wasmer_wasix::build_wasi_instance(&module, &mut wasi_env, &mut store).unwrap(); -// let config = wasmer_wasi::wasmer_vbus::SpawnOptionsConfig { +// let config = wasmer_wasix::wasmer_vbus::SpawnOptionsConfig { // reuse: false, // env: wasi_env.data(&store).clone(), // remote_instance: None, diff --git a/lib/vfs/Cargo.toml b/lib/vfs/Cargo.toml index 03c70a78ead..b9f5fe7b285 100644 --- a/lib/vfs/Cargo.toml +++ b/lib/vfs/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "wasmer-vfs" -version = "3.2.0-alpha.1" +name = "virtfs" +version = "0.1.0" description = "Wasmer Virtual FileSystem" authors = ["Wasmer Engineering Team "] license = "MIT" diff --git a/lib/vfs/src/lib.rs b/lib/vfs/src/lib.rs index 580905e5983..7bff4f1fe1a 100644 --- a/lib/vfs/src/lib.rs +++ b/lib/vfs/src/lib.rs @@ -24,7 +24,7 @@ pub mod special_file; pub mod tmp_fs; pub mod union_fs; pub mod zero_file; -// tty_file -> see wasmer_wasi::tty_file +// tty_file -> see wasmer_wasix::tty_file pub mod pipe; #[cfg(feature = "static-fs")] pub mod static_fs; diff --git a/lib/vfs/src/union_fs.rs b/lib/vfs/src/union_fs.rs index 61df13517fc..d9d6d18af8b 100644 --- a/lib/vfs/src/union_fs.rs +++ b/lib/vfs/src/union_fs.rs @@ -311,7 +311,7 @@ impl FileSystem for UnionFileSystem { Err(err) => { // This fixes a bug when attempting to create the directory /usr when it does not exist // on the x86 version of memfs - // TODO: patch wasmer_vfs and remove + // TODO: patch virtfs and remove if let FsError::NotAFile = &err { ret_error = FsError::EntryNotFound; } else { @@ -335,7 +335,7 @@ impl FileSystem for UnionFileSystem { Err(err) => { // This fixes a bug when attempting to create the directory /usr when it does not exist // on the x86 version of memfs - // TODO: patch wasmer_vfs and remove + // TODO: patch virtfs and remove if let FsError::NotAFile = &err { ret_error = FsError::EntryNotFound; } else { diff --git a/lib/vnet/Cargo.toml b/lib/vnet/Cargo.toml index 1b04a4aa89c..458e82e1980 100644 --- a/lib/vnet/Cargo.toml +++ b/lib/vnet/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "wasmer-vnet" -version = "3.2.0-alpha.1" +name = "virtnet" +version = "0.1.0" description = "Wasmer Virtual Networking" authors = ["Wasmer Engineering Team "] license = "MIT" diff --git a/lib/wasi-experimental-io-devices/Cargo.toml b/lib/wasi-experimental-io-devices/Cargo.toml index 38e6c05399f..f4a4063d97e 100644 --- a/lib/wasi-experimental-io-devices/Cargo.toml +++ b/lib/wasi-experimental-io-devices/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "wasmer-wasi-experimental-io-devices" -version = "3.2.0-alpha.1" -description = "An experimental non-standard WASI extension for graphics" +name = "wasmer-wasix-experimental-io-devices" +version = "0.1.0" +description = "An experimental non-standard WASI/WASIX extension for graphics" categories = ["wasm"] keywords = ["wasm", "webassembly", "types"] authors = ["Wasmer Engineering Team "] @@ -14,8 +14,8 @@ edition = "2018" maintenance = { status = "experimental" } [dependencies] -wasmer-wasi = { version = "=3.2.0-alpha.1", path = "../wasi", default-features=false } -wasmer-wasi-types = { path = "../wasi-types", version = "=3.2.0-alpha.1" } +wasmer-wasix = { version = "0.1.0", path = "../wasi", default-features=false } +wasmer-wasix-types = { path = "../wasi-types", version = "0.1.0" } tracing = "0.1" minifb = { version = "0.24.0", optional = true } nix = "0.25.0" @@ -25,10 +25,10 @@ typetag = "0.1" [features] default = [ - "wasmer-wasi/default" + "wasmer-wasix/default" ] enable-serde = [ - "wasmer-wasi/enable-serde" + "wasmer-wasix/enable-serde" ] # This feature exists, so that "cargo build --all" doesn't # accidentally link libxcbcommon and libwayland into the CLI diff --git a/lib/wasi-experimental-io-devices/src/lib.rs b/lib/wasi-experimental-io-devices/src/lib.rs index 4d9010789f6..8b6e3050b60 100644 --- a/lib/wasi-experimental-io-devices/src/lib.rs +++ b/lib/wasi-experimental-io-devices/src/lib.rs @@ -6,9 +6,9 @@ pub mod link_ext; pub use crate::link_ext::*; #[cfg(not(feature = "link_external_libs"))] -use wasmer_wasi::fs::WasiFs; +use wasmer_wasix::fs::WasiFs; #[cfg(not(feature = "link_external_libs"))] -use wasmer_wasi::fs::WasiInodes; +use wasmer_wasix::fs::WasiInodes; #[cfg(not(feature = "link_external_libs"))] pub fn initialize(_: &WasiInodes, _: &mut WasiFs) -> Result<(), String> { diff --git a/lib/wasi-experimental-io-devices/src/link-ext.rs b/lib/wasi-experimental-io-devices/src/link-ext.rs index 81264838cd1..250d201fc0d 100644 --- a/lib/wasi-experimental-io-devices/src/link-ext.rs +++ b/lib/wasi-experimental-io-devices/src/link-ext.rs @@ -5,9 +5,9 @@ use std::collections::{BTreeSet, VecDeque}; use std::convert::TryInto; use std::io::{Read, Seek, SeekFrom, Write}; use tracing::debug; -use wasmer_wasi::types::{wasi::Filesize, *}; -use wasmer_wasi::{VirtualFile, WasiFsError, ALL_RIGHTS}; -use wasmer_wasi_types::wasi::Fdflags; +use wasmer_wasix::types::{wasi::Filesize, *}; +use wasmer_wasix::{VirtualFile, WasiFsError, ALL_RIGHTS}; +use wasmer_wasix_types::wasi::Fdflags; use minifb::{Key, KeyRepeat, MouseButton, Scale, Window, WindowOptions}; @@ -16,8 +16,8 @@ mod util; use util::*; use std::cell::RefCell; -use wasmer_wasi::os::fs::fd::Fd; -use wasmer_wasi::os::fs::{WasiFs, WasiInodes, VIRTUAL_ROOT_FD}; +use wasmer_wasix::os::fs::fd::Fd; +use wasmer_wasix::os::fs::{WasiFs, WasiInodes, VIRTUAL_ROOT_FD}; std::thread_local! { pub(crate) static FRAMEBUFFER_STATE: RefCell = RefCell::new(FrameBufferState::new() diff --git a/lib/wasi-local-networking/Cargo.toml b/lib/wasi-local-networking/Cargo.toml index 693ead78b19..10864a05a2e 100644 --- a/lib/wasi-local-networking/Cargo.toml +++ b/lib/wasi-local-networking/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wasmer-wasi-local-networking" -version = "3.2.0-alpha.1" +name = "virtnet-native" +version = "0.1.0" description = "An WASIX extension for local networking" categories = ["wasm"] -keywords = ["wasm", "webassembly", "types"] +keywords = ["wasm", "webassembly", "types", "wasix"] authors = ["Wasmer Engineering Team "] repository = "https://github.com/wasmerio/wasmer" license = "MIT" @@ -14,7 +14,7 @@ edition = "2018" maintenance = { status = "experimental" } [dependencies] -wasmer-vnet = { version = "=3.2.0-alpha.1", path = "../vnet" } +virtnet = { version = "0.1.0", path = "../vnet" } tracing = "0.1" bytes = "1.1" tokio = { version = "1", features = [ "sync", "macros", "io-util", "signal" ], default_features = false } diff --git a/lib/wasi-local-networking/src/lib.rs b/lib/wasi-local-networking/src/lib.rs index c1485feec0c..58b3fd6bc91 100644 --- a/lib/wasi-local-networking/src/lib.rs +++ b/lib/wasi-local-networking/src/lib.rs @@ -11,7 +11,7 @@ use tokio::sync::mpsc; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; #[allow(unused_imports)] -use wasmer_vnet::{ +use virtnet::{ IpCidr, IpRoute, NetworkError, Result, SocketStatus, StreamSecurity, VirtualConnectedSocket, VirtualConnectionlessSocket, VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, VirtualSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, diff --git a/lib/wasi-types/Cargo.toml b/lib/wasi-types/Cargo.toml index cb542b6bced..d6691fb1867 100644 --- a/lib/wasi-types/Cargo.toml +++ b/lib/wasi-types/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wasmer-wasi-types" -version = "3.2.0-alpha.1" -description = "WASI types for Wasmer WebAssembly runtime" +name = "wasmer-wasix-types" +version = "0.1.0" +description = "WASI and WASIX types for Wasmer WebAssembly runtime" categories = ["wasm", "os"] -keywords = ["wasm", "webassembly", "wasi", "sandbox", "ABI"] +keywords = ["wasm", "webassembly", "wasi", "wasix", "sandbox", "ABI"] authors = ["Wasmer Engineering Team "] repository = "https://github.com/wasmerio/wasmer" license = "MIT" diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index 425e885ca88..b5258552863 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -1,9 +1,9 @@ [package] -name = "wasmer-wasi" -version = "3.2.0-alpha.1" -description = "WASI implementation library for Wasmer WebAssembly runtime" +name = "wasmer-wasix" +version = "0.1.0" +description = "WASI and WASIX implementation library for Wasmer WebAssembly runtime" categories = ["wasm", "os"] -keywords = ["wasm", "webassembly", "wasi", "sandbox", "ABI"] +keywords = ["wasm", "webassembly", "wasi", "wasix", "sandbox", "ABI"] authors = ["Wasmer Engineering Team "] repository = "https://github.com/wasmerio/wasmer" license = "MIT" @@ -15,13 +15,13 @@ cfg-if = "1.0" thiserror = "1" tracing = { version = "0.1" } getrandom = "0.2" -wasmer-wasi-types = { path = "../wasi-types", version = "=3.2.0-alpha.1" } +wasmer-wasix-types = { path = "../wasi-types", version = "0.1.0" } wasmer-types = { path = "../types", version = "=3.2.0-alpha.1", default-features = false } wasmer = { path = "../api", version = "=3.2.0-alpha.1", default-features = false, features = ["wat", "js-serializable-module"] } -wasmer-vfs = { path = "../vfs", version = "=3.2.0-alpha.1", default-features = false, features = ["webc-fs"] } wasmer-vm = { path = "../vm", version = "=3.2.0-alpha.1", optional = true } -wasmer-vnet = { path = "../vnet", version = "=3.2.0-alpha.1", default-features = false } -wasmer-wasi-local-networking = { path = "../wasi-local-networking", version = "=3.2.0-alpha.1", default-features = false, optional = true } +virtfs = { path = "../vfs", version = "0.1.0", default-features = false, features = ["webc-fs"] } +virtnet = { path = "../vnet", version = "0.1.0", default-features = false } +virtnet-native = { path = "../wasi-local-networking", version = "0.1.0", default-features = false, optional = true } wasmer-emscripten = { path = "../emscripten", version = "=3.2.0-alpha.1", optional = true } typetag = { version = "0.1", optional = true } serde = { version = "1.0", default-features = false, features = ["derive"] } @@ -101,21 +101,21 @@ webc_runner_rt_wasi = [] webc_runner_rt_wcgi = ["hyper", "wcgi", "wcgi-host"] webc_runner_rt_emscripten = ["wasmer-emscripten"] -sys = ["wasmer/sys", "wasmer-wasi-types/sys", "webc/mmap", "wasmer-vm", "time"] +sys = ["wasmer/sys", "wasmer-wasix-types/sys", "webc/mmap", "wasmer-vm", "time"] sys-default = ["wasmer/wat", "wasmer/compiler", "sys", "logging", "host-fs", "sys-poll", "sys-thread", "host-vnet", "host-threads", "host-reqwest" ] sys-poll = [] sys-thread = ["tokio/rt", "tokio/time", "tokio/rt-multi-thread"] compiler = [ "wasmer/compiler", "wasmer-compiler"] -js = ["wasmer/js", "wasmer-vfs/no-time", "getrandom/js", "chrono", "wasmer-wasi-types/js"] +js = ["wasmer/js", "virtfs/no-time", "getrandom/js", "chrono", "wasmer-wasix-types/js"] js-default = ["js", "wasmer/js-default"] test-js = ["js", "wasmer/js-default", "wasmer/wat"] -host-vnet = [ "wasmer-wasi-local-networking" ] +host-vnet = [ "virtnet-native" ] host-threads = [] host-reqwest = ["reqwest"] -host-fs = ["wasmer-vfs/host-fs"] +host-fs = ["virtfs/host-fs"] host-termios = ["termios", "term_size"] logging = ["tracing/log"] @@ -125,7 +125,7 @@ disable-all-logging = [ ] enable-serde = [ "typetag", - "wasmer-vfs/enable-serde", - "wasmer-wasi-types/enable-serde", + "virtfs/enable-serde", + "wasmer-wasix-types/enable-serde", ] diff --git a/lib/wasi/README.md b/lib/wasi/README.md index e65e2508d36..ac56c8069dd 100644 --- a/lib/wasi/README.md +++ b/lib/wasi/README.md @@ -61,7 +61,7 @@ Hello, Some("Gordon") ```rust use wasmer::{Store, Module, Instance}; -use wasmer_wasi::WasiState; +use wasmer_wasix::WasiState; let mut store = Store::default(); let module = Module::from_file(&store, "hello.wasm")?; diff --git a/lib/wasi/src/bin_factory/binary_package.rs b/lib/wasi/src/bin_factory/binary_package.rs index 814be7b8415..c7f9adf9be8 100644 --- a/lib/wasi/src/bin_factory/binary_package.rs +++ b/lib/wasi/src/bin_factory/binary_package.rs @@ -6,8 +6,8 @@ use std::{ }; use derivative::*; -use wasmer_vfs::{FileSystem, TmpFileSystem}; -use wasmer_wasi_types::wasi::Snapshot0Clockid; +use virtfs::{FileSystem, TmpFileSystem}; +use wasmer_wasix_types::wasi::Snapshot0Clockid; use super::hash_of_binary; use crate::syscalls::platform_clock_time_get; diff --git a/lib/wasi/src/bin_factory/exec.rs b/lib/wasi/src/bin_factory/exec.rs index 791d9a727d1..92a115ebddc 100644 --- a/lib/wasi/src/bin_factory/exec.rs +++ b/lib/wasi/src/bin_factory/exec.rs @@ -9,7 +9,7 @@ use tracing::*; #[cfg(feature = "sys")] use wasmer::NativeEngineExt; use wasmer::{FunctionEnvMut, Instance, Memory, Module, Store}; -use wasmer_wasi_types::wasi::{Errno, ExitCode}; +use wasmer_wasix_types::wasi::{Errno, ExitCode}; use super::{BinFactory, BinaryPackage, ModuleCache}; use crate::{ diff --git a/lib/wasi/src/bin_factory/mod.rs b/lib/wasi/src/bin_factory/mod.rs index d39becba4d3..72bcad224dc 100644 --- a/lib/wasi/src/bin_factory/mod.rs +++ b/lib/wasi/src/bin_factory/mod.rs @@ -4,7 +4,7 @@ use std::{ sync::{Arc, RwLock}, }; -use wasmer_vfs::{AsyncReadExt, FileSystem}; +use virtfs::{AsyncReadExt, FileSystem}; mod binary_package; mod exec; diff --git a/lib/wasi/src/bin_factory/module_cache.rs b/lib/wasi/src/bin_factory/module_cache.rs index e87e111703b..a016a2f18d9 100644 --- a/lib/wasi/src/bin_factory/module_cache.rs +++ b/lib/wasi/src/bin_factory/module_cache.rs @@ -7,7 +7,7 @@ use std::{ }; use wasmer::Module; -use wasmer_wasi_types::wasi::Snapshot0Clockid; +use wasmer_wasix_types::wasi::Snapshot0Clockid; use super::BinaryPackage; use crate::{syscalls::platform_clock_time_get, WasiRuntime}; diff --git a/lib/wasi/src/fs/fd.rs b/lib/wasi/src/fs/fd.rs index e96844dd0ca..7dea933910e 100644 --- a/lib/wasi/src/fs/fd.rs +++ b/lib/wasi/src/fs/fd.rs @@ -7,8 +7,8 @@ use std::{ #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; -use wasmer_vfs::{Pipe, VirtualFile}; -use wasmer_wasi_types::wasi::{Fd as WasiFd, Fdflags, Filestat, Rights}; +use virtfs::{Pipe, VirtualFile}; +use wasmer_wasix_types::wasi::{Fd as WasiFd, Fdflags, Filestat, Rights}; use crate::net::socket::InodeSocket; diff --git a/lib/wasi/src/fs/inode_guard.rs b/lib/wasi/src/fs/inode_guard.rs index e02ae40761c..52fd5129842 100644 --- a/lib/wasi/src/fs/inode_guard.rs +++ b/lib/wasi/src/fs/inode_guard.rs @@ -9,9 +9,9 @@ use std::{ }; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite}; -use wasmer_vfs::{FsError, VirtualFile}; -use wasmer_vnet::NetworkError; -use wasmer_wasi_types::{ +use virtfs::{FsError, VirtualFile}; +use virtnet::NetworkError; +use wasmer_wasix_types::{ types::Eventtype, wasi, wasi::{Errno, Event, EventFdReadwrite, EventUnion, Eventrwflags, Subscription}, diff --git a/lib/wasi/src/fs/mod.rs b/lib/wasi/src/fs/mod.rs index f04fafac096..330433d587e 100644 --- a/lib/wasi/src/fs/mod.rs +++ b/lib/wasi/src/fs/mod.rs @@ -18,8 +18,8 @@ use crate::state::{Stderr, Stdin, Stdout}; use serde_derive::{Deserialize, Serialize}; use tokio::io::AsyncWriteExt; use tracing::{debug, trace}; -use wasmer_vfs::{FileSystem, FsError, OpenOptions, VirtualFile}; -use wasmer_wasi_types::{ +use virtfs::{FileSystem, FsError, OpenOptions, VirtualFile}; +use wasmer_wasix_types::{ types::{__WASI_STDERR_FILENO, __WASI_STDIN_FILENO, __WASI_STDOUT_FILENO}, wasi::{ Errno, Fd as WasiFd, Fdflags, Fdstat, Filesize, Filestat, Filetype, Preopentype, Prestat, @@ -261,48 +261,48 @@ impl Default for WasiInodes { #[derive(Debug, Clone)] pub enum WasiFsRoot { - Sandbox(Arc), + Sandbox(Arc), Backing(Arc>), } impl FileSystem for WasiFsRoot { - fn read_dir(&self, path: &Path) -> wasmer_vfs::Result { + fn read_dir(&self, path: &Path) -> virtfs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.read_dir(path), WasiFsRoot::Backing(fs) => fs.read_dir(path), } } - fn create_dir(&self, path: &Path) -> wasmer_vfs::Result<()> { + fn create_dir(&self, path: &Path) -> virtfs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.create_dir(path), WasiFsRoot::Backing(fs) => fs.create_dir(path), } } - fn remove_dir(&self, path: &Path) -> wasmer_vfs::Result<()> { + fn remove_dir(&self, path: &Path) -> virtfs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.remove_dir(path), WasiFsRoot::Backing(fs) => fs.remove_dir(path), } } - fn rename(&self, from: &Path, to: &Path) -> wasmer_vfs::Result<()> { + fn rename(&self, from: &Path, to: &Path) -> virtfs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.rename(from, to), WasiFsRoot::Backing(fs) => fs.rename(from, to), } } - fn metadata(&self, path: &Path) -> wasmer_vfs::Result { + fn metadata(&self, path: &Path) -> virtfs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.metadata(path), WasiFsRoot::Backing(fs) => fs.metadata(path), } } - fn symlink_metadata(&self, path: &Path) -> wasmer_vfs::Result { + fn symlink_metadata(&self, path: &Path) -> virtfs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.symlink_metadata(path), WasiFsRoot::Backing(fs) => fs.symlink_metadata(path), } } - fn remove_file(&self, path: &Path) -> wasmer_vfs::Result<()> { + fn remove_file(&self, path: &Path) -> virtfs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.remove_file(path), WasiFsRoot::Backing(fs) => fs.remove_file(path), @@ -1763,12 +1763,12 @@ impl std::fmt::Debug for WasiFs { } /// Returns the default filesystem backing -pub fn default_fs_backing() -> Box { +pub fn default_fs_backing() -> Box { cfg_if::cfg_if! { if #[cfg(feature = "host-fs")] { - Box::new(wasmer_vfs::host_fs::FileSystem::default()) + Box::new(virtfs::host_fs::FileSystem::default()) } else if #[cfg(not(feature = "host-fs"))] { - Box::new(wasmer_vfs::mem_fs::FileSystem::default()) + Box::new(virtfs::mem_fs::FileSystem::default()) } else { Box::new(FallbackFileSystem::default()) } @@ -1785,7 +1785,7 @@ impl FallbackFileSystem { } impl FileSystem for FallbackFileSystem { - fn read_dir(&self, _path: &Path) -> Result { + fn read_dir(&self, _path: &Path) -> Result { Self::fail(); } fn create_dir(&self, _path: &Path) -> Result<(), FsError> { @@ -1797,21 +1797,21 @@ impl FileSystem for FallbackFileSystem { fn rename(&self, _from: &Path, _to: &Path) -> Result<(), FsError> { Self::fail(); } - fn metadata(&self, _path: &Path) -> Result { + fn metadata(&self, _path: &Path) -> Result { Self::fail(); } - fn symlink_metadata(&self, _path: &Path) -> Result { + fn symlink_metadata(&self, _path: &Path) -> Result { Self::fail(); } fn remove_file(&self, _path: &Path) -> Result<(), FsError> { Self::fail(); } - fn new_open_options(&self) -> wasmer_vfs::OpenOptions { + fn new_open_options(&self) -> virtfs::OpenOptions { Self::fail(); } } -pub fn virtual_file_type_to_wasi_file_type(file_type: wasmer_vfs::FileType) -> Filetype { +pub fn virtual_file_type_to_wasi_file_type(file_type: virtfs::FileType) -> Filetype { // TODO: handle other file types if file_type.is_dir() { Filetype::Directory diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index bb23dc35660..900ce649f8f 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -65,27 +65,27 @@ use thiserror::Error; use tracing::error; // re-exports needed for OS pub use wasmer; -pub use wasmer_wasi_types; +pub use wasmer_wasix_types; use wasmer::{ imports, namespace, AsStoreMut, Exports, FunctionEnv, Imports, Memory32, MemoryAccessError, MemorySize, RuntimeError, }; -pub use wasmer_vfs; -#[deprecated(since = "2.1.0", note = "Please use `wasmer_vfs::FsError`")] -pub use wasmer_vfs::FsError as WasiFsError; -#[deprecated(since = "2.1.0", note = "Please use `wasmer_vfs::VirtualFile`")] -pub use wasmer_vfs::VirtualFile as WasiFile; -pub use wasmer_vfs::{DuplexPipe, FsError, Pipe, VirtualFile, WasiBidirectionalSharedPipePair}; -pub use wasmer_vnet; -pub use wasmer_vnet::{UnsupportedVirtualNetworking, VirtualNetworking}; +pub use virtfs; +#[deprecated(since = "2.1.0", note = "Please use `virtfs::FsError`")] +pub use virtfs::FsError as WasiFsError; +#[deprecated(since = "2.1.0", note = "Please use `virtfs::VirtualFile`")] +pub use virtfs::VirtualFile as WasiFile; +pub use virtfs::{DuplexPipe, FsError, Pipe, VirtualFile, WasiBidirectionalSharedPipePair}; +pub use virtnet; +pub use virtnet::{UnsupportedVirtualNetworking, VirtualNetworking}; #[cfg(feature = "host-vnet")] -pub use wasmer_wasi_local_networking::{ +pub use virtnet_native::{ io_err_into_net_error, LocalNetworking, LocalTcpListener, LocalTcpStream, LocalUdpSocket, }; -use wasmer_wasi_types::wasi::{BusErrno, Errno, ExitCode}; +use wasmer_wasix_types::wasi::{BusErrno, Errno, ExitCode}; pub use crate::{ fs::{default_fs_backing, Fd, WasiFs, WasiInodes, VIRTUAL_ROOT_FD}, diff --git a/lib/wasi/src/net/mod.rs b/lib/wasi/src/net/mod.rs index e64065ae72b..89f1acbce2a 100644 --- a/lib/wasi/src/net/mod.rs +++ b/lib/wasi/src/net/mod.rs @@ -4,10 +4,10 @@ use std::{ time::Duration, }; +use virtnet::{IpCidr, IpRoute, NetworkError}; use wasmer::{MemoryView, WasmPtr}; use wasmer_types::MemorySize; -use wasmer_vnet::{IpCidr, IpRoute, NetworkError}; -use wasmer_wasi_types::{ +use wasmer_wasix_types::{ types::{ OptionTag, OptionTimestamp, Route, __wasi_addr_ip4_t, __wasi_addr_ip6_t, __wasi_addr_port_t, __wasi_addr_port_u, __wasi_addr_t, __wasi_addr_u, __wasi_cidr_t, diff --git a/lib/wasi/src/net/socket.rs b/lib/wasi/src/net/socket.rs index c4d2ddddc02..942ac16b090 100644 --- a/lib/wasi/src/net/socket.rs +++ b/lib/wasi/src/net/socket.rs @@ -10,12 +10,12 @@ use std::{ #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; -use wasmer_types::MemorySize; -use wasmer_vnet::{ +use virtnet::{ VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, }; -use wasmer_wasi_types::wasi::{ +use wasmer_types::MemorySize; +use wasmer_wasix_types::wasi::{ Addressfamily, Errno, Fdflags, Rights, SockProto, Sockoption, Socktype, }; @@ -1213,7 +1213,7 @@ impl InodeSocketProtected { pub fn poll_read_ready( &mut self, cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { + ) -> std::task::Poll> { match &mut self.kind { InodeSocketKind::TcpListener { socket, .. } => socket.poll_accept_ready(cx), InodeSocketKind::TcpStream { socket, .. } => socket.poll_read_ready(cx), @@ -1221,7 +1221,7 @@ impl InodeSocketProtected { InodeSocketKind::Raw(socket) => socket.poll_read_ready(cx), InodeSocketKind::Icmp(socket) => socket.poll_read_ready(cx), InodeSocketKind::PreSocket { .. } => { - std::task::Poll::Ready(Err(wasmer_vnet::NetworkError::IOError)) + std::task::Poll::Ready(Err(virtnet::NetworkError::IOError)) } } } @@ -1229,7 +1229,7 @@ impl InodeSocketProtected { pub fn poll_write_ready( &mut self, cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { + ) -> std::task::Poll> { match &mut self.kind { InodeSocketKind::TcpListener { .. } => std::task::Poll::Pending, InodeSocketKind::TcpStream { socket, .. } => socket.poll_write_ready(cx), @@ -1237,7 +1237,7 @@ impl InodeSocketProtected { InodeSocketKind::Raw(socket) => socket.poll_write_ready(cx), InodeSocketKind::Icmp(socket) => socket.poll_write_ready(cx), InodeSocketKind::PreSocket { .. } => { - std::task::Poll::Ready(Err(wasmer_vnet::NetworkError::IOError)) + std::task::Poll::Ready(Err(virtnet::NetworkError::IOError)) } } } diff --git a/lib/wasi/src/os/command/builtins/cmd_wasmer.rs b/lib/wasi/src/os/command/builtins/cmd_wasmer.rs index 1b7954f2d99..1bde0402d4b 100644 --- a/lib/wasi/src/os/command/builtins/cmd_wasmer.rs +++ b/lib/wasi/src/os/command/builtins/cmd_wasmer.rs @@ -5,7 +5,7 @@ use crate::{ VirtualBusError, }; use wasmer::{FunctionEnvMut, Store}; -use wasmer_wasi_types::wasi::Errno; +use wasmer_wasix_types::wasi::Errno; use crate::{ bin_factory::{spawn_exec, BinaryPackage, ModuleCache}, diff --git a/lib/wasi/src/os/command/mod.rs b/lib/wasi/src/os/command/mod.rs index dbe78f9c125..cb0093db7a4 100644 --- a/lib/wasi/src/os/command/mod.rs +++ b/lib/wasi/src/os/command/mod.rs @@ -3,7 +3,7 @@ pub mod builtins; use std::{collections::HashMap, sync::Arc}; use wasmer::{FunctionEnvMut, Store}; -use wasmer_wasi_types::wasi::Errno; +use wasmer_wasix_types::wasi::Errno; use crate::{ bin_factory::ModuleCache, syscalls::stderr_write, VirtualBusError, WasiEnv, WasiRuntime, diff --git a/lib/wasi/src/os/console/mod.rs b/lib/wasi/src/os/console/mod.rs index 094b2d9fe83..160a764d311 100644 --- a/lib/wasi/src/os/console/mod.rs +++ b/lib/wasi/src/os/console/mod.rs @@ -16,13 +16,13 @@ use linked_hash_set::LinkedHashSet; use tokio::sync::{mpsc, RwLock}; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; -#[cfg(feature = "sys")] -use wasmer::Engine; -use wasmer_vfs::{ +use virtfs::{ ArcBoxFile, ArcFile, AsyncWriteExt, CombineFile, DeviceFile, DuplexPipe, FileSystem, Pipe, PipeRx, PipeTx, RootFileSystemBuilder, VirtualFile, }; -use wasmer_wasi_types::{types::__WASI_STDIN_FILENO, wasi::BusErrno}; +#[cfg(feature = "sys")] +use wasmer::Engine; +use wasmer_wasix_types::{types::__WASI_STDIN_FILENO, wasi::BusErrno}; use super::{cconst::ConsoleConst, common::*, task::TaskJoinHandle}; use crate::{ @@ -209,7 +209,7 @@ impl Console { } else { let mut stderr = self.stderr.clone(); tasks.block_on(async { - wasmer_vfs::AsyncWriteExt::write_all( + virtfs::AsyncWriteExt::write_all( &mut stderr, format!("package not found [{}]\r\n", webc).as_bytes(), ) @@ -229,12 +229,9 @@ impl Console { if let Err(err) = env.uses(self.uses.clone()) { let mut stderr = self.stderr.clone(); tasks.block_on(async { - wasmer_vfs::AsyncWriteExt::write_all( - &mut stderr, - format!("{}\r\n", err).as_bytes(), - ) - .await - .ok(); + virtfs::AsyncWriteExt::write_all(&mut stderr, format!("{}\r\n", err).as_bytes()) + .await + .ok(); }); tracing::debug!("failed to load used dependency - {}", err); return Err(VirtualBusError::BadRequest); @@ -268,7 +265,7 @@ impl Console { data.insert_str(0, ConsoleConst::TERM_NO_WRAPAROUND); let mut stderr = self.stderr.clone(); - wasmer_vfs::AsyncWriteExt::write_all(&mut stderr, data.as_str().as_bytes()) + virtfs::AsyncWriteExt::write_all(&mut stderr, data.as_str().as_bytes()) .await .ok(); } diff --git a/lib/wasi/src/os/task/process.rs b/lib/wasi/src/os/task/process.rs index b2ceb2667b6..0c80b3f2c8a 100644 --- a/lib/wasi/src/os/task/process.rs +++ b/lib/wasi/src/os/task/process.rs @@ -11,7 +11,7 @@ use std::{ use crate::WasiRuntimeError; use tracing::trace; -use wasmer_wasi_types::{ +use wasmer_wasix_types::{ types::Signal, wasi::{Errno, ExitCode, Snapshot0Clockid, TlKey, TlUser, TlVal}, }; diff --git a/lib/wasi/src/os/task/signal.rs b/lib/wasi/src/os/task/signal.rs index 1ed12bd62a3..28462829bab 100644 --- a/lib/wasi/src/os/task/signal.rs +++ b/lib/wasi/src/os/task/signal.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use wasmer_wasi_types::types::Signal; +use wasmer_wasix_types::types::Signal; #[derive(thiserror::Error, Debug)] #[error("Signal could not be delivered")] diff --git a/lib/wasi/src/os/task/task_join_handle.rs b/lib/wasi/src/os/task/task_join_handle.rs index 62b534caf05..c4fa6b14293 100644 --- a/lib/wasi/src/os/task/task_join_handle.rs +++ b/lib/wasi/src/os/task/task_join_handle.rs @@ -4,7 +4,7 @@ use std::{ task::{Context, Poll}, }; -use wasmer_wasi_types::wasi::{Errno, ExitCode}; +use wasmer_wasix_types::wasi::{Errno, ExitCode}; use crate::WasiRuntimeError; diff --git a/lib/wasi/src/os/task/thread.rs b/lib/wasi/src/os/task/thread.rs index 6304f20e7c3..38098ee20de 100644 --- a/lib/wasi/src/os/task/thread.rs +++ b/lib/wasi/src/os/task/thread.rs @@ -6,7 +6,7 @@ use std::{ }; use bytes::{Bytes, BytesMut}; -use wasmer_wasi_types::{ +use wasmer_wasix_types::{ types::Signal, wasi::{Errno, ExitCode}, }; diff --git a/lib/wasi/src/os/tty/mod.rs b/lib/wasi/src/os/tty/mod.rs index 02e29da0edb..2492040fef0 100644 --- a/lib/wasi/src/os/tty/mod.rs +++ b/lib/wasi/src/os/tty/mod.rs @@ -5,8 +5,8 @@ use std::{ use derivative::*; use futures::future::BoxFuture; -use wasmer_vfs::{AsyncWriteExt, NullFile, VirtualFile}; -use wasmer_wasi_types::wasi::{Signal, Snapshot0Clockid}; +use virtfs::{AsyncWriteExt, NullFile, VirtualFile}; +use wasmer_wasix_types::wasi::{Signal, Snapshot0Clockid}; use crate::syscalls::platform_clock_time_get; diff --git a/lib/wasi/src/runners/container.rs b/lib/wasi/src/runners/container.rs index 31c58fec1a0..befad496213 100644 --- a/lib/wasi/src/runners/container.rs +++ b/lib/wasi/src/runners/container.rs @@ -1,7 +1,7 @@ use std::{path::PathBuf, sync::Arc}; use bytes::Bytes; -use wasmer_vfs::{webc_fs::WebcFileSystem, FileSystem}; +use virtfs::{webc_fs::WebcFileSystem, FileSystem}; use webc::{ metadata::Manifest, v1::{ParseOptions, WebC, WebCMmap, WebCOwned}, diff --git a/lib/wasi/src/runners/wcgi/handler.rs b/lib/wasi/src/runners/wcgi/handler.rs index aa5bd5d47dd..d5cd7772b5d 100644 --- a/lib/wasi/src/runners/wcgi/handler.rs +++ b/lib/wasi/src/runners/wcgi/handler.rs @@ -15,8 +15,8 @@ use tokio::{ io::{AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt}, runtime::Handle, }; +use virtfs::{FileSystem, PassthruFileSystem, RootFileSystemBuilder, TmpFileSystem}; use wasmer::Module; -use wasmer_vfs::{FileSystem, PassthruFileSystem, RootFileSystemBuilder, TmpFileSystem}; use wcgi_host::CgiDialect; use crate::{ diff --git a/lib/wasi/src/runners/wcgi/runner.rs b/lib/wasi/src/runners/wcgi/runner.rs index 516e7bbe532..081b1fda7fd 100644 --- a/lib/wasi/src/runners/wcgi/runner.rs +++ b/lib/wasi/src/runners/wcgi/runner.rs @@ -2,8 +2,8 @@ use std::{collections::HashMap, convert::Infallible, net::SocketAddr, path::Path use anyhow::{Context, Error}; use futures::future::AbortHandle; +use virtfs::FileSystem; use wasmer::{Engine, Module, Store}; -use wasmer_vfs::FileSystem; use wcgi_host::CgiDialect; use webc::metadata::{ annotations::{Wasi, Wcgi}, diff --git a/lib/wasi/src/runtime/mod.rs b/lib/wasi/src/runtime/mod.rs index f2bc1c367e9..c2b04c6c8b0 100644 --- a/lib/wasi/src/runtime/mod.rs +++ b/lib/wasi/src/runtime/mod.rs @@ -4,7 +4,7 @@ pub use self::task_manager::{SpawnType, SpawnedMemory, VirtualTaskManager}; use std::{fmt, sync::Arc}; -use wasmer_vnet::{DynVirtualNetworking, VirtualNetworking}; +use virtnet::{DynVirtualNetworking, VirtualNetworking}; use crate::{http::DynHttpClient, os::TtyBridge}; @@ -83,9 +83,9 @@ impl PluggableRuntimeImplementation { // TODO: the cfg flags below should instead be handled by separate implementations. cfg_if::cfg_if! { if #[cfg(feature = "host-vnet")] { - let networking = Arc::new(wasmer_wasi_local_networking::LocalNetworking::default()); + let networking = Arc::new(virtnet_native::LocalNetworking::default()); } else { - let networking = Arc::new(wasmer_vnet::UnsupportedVirtualNetworking::default()); + let networking = Arc::new(virtnet::UnsupportedVirtualNetworking::default()); } } cfg_if::cfg_if! { diff --git a/lib/wasi/src/state/builder.rs b/lib/wasi/src/state/builder.rs index fb86ecc7f15..d48862f9bd7 100644 --- a/lib/wasi/src/state/builder.rs +++ b/lib/wasi/src/state/builder.rs @@ -8,8 +8,8 @@ use std::{ use rand::Rng; use thiserror::Error; +use virtfs::{ArcFile, FsError, TmpFileSystem, VirtualFile}; use wasmer::{AsStoreMut, Instance, Module}; -use wasmer_vfs::{ArcFile, FsError, TmpFileSystem, VirtualFile}; use crate::{ bin_factory::{BinFactory, ModuleCache}, @@ -27,7 +27,7 @@ use super::env::WasiEnvInit; /// /// Usage: /// ```no_run -/// # use wasmer_wasi::{WasiEnv, WasiStateCreationError}; +/// # use wasmer_wasix::{WasiEnv, WasiStateCreationError}; /// # fn main() -> Result<(), WasiStateCreationError> { /// let mut state_builder = WasiEnv::builder("wasi-prog-name"); /// state_builder @@ -340,7 +340,7 @@ impl WasiEnvBuilder { /// Usage: /// /// ```no_run - /// # use wasmer_wasi::{WasiEnv, WasiStateCreationError}; + /// # use wasmer_wasix::{WasiEnv, WasiStateCreationError}; /// # fn main() -> Result<(), WasiStateCreationError> { /// WasiEnv::builder("program_name") /// .preopen_build(|p| p.directory("src").read(true).write(true).create(true))? @@ -362,7 +362,7 @@ impl WasiEnvBuilder { /// Usage: /// /// ```no_run - /// # use wasmer_wasi::{WasiEnv, WasiStateCreationError}; + /// # use wasmer_wasix::{WasiEnv, WasiStateCreationError}; /// # fn main() -> Result<(), WasiStateCreationError> { /// WasiEnv::builder("program_name") /// .preopen_build(|p| p.directory("src").read(true).write(true).create(true))? @@ -480,19 +480,19 @@ impl WasiEnvBuilder { /// Sets the FileSystem to be used with this WASI instance. /// - /// This is usually used in case a custom `wasmer_vfs::FileSystem` is needed. - pub fn fs(mut self, fs: Box) -> Self { + /// This is usually used in case a custom `virtfs::FileSystem` is needed. + pub fn fs(mut self, fs: Box) -> Self { self.set_fs(fs); self } - pub fn set_fs(&mut self, fs: Box) { + pub fn set_fs(&mut self, fs: Box) { self.fs = Some(WasiFsRoot::Backing(Arc::new(fs))); } /// Sets a new sandbox FileSystem to be used with this WASI instance. /// - /// This is usually used in case a custom `wasmer_vfs::FileSystem` is needed. + /// This is usually used in case a custom `virtfs::FileSystem` is needed. pub fn sandbox_fs(mut self, fs: TmpFileSystem) -> Self { self.fs = Some(WasiFsRoot::Sandbox(Arc::new(fs))); self diff --git a/lib/wasi/src/state/env.rs b/lib/wasi/src/state/env.rs index 83830d55a47..ace93a1955f 100644 --- a/lib/wasi/src/state/env.rs +++ b/lib/wasi/src/state/env.rs @@ -3,15 +3,15 @@ use std::{collections::HashMap, ops::Deref, path::PathBuf, sync::Arc, time::Dura use derivative::Derivative; use rand::Rng; use tracing::{trace, warn}; +use virtfs::{FsError, VirtualFile}; +use virtnet::DynVirtualNetworking; #[cfg(feature = "sys")] use wasmer::NativeEngineExt; use wasmer::{ AsStoreMut, AsStoreRef, FunctionEnvMut, Global, Instance, Memory, MemoryView, Module, TypedFunction, }; -use wasmer_vfs::{FsError, VirtualFile}; -use wasmer_vnet::DynVirtualNetworking; -use wasmer_wasi_types::{ +use wasmer_wasix_types::{ types::Signal, wasi::{Errno, ExitCode, Snapshot0Clockid}, }; @@ -766,7 +766,7 @@ impl WasiEnv { use std::{borrow::Cow, collections::VecDeque}; #[allow(unused_imports)] - use wasmer_vfs::FileSystem; + use virtfs::FileSystem; let mut already: HashMap> = HashMap::new(); @@ -859,7 +859,7 @@ impl WasiEnv { use std::path::Path; #[allow(unused_imports)] - use wasmer_vfs::FileSystem; + use virtfs::FileSystem; #[cfg(feature = "sys")] for (command, target) in map_commands.iter() { diff --git a/lib/wasi/src/state/func_env.rs b/lib/wasi/src/state/func_env.rs index 900017f8fa1..2649ca3927c 100644 --- a/lib/wasi/src/state/func_env.rs +++ b/lib/wasi/src/state/func_env.rs @@ -1,6 +1,6 @@ use tracing::trace; use wasmer::{AsStoreMut, AsStoreRef, ExportError, FunctionEnv, Imports, Instance, Memory, Module}; -use wasmer_wasi_types::wasi::ExitCode; +use wasmer_wasix_types::wasi::ExitCode; use crate::{ state::WasiInstanceHandles, diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index ef3316eb839..23dd529d7ed 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -32,9 +32,9 @@ use std::{ use derivative::Derivative; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; +use virtfs::{FileOpener, FileSystem, FsError, OpenOptions, VirtualFile}; use wasmer::Store; -use wasmer_vfs::{FileOpener, FileSystem, FsError, OpenOptions, VirtualFile}; -use wasmer_wasi_types::wasi::{Errno, Fd as WasiFd, Rights, Snapshot0Clockid}; +use wasmer_wasix_types::wasi::{Errno, Fd as WasiFd, Rights, Snapshot0Clockid}; pub use self::{ builder::*, @@ -61,8 +61,8 @@ impl FileOpener for WasiStateOpener { fn open( &self, path: &Path, - conf: &wasmer_vfs::OpenOptionsConfig, - ) -> wasmer_vfs::Result> { + conf: &virtfs::OpenOptionsConfig, + ) -> virtfs::Result> { let mut new_options = self.root_fs.new_open_options(); new_options.options(conf.clone()); new_options.open(path) @@ -177,10 +177,7 @@ impl WasiState { // Implementations of direct to FS calls so that we can easily change their implementation impl WasiState { - pub(crate) fn fs_read_dir>( - &self, - path: P, - ) -> Result { + pub(crate) fn fs_read_dir>(&self, path: P) -> Result { self.fs .root_fs .read_dir(path.as_ref()) diff --git a/lib/wasi/src/state/types.rs b/lib/wasi/src/state/types.rs index 7a0fe98f48d..3af247a9074 100644 --- a/lib/wasi/src/state/types.rs +++ b/lib/wasi/src/state/types.rs @@ -5,15 +5,15 @@ use cfg_if::cfg_if; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; -use wasmer_wasi_types::wasi::{BusErrno, Rights}; +use wasmer_wasix_types::wasi::{BusErrno, Rights}; use crate::VirtualBusError; cfg_if! { if #[cfg(feature = "host-fs")] { - pub use wasmer_vfs::host_fs::{Stderr, Stdin, Stdout}; + pub use virtfs::host_fs::{Stderr, Stdin, Stdout}; } else { - pub use wasmer_vfs::mem_fs::{Stderr, Stdin, Stdout}; + pub use virtfs::mem_fs::{Stderr, Stdin, Stdout}; } } diff --git a/lib/wasi/src/syscalls/legacy/snapshot0.rs b/lib/wasi/src/syscalls/legacy/snapshot0.rs index 3e1bdd696e3..e239fe26227 100644 --- a/lib/wasi/src/syscalls/legacy/snapshot0.rs +++ b/lib/wasi/src/syscalls/legacy/snapshot0.rs @@ -1,6 +1,6 @@ use tracing::{field, instrument, trace_span}; use wasmer::{AsStoreMut, FunctionEnvMut, WasmPtr}; -use wasmer_wasi_types::wasi::{ +use wasmer_wasix_types::wasi::{ Errno, Event, EventFdReadwrite, Eventrwflags, Eventtype, Fd, Filesize, Filestat, Filetype, Snapshot0Event, Snapshot0Filestat, Snapshot0Subscription, Snapshot0Whence, Subscription, Whence, diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index e3a3926a160..ccb55b50d35 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -1,7 +1,7 @@ #![allow(unused, clippy::too_many_arguments, clippy::cognitive_complexity)] pub mod types { - pub use wasmer_wasi_types::{types::*, wasi}; + pub use wasmer_wasix_types::{types::*, wasi}; } #[cfg(any( @@ -63,16 +63,16 @@ pub use unix::*; #[cfg(any(target_family = "wasm"))] pub use wasm::*; +pub(crate) use virtfs::{ + AsyncSeekExt, AsyncWriteExt, DuplexPipe, FileSystem, FsError, VirtualFile, +}; +pub(crate) use virtnet::StreamSecurity; pub(crate) use wasmer::{ AsStoreMut, AsStoreRef, Extern, Function, FunctionEnv, FunctionEnvMut, Global, Instance, Memory, Memory32, Memory64, MemoryAccessError, MemoryError, MemorySize, MemoryView, Module, OnCalledAction, Pages, RuntimeError, Store, TypedFunction, Value, WasmPtr, WasmSlice, }; -pub(crate) use wasmer_vfs::{ - AsyncSeekExt, AsyncWriteExt, DuplexPipe, FileSystem, FsError, VirtualFile, -}; -pub(crate) use wasmer_vnet::StreamSecurity; -pub(crate) use wasmer_wasi_types::{asyncify::__wasi_asyncify_t, wasi::EventUnion}; +pub(crate) use wasmer_wasix_types::{asyncify::__wasi_asyncify_t, wasi::EventUnion}; #[cfg(any(target_os = "windows"))] pub use windows::*; diff --git a/lib/wasi/src/syscalls/unix/mod.rs b/lib/wasi/src/syscalls/unix/mod.rs index 029390618f2..11b6bd143f0 100644 --- a/lib/wasi/src/syscalls/unix/mod.rs +++ b/lib/wasi/src/syscalls/unix/mod.rs @@ -5,7 +5,7 @@ use libc::{ CLOCK_REALTIME, CLOCK_THREAD_CPUTIME_ID, }; use wasmer::WasmRef; -use wasmer_wasi_types::wasi::{Errno, Snapshot0Clockid, Timestamp}; +use wasmer_wasix_types::wasi::{Errno, Snapshot0Clockid, Timestamp}; use crate::syscalls::types::*; diff --git a/lib/wasi/src/syscalls/wasi/fd_read.rs b/lib/wasi/src/syscalls/wasi/fd_read.rs index d8df4bc6b5c..0b3b73367f7 100644 --- a/lib/wasi/src/syscalls/wasi/fd_read.rs +++ b/lib/wasi/src/syscalls/wasi/fd_read.rs @@ -1,6 +1,6 @@ use std::{collections::VecDeque, task::Waker}; -use wasmer_vfs::{AsyncReadExt, ReadBuf}; +use virtfs::{AsyncReadExt, ReadBuf}; use super::*; use crate::{fs::NotificationInner, syscalls::*}; @@ -280,7 +280,7 @@ fn fd_read_internal( .map_err(mem_error_to_wasi)?; total_read += - wasmer_vfs::AsyncReadExt::read(&mut pipe, buf.as_mut()).await?; + virtfs::AsyncReadExt::read(&mut pipe, buf.as_mut()).await?; } Ok(total_read) } diff --git a/lib/wasi/src/syscalls/wasi/path_open.rs b/lib/wasi/src/syscalls/wasi/path_open.rs index 19d505af888..67414ecb336 100644 --- a/lib/wasi/src/syscalls/wasi/path_open.rs +++ b/lib/wasi/src/syscalls/wasi/path_open.rs @@ -109,7 +109,7 @@ pub fn path_open( (false, false, false) }; - wasmer_vfs::OpenOptionsConfig { + virtfs::OpenOptionsConfig { read: fs_rights_base.contains(Rights::FD_READ), write: write_permission, create_new: create_permission && o_flags.contains(Oflags::EXCL), @@ -118,7 +118,7 @@ pub fn path_open( truncate: truncate_permission, } } - Err(_) => wasmer_vfs::OpenOptionsConfig { + Err(_) => virtfs::OpenOptionsConfig { append: fs_flags.contains(Fdflags::APPEND), write: fs_rights_base.contains(Rights::FD_WRITE), read: fs_rights_base.contains(Rights::FD_READ), @@ -128,7 +128,7 @@ pub fn path_open( }, }; - let parent_rights = wasmer_vfs::OpenOptionsConfig { + let parent_rights = virtfs::OpenOptionsConfig { read: working_dir.rights.contains(Rights::FD_READ), write: working_dir.rights.contains(Rights::FD_WRITE), // The parent is a directory, which is why these options diff --git a/lib/wasi/src/syscalls/wasi/poll_oneoff.rs b/lib/wasi/src/syscalls/wasi/poll_oneoff.rs index 6285d56c9c7..479051ea6fe 100644 --- a/lib/wasi/src/syscalls/wasi/poll_oneoff.rs +++ b/lib/wasi/src/syscalls/wasi/poll_oneoff.rs @@ -1,6 +1,6 @@ use std::f32::consts::E; -use wasmer_wasi_types::wasi::SubscriptionClock; +use wasmer_wasix_types::wasi::SubscriptionClock; use super::*; use crate::{ diff --git a/lib/wasi/src/syscalls/wasix/fd_pipe.rs b/lib/wasi/src/syscalls/wasix/fd_pipe.rs index 2f6e4a8d527..fc0cc3650ba 100644 --- a/lib/wasi/src/syscalls/wasix/fd_pipe.rs +++ b/lib/wasi/src/syscalls/wasix/fd_pipe.rs @@ -1,4 +1,4 @@ -use wasmer_vfs::Pipe; +use virtfs::Pipe; use super::*; use crate::syscalls::*; diff --git a/lib/wasi/src/syscalls/wasix/proc_spawn.rs b/lib/wasi/src/syscalls/wasix/proc_spawn.rs index b6ce12fad89..65e2334d3de 100644 --- a/lib/wasi/src/syscalls/wasix/proc_spawn.rs +++ b/lib/wasi/src/syscalls/wasix/proc_spawn.rs @@ -1,4 +1,4 @@ -use wasmer_vfs::Pipe; +use virtfs::Pipe; use super::*; use crate::syscalls::*; diff --git a/lib/wasi/src/syscalls/wasix/sock_send_file.rs b/lib/wasi/src/syscalls/wasix/sock_send_file.rs index 2e3be8e26d5..90fceca2015 100644 --- a/lib/wasi/src/syscalls/wasix/sock_send_file.rs +++ b/lib/wasi/src/syscalls/wasix/sock_send_file.rs @@ -1,4 +1,4 @@ -use wasmer_vfs::AsyncReadExt; +use virtfs::AsyncReadExt; use super::*; use crate::{syscalls::*, WasiInodes}; @@ -130,7 +130,7 @@ pub fn sock_send_file( // TODO: optimize with MaybeUninit let mut buf = vec![0u8; sub_count as usize]; let amt = - wasmer_vfs::AsyncReadExt::read(pipe, &mut buf[..]) + virtfs::AsyncReadExt::read(pipe, &mut buf[..]) .await .map_err(map_io_err)?; buf.truncate(amt); diff --git a/lib/wasi/src/utils/mod.rs b/lib/wasi/src/utils/mod.rs index 260e81b6053..572e9e0fa22 100644 --- a/lib/wasi/src/utils/mod.rs +++ b/lib/wasi/src/utils/mod.rs @@ -8,7 +8,7 @@ pub use self::dummy_waker::WasiDummyWaker; use std::collections::BTreeSet; use wasmer::Module; -use wasmer_wasi_types::wasi::Errno; +use wasmer_wasix_types::wasi::Errno; pub use self::thread_parker::WasiParkingLot; pub(crate) use owned_mutex_guard::{ diff --git a/lib/wasi/src/wapm/mod.rs b/lib/wasi/src/wapm/mod.rs index 721ca216cc2..374e520677a 100644 --- a/lib/wasi/src/wapm/mod.rs +++ b/lib/wasi/src/wapm/mod.rs @@ -4,7 +4,7 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; -use wasmer_vfs::FileSystem; +use virtfs::FileSystem; use tracing::*; #[allow(unused_imports)] @@ -364,7 +364,7 @@ where } // Add the file system from the webc - let webc_fs = wasmer_vfs::webc_fs::WebcFileSystem::init_all(ownership.clone()); + let webc_fs = virtfs::webc_fs::WebcFileSystem::init_all(ownership.clone()); let top_level_dirs = webc_fs.top_level_dirs().clone(); pck.webc_fs = Some(Arc::new(webc_fs)); pck.webc_top_level_dirs = top_level_dirs; diff --git a/lib/wasi/tests/runners.rs b/lib/wasi/tests/runners.rs index 713ab862e16..6b37c4a8b2a 100644 --- a/lib/wasi/tests/runners.rs +++ b/lib/wasi/tests/runners.rs @@ -4,13 +4,13 @@ use std::{path::Path, time::Duration}; use once_cell::sync::Lazy; use reqwest::Client; -use wasmer_wasi::runners::{Runner, WapmContainer}; +use wasmer_wasix::runners::{Runner, WapmContainer}; #[cfg(feature = "webc_runner_rt_wasi")] mod wasi { use tokio::runtime::Handle; use wasmer::Store; - use wasmer_wasi::{ + use wasmer_wasix::{ runners::wasi::WasiRunner, runtime::task_manager::tokio::TokioTaskManager, WasiError, }; @@ -88,7 +88,7 @@ mod wcgi { use futures::{channel::mpsc::Sender, future::AbortHandle, SinkExt, StreamExt}; use rand::Rng; use tokio::runtime::Handle; - use wasmer_wasi::{runners::wcgi::WcgiRunner, runtime::task_manager::tokio::TokioTaskManager}; + use wasmer_wasix::{runners::wcgi::WcgiRunner, runtime::task_manager::tokio::TokioTaskManager}; use super::*; @@ -162,7 +162,7 @@ mod wcgi { handle: Handle, } - impl wasmer_wasi::runners::wcgi::Callbacks for Callbacks { + impl wasmer_wasix::runners::wcgi::Callbacks for Callbacks { fn started(&self, abort: futures::stream::AbortHandle) { let mut sender = self.sender.clone(); self.handle.spawn(async move { diff --git a/lib/wasi/tests/stdio.rs b/lib/wasi/tests/stdio.rs index e1480720330..fe5264857eb 100644 --- a/lib/wasi/tests/stdio.rs +++ b/lib/wasi/tests/stdio.rs @@ -1,8 +1,8 @@ use std::sync::Arc; +use virtfs::{AsyncReadExt, AsyncWriteExt}; use wasmer::{Module, Store}; -use wasmer_vfs::{AsyncReadExt, AsyncWriteExt}; -use wasmer_wasi::{Pipe, PluggableRuntimeImplementation, WasiEnv}; +use wasmer_wasix::{Pipe, PluggableRuntimeImplementation, WasiEnv}; mod sys { #[tokio::test] diff --git a/tests/lib/wast/Cargo.toml b/tests/lib/wast/Cargo.toml index b57115ab24c..8d959c111b3 100644 --- a/tests/lib/wast/Cargo.toml +++ b/tests/lib/wast/Cargo.toml @@ -13,8 +13,8 @@ edition = "2018" [dependencies] anyhow = "1.0" wasmer = { path = "../../../lib/api", version = "=3.2.0-alpha.1", default-features = false } -wasmer-wasi = { path = "../../../lib/wasi", version = "=3.2.0-alpha.1" } -wasmer-vfs = { path = "../../../lib/vfs", version = "=3.2.0-alpha.1" } +wasmer-wasix = { path = "../../../lib/wasi", version = "0.1.0" } +virtfs = { path = "../../../lib/vfs", version = "0.1.0" } wast = "38.0" serde = "1" tempfile = "3.4.0" diff --git a/tests/lib/wast/src/wasi_wast.rs b/tests/lib/wast/src/wasi_wast.rs index 4583f803f43..a19e696dc26 100644 --- a/tests/lib/wast/src/wasi_wast.rs +++ b/tests/lib/wast/src/wasi_wast.rs @@ -5,13 +5,13 @@ use std::path::{Path, PathBuf}; use std::pin::Pin; use std::sync::{mpsc, Arc, Mutex}; use std::task::{Context, Poll}; -use wasmer::{FunctionEnv, Imports, Module, Store}; -use wasmer_vfs::{ +use virtfs::{ host_fs, mem_fs, passthru_fs, tmp_fs, union_fs, AsyncRead, AsyncSeek, AsyncWrite, AsyncWriteExt, FileSystem, Pipe, ReadBuf, RootFileSystemBuilder, }; -use wasmer_wasi::types::wasi::{Filesize, Timestamp}; -use wasmer_wasi::{ +use wasmer::{FunctionEnv, Imports, Module, Store}; +use wasmer_wasix::types::wasi::{Filesize, Timestamp}; +use wasmer_wasix::{ generate_import_object_from_env, get_wasi_version, FsError, PluggableRuntimeImplementation, VirtualFile, WasiEnv, WasiEnvBuilder, WasiRuntime, WasiVersion, }; @@ -20,22 +20,22 @@ use wast::parser::{self, Parse, ParseBuffer, Parser}; /// The kind of filesystem `WasiTest` is going to use. #[derive(Debug)] pub enum WasiFileSystemKind { - /// Instruct the test runner to use `wasmer_vfs::host_fs`. + /// Instruct the test runner to use `virtfs::host_fs`. Host, - /// Instruct the test runner to use `wasmer_vfs::mem_fs`. + /// Instruct the test runner to use `virtfs::mem_fs`. InMemory, - /// Instruct the test runner to use `wasmer_vfs::tmp_fs` + /// Instruct the test runner to use `virtfs::tmp_fs` Tmp, - /// Instruct the test runner to use `wasmer_vfs::passtru_fs` + /// Instruct the test runner to use `virtfs::passtru_fs` PassthruMemory, - /// Instruct the test runner to use `wasmer_vfs::union_fs` + /// Instruct the test runner to use `virtfs::union_fs` UnionHostMemory, - /// Instruct the test runner to use the TempFs returned by `wasmer_vfs::builder::RootFileSystemBuilder` + /// Instruct the test runner to use the TempFs returned by `virtfs::builder::RootFileSystemBuilder` RootFileSystemBuilder, } @@ -690,7 +690,7 @@ impl AsyncRead for OutputCapturerer { } } -/// When using `wasmer_vfs::mem_fs`, we cannot rely on `BASE_TEST_DIR` +/// When using `virtfs::mem_fs`, we cannot rely on `BASE_TEST_DIR` /// because the host filesystem cannot be used. Instead, we are /// copying `BASE_TEST_DIR` to the `mem_fs`. fn map_host_fs_to_mem_fs<'a>( From f59ab5caee7fd1972994e139931df76bc3455527 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 16 Mar 2023 09:29:31 +0100 Subject: [PATCH 2/4] Renamed virtfs to virtual-fs and virtnet to virtual-net --- Cargo.lock | 40 +++++++++---------- lib/c-api/Cargo.toml | 4 +- lib/c-api/src/wasm_c_api/wasi/mod.rs | 4 +- lib/cli/Cargo.toml | 4 +- lib/cli/src/commands/run/wasi.rs | 6 +-- lib/sys-utils/tests/fd_mmap_memory.rs | 2 +- lib/vfs/Cargo.toml | 2 +- lib/vfs/src/union_fs.rs | 4 +- lib/vnet/Cargo.toml | 2 +- lib/wasi-local-networking/Cargo.toml | 2 +- lib/wasi-local-networking/src/lib.rs | 2 +- lib/wasi/Cargo.toml | 10 ++--- lib/wasi/src/bin_factory/binary_package.rs | 2 +- lib/wasi/src/bin_factory/mod.rs | 2 +- lib/wasi/src/fs/fd.rs | 2 +- lib/wasi/src/fs/inode_guard.rs | 4 +- lib/wasi/src/fs/mod.rs | 34 ++++++++-------- lib/wasi/src/lib.rs | 16 ++++---- lib/wasi/src/net/mod.rs | 2 +- lib/wasi/src/net/socket.rs | 10 ++--- lib/wasi/src/os/console/mod.rs | 8 ++-- lib/wasi/src/os/tty/mod.rs | 2 +- lib/wasi/src/runners/container.rs | 2 +- lib/wasi/src/runners/wcgi/handler.rs | 2 +- lib/wasi/src/runners/wcgi/runner.rs | 2 +- lib/wasi/src/runtime/mod.rs | 4 +- lib/wasi/src/state/builder.rs | 10 ++--- lib/wasi/src/state/env.rs | 8 ++-- lib/wasi/src/state/mod.rs | 8 ++-- lib/wasi/src/state/types.rs | 4 +- lib/wasi/src/syscalls/mod.rs | 4 +- lib/wasi/src/syscalls/wasi/fd_read.rs | 4 +- lib/wasi/src/syscalls/wasi/path_open.rs | 6 +-- lib/wasi/src/syscalls/wasix/fd_pipe.rs | 2 +- lib/wasi/src/syscalls/wasix/proc_spawn.rs | 2 +- lib/wasi/src/syscalls/wasix/sock_send_file.rs | 4 +- lib/wasi/src/wapm/mod.rs | 4 +- lib/wasi/tests/stdio.rs | 2 +- tests/lib/wast/Cargo.toml | 2 +- tests/lib/wast/src/wasi_wast.rs | 16 ++++---- 40 files changed, 125 insertions(+), 125 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index acfed8e49d7..b91374579d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4370,7 +4370,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] -name = "virtfs" +name = "virtnet-native" +version = "0.1.0" +dependencies = [ + "async-trait", + "bytes", + "libc", + "tokio", + "tracing", + "virtual-net", +] + +[[package]] +name = "virtual-fs" version = "0.1.0" dependencies = [ "anyhow", @@ -4393,7 +4405,7 @@ dependencies = [ ] [[package]] -name = "virtnet" +name = "virtual-net" version = "0.1.0" dependencies = [ "async-trait", @@ -4402,18 +4414,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "virtnet-native" -version = "0.1.0" -dependencies = [ - "async-trait", - "bytes", - "libc", - "tokio", - "tracing", - "virtnet", -] - [[package]] name = "void" version = "1.0.2" @@ -4843,7 +4843,7 @@ dependencies = [ "paste", "thiserror", "typetag", - "virtfs", + "virtual-fs", "wasmer", "wasmer-compiler", "wasmer-compiler-cranelift", @@ -4938,9 +4938,9 @@ dependencies = [ "tracing-subscriber 0.3.16", "unix_mode", "url", - "virtfs", - "virtnet", "virtnet-native", + "virtual-fs", + "virtual-net", "walkdir", "wasm-coredump-builder", "wasmer", @@ -5313,9 +5313,9 @@ dependencies = [ "tracing-wasm", "typetag", "urlencoding", - "virtfs", - "virtnet", "virtnet-native", + "virtual-fs", + "virtual-net", "wai-bindgen-wasmer", "waker-fn", "wasm-bindgen", @@ -5390,7 +5390,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "virtfs", + "virtual-fs", "wasmer", "wasmer-wasix", "wast 38.0.1", diff --git a/lib/c-api/Cargo.toml b/lib/c-api/Cargo.toml index 83f1c67d786..14c03c2ef25 100644 --- a/lib/c-api/Cargo.toml +++ b/lib/c-api/Cargo.toml @@ -31,7 +31,7 @@ wasmer-compiler = { version = "=3.2.0-alpha.1", path = "../compiler" } wasmer-middlewares = { version = "=3.2.0-alpha.1", path = "../middlewares", optional = true } wasmer-wasix = { version = "0.1.0", path = "../wasi", features = ["host-fs", "host-vnet"], optional = true } wasmer-types = { version = "=3.2.0-alpha.1", path = "../types" } -virtfs = { version = "0.1.0", path = "../vfs", optional = true, default-features = false, features = ["static-fs"] } +virtual-fs = { version = "0.1.0", path = "../vfs", optional = true, default-features = false, features = ["static-fs"] } webc = { version = "5.0.0-rc.5", optional = true } enumset = "1.0.2" cfg-if = "1.0" @@ -92,7 +92,7 @@ wasmer-artifact-load = ["wasmer-compiler/wasmer-artifact-load"] wasmer-artifact-create = ["wasmer-compiler/wasmer-artifact-create"] static-artifact-load = ["wasmer-compiler/static-artifact-load"] static-artifact-create = ["wasmer-compiler/static-artifact-create"] -webc_runner = ["wasmer-wasix/webc_runner", "virtfs", "webc"] +webc_runner = ["wasmer-wasix/webc_runner", "virtual-fs", "webc"] # Deprecated features. jit = ["compiler"] diff --git a/lib/c-api/src/wasm_c_api/wasi/mod.rs b/lib/c-api/src/wasm_c_api/wasi/mod.rs index f0c7389d629..d37a7bd2c70 100644 --- a/lib/c-api/src/wasm_c_api/wasi/mod.rs +++ b/lib/c-api/src/wasm_c_api/wasi/mod.rs @@ -19,7 +19,7 @@ use std::slice; #[cfg(feature = "webc_runner")] use wasmer_api::{AsStoreMut, Imports, Module}; use wasmer_wasix::{ - default_fs_backing, get_wasi_version, virtfs::AsyncReadExt, Pipe, VirtualTaskManager, WasiEnv, + default_fs_backing, get_wasi_version, virtual_fs::AsyncReadExt, Pipe, VirtualTaskManager, WasiEnv, WasiEnvBuilder, WasiFile, WasiFunctionEnv, WasiVersion, }; @@ -248,7 +248,7 @@ fn prepare_webc_env( len: usize, package_name: &str, ) -> Option<(WasiFunctionEnv, Imports)> { - use virtfs::static_fs::StaticFileSystem; + use virtual_fs::static_fs::StaticFileSystem; use webc::v1::{FsEntryType, WebC}; let slice = unsafe { std::slice::from_raw_parts(bytes, len) }; diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 0c616ca6d5f..a50aaee49b2 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -40,8 +40,8 @@ wasmer-cache = { version = "=3.2.0-alpha.1", path = "../cache", optional = true wasmer-types = { version = "=3.2.0-alpha.1", path = "../types", features = ["enable-serde"] } wasmer-registry = { version = "=4.0.0", path = "../registry" } wasmer-object = { version = "=3.2.0-alpha.1", path = "../object", optional = true } -virtfs = { version = "0.1.0", path = "../vfs", default-features = false, features = ["host-fs"] } -virtnet = { version = "0.1.0", path = "../vnet" } +virtual-fs = { version = "0.1.0", path = "../vfs", default-features = false, features = ["host-fs"] } +virtual-net = { version = "0.1.0", path = "../vnet" } wasmer-wasm-interface = { version = "3.2.0-alpha.1", path = "../wasm-interface" } wasmparser = "0.51.4" atty = "0.2" diff --git a/lib/cli/src/commands/run/wasi.rs b/lib/cli/src/commands/run/wasi.rs index 2b64de47507..77a2ef6d794 100644 --- a/lib/cli/src/commands/run/wasi.rs +++ b/lib/cli/src/commands/run/wasi.rs @@ -4,8 +4,8 @@ use std::collections::HashMap; use std::path::PathBuf; use std::sync::Arc; use std::{collections::BTreeSet, path::Path}; -use virtfs::FileSystem; -use virtfs::{DeviceFile, PassthruFileSystem, RootFileSystemBuilder}; +use virtual_fs::FileSystem; +use virtual_fs::{DeviceFile, PassthruFileSystem, RootFileSystemBuilder}; use wasmer::{AsStoreMut, Instance, Module, RuntimeError, Value}; use wasmer_wasix::types::__WASI_STDIN_FILENO; use wasmer_wasix::{ @@ -123,7 +123,7 @@ impl Wasi { if self.networking { rt.set_networking_implementation(virtnet_native::LocalNetworking::default()); } else { - rt.set_networking_implementation(virtnet::UnsupportedVirtualNetworking::default()); + rt.set_networking_implementation(virtual_net::UnsupportedVirtualNetworking::default()); } let engine = store.as_store_mut().engine().clone(); diff --git a/lib/sys-utils/tests/fd_mmap_memory.rs b/lib/sys-utils/tests/fd_mmap_memory.rs index f2584a43730..b502b0cd1dc 100644 --- a/lib/sys-utils/tests/fd_mmap_memory.rs +++ b/lib/sys-utils/tests/fd_mmap_memory.rs @@ -4,7 +4,7 @@ // use wasmer::{BaseTunables, Engine, Module, Store, Tunables}; // use wasmer_vm::VMMemory; // use wasmer_wasix::{ -// bin_factory::spawn_exec_module, virtfs::host_fs::File, BusSpawnedProcessJoin, +// bin_factory::spawn_exec_module, virtual_fs::host_fs::File, BusSpawnedProcessJoin, // PluggableRuntimeImplementation, WasiControlPlane, WasiEnv, WasiRuntime, // WasiState, // }; diff --git a/lib/vfs/Cargo.toml b/lib/vfs/Cargo.toml index b9f5fe7b285..3e67c84286a 100644 --- a/lib/vfs/Cargo.toml +++ b/lib/vfs/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "virtfs" +name = "virtual-fs" version = "0.1.0" description = "Wasmer Virtual FileSystem" authors = ["Wasmer Engineering Team "] diff --git a/lib/vfs/src/union_fs.rs b/lib/vfs/src/union_fs.rs index d9d6d18af8b..8150c82ca67 100644 --- a/lib/vfs/src/union_fs.rs +++ b/lib/vfs/src/union_fs.rs @@ -311,7 +311,7 @@ impl FileSystem for UnionFileSystem { Err(err) => { // This fixes a bug when attempting to create the directory /usr when it does not exist // on the x86 version of memfs - // TODO: patch virtfs and remove + // TODO: patch virtual-fs and remove if let FsError::NotAFile = &err { ret_error = FsError::EntryNotFound; } else { @@ -335,7 +335,7 @@ impl FileSystem for UnionFileSystem { Err(err) => { // This fixes a bug when attempting to create the directory /usr when it does not exist // on the x86 version of memfs - // TODO: patch virtfs and remove + // TODO: patch virtual-fs and remove if let FsError::NotAFile = &err { ret_error = FsError::EntryNotFound; } else { diff --git a/lib/vnet/Cargo.toml b/lib/vnet/Cargo.toml index 458e82e1980..09c9fb45ba0 100644 --- a/lib/vnet/Cargo.toml +++ b/lib/vnet/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "virtnet" +name = "virtual-net" version = "0.1.0" description = "Wasmer Virtual Networking" authors = ["Wasmer Engineering Team "] diff --git a/lib/wasi-local-networking/Cargo.toml b/lib/wasi-local-networking/Cargo.toml index 10864a05a2e..83ebbf6756a 100644 --- a/lib/wasi-local-networking/Cargo.toml +++ b/lib/wasi-local-networking/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" maintenance = { status = "experimental" } [dependencies] -virtnet = { version = "0.1.0", path = "../vnet" } +virtual-net = { version = "0.1.0", path = "../vnet" } tracing = "0.1" bytes = "1.1" tokio = { version = "1", features = [ "sync", "macros", "io-util", "signal" ], default_features = false } diff --git a/lib/wasi-local-networking/src/lib.rs b/lib/wasi-local-networking/src/lib.rs index 58b3fd6bc91..f201e067021 100644 --- a/lib/wasi-local-networking/src/lib.rs +++ b/lib/wasi-local-networking/src/lib.rs @@ -11,7 +11,7 @@ use tokio::sync::mpsc; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; #[allow(unused_imports)] -use virtnet::{ +use virtual_net::{ IpCidr, IpRoute, NetworkError, Result, SocketStatus, StreamSecurity, VirtualConnectedSocket, VirtualConnectionlessSocket, VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, VirtualSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index b5258552863..f6567e9b93e 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -19,8 +19,8 @@ wasmer-wasix-types = { path = "../wasi-types", version = "0.1.0" } wasmer-types = { path = "../types", version = "=3.2.0-alpha.1", default-features = false } wasmer = { path = "../api", version = "=3.2.0-alpha.1", default-features = false, features = ["wat", "js-serializable-module"] } wasmer-vm = { path = "../vm", version = "=3.2.0-alpha.1", optional = true } -virtfs = { path = "../vfs", version = "0.1.0", default-features = false, features = ["webc-fs"] } -virtnet = { path = "../vnet", version = "0.1.0", default-features = false } +virtual-fs = { path = "../vfs", version = "0.1.0", default-features = false, features = ["webc-fs"] } +virtual-net = { path = "../vnet", version = "0.1.0", default-features = false } virtnet-native = { path = "../wasi-local-networking", version = "0.1.0", default-features = false, optional = true } wasmer-emscripten = { path = "../emscripten", version = "=3.2.0-alpha.1", optional = true } typetag = { version = "0.1", optional = true } @@ -108,14 +108,14 @@ sys-thread = ["tokio/rt", "tokio/time", "tokio/rt-multi-thread"] compiler = [ "wasmer/compiler", "wasmer-compiler"] -js = ["wasmer/js", "virtfs/no-time", "getrandom/js", "chrono", "wasmer-wasix-types/js"] +js = ["wasmer/js", "virtual-fs/no-time", "getrandom/js", "chrono", "wasmer-wasix-types/js"] js-default = ["js", "wasmer/js-default"] test-js = ["js", "wasmer/js-default", "wasmer/wat"] host-vnet = [ "virtnet-native" ] host-threads = [] host-reqwest = ["reqwest"] -host-fs = ["virtfs/host-fs"] +host-fs = ["virtual-fs/host-fs"] host-termios = ["termios", "term_size"] logging = ["tracing/log"] @@ -125,7 +125,7 @@ disable-all-logging = [ ] enable-serde = [ "typetag", - "virtfs/enable-serde", + "virtual-fs/enable-serde", "wasmer-wasix-types/enable-serde", ] diff --git a/lib/wasi/src/bin_factory/binary_package.rs b/lib/wasi/src/bin_factory/binary_package.rs index c7f9adf9be8..ece724168f7 100644 --- a/lib/wasi/src/bin_factory/binary_package.rs +++ b/lib/wasi/src/bin_factory/binary_package.rs @@ -6,7 +6,7 @@ use std::{ }; use derivative::*; -use virtfs::{FileSystem, TmpFileSystem}; +use virtual_fs::{FileSystem, TmpFileSystem}; use wasmer_wasix_types::wasi::Snapshot0Clockid; use super::hash_of_binary; diff --git a/lib/wasi/src/bin_factory/mod.rs b/lib/wasi/src/bin_factory/mod.rs index 72bcad224dc..8f697fc10cd 100644 --- a/lib/wasi/src/bin_factory/mod.rs +++ b/lib/wasi/src/bin_factory/mod.rs @@ -4,7 +4,7 @@ use std::{ sync::{Arc, RwLock}, }; -use virtfs::{AsyncReadExt, FileSystem}; +use virtual_fs::{AsyncReadExt, FileSystem}; mod binary_package; mod exec; diff --git a/lib/wasi/src/fs/fd.rs b/lib/wasi/src/fs/fd.rs index 7dea933910e..94ea01eac8a 100644 --- a/lib/wasi/src/fs/fd.rs +++ b/lib/wasi/src/fs/fd.rs @@ -7,7 +7,7 @@ use std::{ #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; -use virtfs::{Pipe, VirtualFile}; +use virtual_fs::{Pipe, VirtualFile}; use wasmer_wasix_types::wasi::{Fd as WasiFd, Fdflags, Filestat, Rights}; use crate::net::socket::InodeSocket; diff --git a/lib/wasi/src/fs/inode_guard.rs b/lib/wasi/src/fs/inode_guard.rs index 52fd5129842..100843ac793 100644 --- a/lib/wasi/src/fs/inode_guard.rs +++ b/lib/wasi/src/fs/inode_guard.rs @@ -9,8 +9,8 @@ use std::{ }; use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite}; -use virtfs::{FsError, VirtualFile}; -use virtnet::NetworkError; +use virtual_fs::{FsError, VirtualFile}; +use virtual_net::NetworkError; use wasmer_wasix_types::{ types::Eventtype, wasi, diff --git a/lib/wasi/src/fs/mod.rs b/lib/wasi/src/fs/mod.rs index 330433d587e..5c081ce93c4 100644 --- a/lib/wasi/src/fs/mod.rs +++ b/lib/wasi/src/fs/mod.rs @@ -18,7 +18,7 @@ use crate::state::{Stderr, Stdin, Stdout}; use serde_derive::{Deserialize, Serialize}; use tokio::io::AsyncWriteExt; use tracing::{debug, trace}; -use virtfs::{FileSystem, FsError, OpenOptions, VirtualFile}; +use virtual_fs::{FileSystem, FsError, OpenOptions, VirtualFile}; use wasmer_wasix_types::{ types::{__WASI_STDERR_FILENO, __WASI_STDIN_FILENO, __WASI_STDOUT_FILENO}, wasi::{ @@ -261,48 +261,48 @@ impl Default for WasiInodes { #[derive(Debug, Clone)] pub enum WasiFsRoot { - Sandbox(Arc), + Sandbox(Arc), Backing(Arc>), } impl FileSystem for WasiFsRoot { - fn read_dir(&self, path: &Path) -> virtfs::Result { + fn read_dir(&self, path: &Path) -> virtual_fs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.read_dir(path), WasiFsRoot::Backing(fs) => fs.read_dir(path), } } - fn create_dir(&self, path: &Path) -> virtfs::Result<()> { + fn create_dir(&self, path: &Path) -> virtual_fs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.create_dir(path), WasiFsRoot::Backing(fs) => fs.create_dir(path), } } - fn remove_dir(&self, path: &Path) -> virtfs::Result<()> { + fn remove_dir(&self, path: &Path) -> virtual_fs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.remove_dir(path), WasiFsRoot::Backing(fs) => fs.remove_dir(path), } } - fn rename(&self, from: &Path, to: &Path) -> virtfs::Result<()> { + fn rename(&self, from: &Path, to: &Path) -> virtual_fs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.rename(from, to), WasiFsRoot::Backing(fs) => fs.rename(from, to), } } - fn metadata(&self, path: &Path) -> virtfs::Result { + fn metadata(&self, path: &Path) -> virtual_fs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.metadata(path), WasiFsRoot::Backing(fs) => fs.metadata(path), } } - fn symlink_metadata(&self, path: &Path) -> virtfs::Result { + fn symlink_metadata(&self, path: &Path) -> virtual_fs::Result { match self { WasiFsRoot::Sandbox(fs) => fs.symlink_metadata(path), WasiFsRoot::Backing(fs) => fs.symlink_metadata(path), } } - fn remove_file(&self, path: &Path) -> virtfs::Result<()> { + fn remove_file(&self, path: &Path) -> virtual_fs::Result<()> { match self { WasiFsRoot::Sandbox(fs) => fs.remove_file(path), WasiFsRoot::Backing(fs) => fs.remove_file(path), @@ -1763,12 +1763,12 @@ impl std::fmt::Debug for WasiFs { } /// Returns the default filesystem backing -pub fn default_fs_backing() -> Box { +pub fn default_fs_backing() -> Box { cfg_if::cfg_if! { if #[cfg(feature = "host-fs")] { - Box::new(virtfs::host_fs::FileSystem::default()) + Box::new(virtual_fs::host_fs::FileSystem::default()) } else if #[cfg(not(feature = "host-fs"))] { - Box::new(virtfs::mem_fs::FileSystem::default()) + Box::new(virtual_fs::mem_fs::FileSystem::default()) } else { Box::new(FallbackFileSystem::default()) } @@ -1785,7 +1785,7 @@ impl FallbackFileSystem { } impl FileSystem for FallbackFileSystem { - fn read_dir(&self, _path: &Path) -> Result { + fn read_dir(&self, _path: &Path) -> Result { Self::fail(); } fn create_dir(&self, _path: &Path) -> Result<(), FsError> { @@ -1797,21 +1797,21 @@ impl FileSystem for FallbackFileSystem { fn rename(&self, _from: &Path, _to: &Path) -> Result<(), FsError> { Self::fail(); } - fn metadata(&self, _path: &Path) -> Result { + fn metadata(&self, _path: &Path) -> Result { Self::fail(); } - fn symlink_metadata(&self, _path: &Path) -> Result { + fn symlink_metadata(&self, _path: &Path) -> Result { Self::fail(); } fn remove_file(&self, _path: &Path) -> Result<(), FsError> { Self::fail(); } - fn new_open_options(&self) -> virtfs::OpenOptions { + fn new_open_options(&self) -> virtual_fs::OpenOptions { Self::fail(); } } -pub fn virtual_file_type_to_wasi_file_type(file_type: virtfs::FileType) -> Filetype { +pub fn virtual_file_type_to_wasi_file_type(file_type: virtual_fs::FileType) -> Filetype { // TODO: handle other file types if file_type.is_dir() { Filetype::Directory diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 900ce649f8f..5b3c26b8dbf 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -72,14 +72,14 @@ use wasmer::{ MemorySize, RuntimeError, }; -pub use virtfs; -#[deprecated(since = "2.1.0", note = "Please use `virtfs::FsError`")] -pub use virtfs::FsError as WasiFsError; -#[deprecated(since = "2.1.0", note = "Please use `virtfs::VirtualFile`")] -pub use virtfs::VirtualFile as WasiFile; -pub use virtfs::{DuplexPipe, FsError, Pipe, VirtualFile, WasiBidirectionalSharedPipePair}; -pub use virtnet; -pub use virtnet::{UnsupportedVirtualNetworking, VirtualNetworking}; +pub use virtual_fs; +#[deprecated(since = "2.1.0", note = "Please use `virtual_fs::FsError`")] +pub use virtual_fs::FsError as WasiFsError; +#[deprecated(since = "2.1.0", note = "Please use `virtual_fs::VirtualFile`")] +pub use virtual_fs::VirtualFile as WasiFile; +pub use virtual_fs::{DuplexPipe, FsError, Pipe, VirtualFile, WasiBidirectionalSharedPipePair}; +pub use virtual_net; +pub use virtual_net::{UnsupportedVirtualNetworking, VirtualNetworking}; #[cfg(feature = "host-vnet")] pub use virtnet_native::{ diff --git a/lib/wasi/src/net/mod.rs b/lib/wasi/src/net/mod.rs index 89f1acbce2a..0a1ade30d8b 100644 --- a/lib/wasi/src/net/mod.rs +++ b/lib/wasi/src/net/mod.rs @@ -4,7 +4,7 @@ use std::{ time::Duration, }; -use virtnet::{IpCidr, IpRoute, NetworkError}; +use virtual_net::{IpCidr, IpRoute, NetworkError}; use wasmer::{MemoryView, WasmPtr}; use wasmer_types::MemorySize; use wasmer_wasix_types::{ diff --git a/lib/wasi/src/net/socket.rs b/lib/wasi/src/net/socket.rs index 942ac16b090..ba2787ac396 100644 --- a/lib/wasi/src/net/socket.rs +++ b/lib/wasi/src/net/socket.rs @@ -10,7 +10,7 @@ use std::{ #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; -use virtnet::{ +use virtual_net::{ VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, }; @@ -1213,7 +1213,7 @@ impl InodeSocketProtected { pub fn poll_read_ready( &mut self, cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { + ) -> std::task::Poll> { match &mut self.kind { InodeSocketKind::TcpListener { socket, .. } => socket.poll_accept_ready(cx), InodeSocketKind::TcpStream { socket, .. } => socket.poll_read_ready(cx), @@ -1221,7 +1221,7 @@ impl InodeSocketProtected { InodeSocketKind::Raw(socket) => socket.poll_read_ready(cx), InodeSocketKind::Icmp(socket) => socket.poll_read_ready(cx), InodeSocketKind::PreSocket { .. } => { - std::task::Poll::Ready(Err(virtnet::NetworkError::IOError)) + std::task::Poll::Ready(Err(virtual_net::NetworkError::IOError)) } } } @@ -1229,7 +1229,7 @@ impl InodeSocketProtected { pub fn poll_write_ready( &mut self, cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { + ) -> std::task::Poll> { match &mut self.kind { InodeSocketKind::TcpListener { .. } => std::task::Poll::Pending, InodeSocketKind::TcpStream { socket, .. } => socket.poll_write_ready(cx), @@ -1237,7 +1237,7 @@ impl InodeSocketProtected { InodeSocketKind::Raw(socket) => socket.poll_write_ready(cx), InodeSocketKind::Icmp(socket) => socket.poll_write_ready(cx), InodeSocketKind::PreSocket { .. } => { - std::task::Poll::Ready(Err(virtnet::NetworkError::IOError)) + std::task::Poll::Ready(Err(virtual_net::NetworkError::IOError)) } } } diff --git a/lib/wasi/src/os/console/mod.rs b/lib/wasi/src/os/console/mod.rs index 160a764d311..27ce2e913b0 100644 --- a/lib/wasi/src/os/console/mod.rs +++ b/lib/wasi/src/os/console/mod.rs @@ -16,7 +16,7 @@ use linked_hash_set::LinkedHashSet; use tokio::sync::{mpsc, RwLock}; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; -use virtfs::{ +use virtual_fs::{ ArcBoxFile, ArcFile, AsyncWriteExt, CombineFile, DeviceFile, DuplexPipe, FileSystem, Pipe, PipeRx, PipeTx, RootFileSystemBuilder, VirtualFile, }; @@ -209,7 +209,7 @@ impl Console { } else { let mut stderr = self.stderr.clone(); tasks.block_on(async { - virtfs::AsyncWriteExt::write_all( + virtual_fs::AsyncWriteExt::write_all( &mut stderr, format!("package not found [{}]\r\n", webc).as_bytes(), ) @@ -229,7 +229,7 @@ impl Console { if let Err(err) = env.uses(self.uses.clone()) { let mut stderr = self.stderr.clone(); tasks.block_on(async { - virtfs::AsyncWriteExt::write_all(&mut stderr, format!("{}\r\n", err).as_bytes()) + virtual_fs::AsyncWriteExt::write_all(&mut stderr, format!("{}\r\n", err).as_bytes()) .await .ok(); }); @@ -265,7 +265,7 @@ impl Console { data.insert_str(0, ConsoleConst::TERM_NO_WRAPAROUND); let mut stderr = self.stderr.clone(); - virtfs::AsyncWriteExt::write_all(&mut stderr, data.as_str().as_bytes()) + virtual_fs::AsyncWriteExt::write_all(&mut stderr, data.as_str().as_bytes()) .await .ok(); } diff --git a/lib/wasi/src/os/tty/mod.rs b/lib/wasi/src/os/tty/mod.rs index 2492040fef0..f54bc5176b0 100644 --- a/lib/wasi/src/os/tty/mod.rs +++ b/lib/wasi/src/os/tty/mod.rs @@ -5,7 +5,7 @@ use std::{ use derivative::*; use futures::future::BoxFuture; -use virtfs::{AsyncWriteExt, NullFile, VirtualFile}; +use virtual_fs::{AsyncWriteExt, NullFile, VirtualFile}; use wasmer_wasix_types::wasi::{Signal, Snapshot0Clockid}; use crate::syscalls::platform_clock_time_get; diff --git a/lib/wasi/src/runners/container.rs b/lib/wasi/src/runners/container.rs index befad496213..66de75a1bca 100644 --- a/lib/wasi/src/runners/container.rs +++ b/lib/wasi/src/runners/container.rs @@ -1,7 +1,7 @@ use std::{path::PathBuf, sync::Arc}; use bytes::Bytes; -use virtfs::{webc_fs::WebcFileSystem, FileSystem}; +use virtual_fs::{webc_fs::WebcFileSystem, FileSystem}; use webc::{ metadata::Manifest, v1::{ParseOptions, WebC, WebCMmap, WebCOwned}, diff --git a/lib/wasi/src/runners/wcgi/handler.rs b/lib/wasi/src/runners/wcgi/handler.rs index d5cd7772b5d..9b546a14990 100644 --- a/lib/wasi/src/runners/wcgi/handler.rs +++ b/lib/wasi/src/runners/wcgi/handler.rs @@ -15,7 +15,7 @@ use tokio::{ io::{AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt}, runtime::Handle, }; -use virtfs::{FileSystem, PassthruFileSystem, RootFileSystemBuilder, TmpFileSystem}; +use virtual_fs::{FileSystem, PassthruFileSystem, RootFileSystemBuilder, TmpFileSystem}; use wasmer::Module; use wcgi_host::CgiDialect; diff --git a/lib/wasi/src/runners/wcgi/runner.rs b/lib/wasi/src/runners/wcgi/runner.rs index 081b1fda7fd..14e67859a3a 100644 --- a/lib/wasi/src/runners/wcgi/runner.rs +++ b/lib/wasi/src/runners/wcgi/runner.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, convert::Infallible, net::SocketAddr, path::Path use anyhow::{Context, Error}; use futures::future::AbortHandle; -use virtfs::FileSystem; +use virtual_fs::FileSystem; use wasmer::{Engine, Module, Store}; use wcgi_host::CgiDialect; use webc::metadata::{ diff --git a/lib/wasi/src/runtime/mod.rs b/lib/wasi/src/runtime/mod.rs index c2b04c6c8b0..02a9a06388e 100644 --- a/lib/wasi/src/runtime/mod.rs +++ b/lib/wasi/src/runtime/mod.rs @@ -4,7 +4,7 @@ pub use self::task_manager::{SpawnType, SpawnedMemory, VirtualTaskManager}; use std::{fmt, sync::Arc}; -use virtnet::{DynVirtualNetworking, VirtualNetworking}; +use virtual_net::{DynVirtualNetworking, VirtualNetworking}; use crate::{http::DynHttpClient, os::TtyBridge}; @@ -85,7 +85,7 @@ impl PluggableRuntimeImplementation { if #[cfg(feature = "host-vnet")] { let networking = Arc::new(virtnet_native::LocalNetworking::default()); } else { - let networking = Arc::new(virtnet::UnsupportedVirtualNetworking::default()); + let networking = Arc::new(virtual_net::UnsupportedVirtualNetworking::default()); } } cfg_if::cfg_if! { diff --git a/lib/wasi/src/state/builder.rs b/lib/wasi/src/state/builder.rs index d48862f9bd7..c761d9cb323 100644 --- a/lib/wasi/src/state/builder.rs +++ b/lib/wasi/src/state/builder.rs @@ -8,7 +8,7 @@ use std::{ use rand::Rng; use thiserror::Error; -use virtfs::{ArcFile, FsError, TmpFileSystem, VirtualFile}; +use virtual_fs::{ArcFile, FsError, TmpFileSystem, VirtualFile}; use wasmer::{AsStoreMut, Instance, Module}; use crate::{ @@ -480,19 +480,19 @@ impl WasiEnvBuilder { /// Sets the FileSystem to be used with this WASI instance. /// - /// This is usually used in case a custom `virtfs::FileSystem` is needed. - pub fn fs(mut self, fs: Box) -> Self { + /// This is usually used in case a custom `virtual_fs::FileSystem` is needed. + pub fn fs(mut self, fs: Box) -> Self { self.set_fs(fs); self } - pub fn set_fs(&mut self, fs: Box) { + pub fn set_fs(&mut self, fs: Box) { self.fs = Some(WasiFsRoot::Backing(Arc::new(fs))); } /// Sets a new sandbox FileSystem to be used with this WASI instance. /// - /// This is usually used in case a custom `virtfs::FileSystem` is needed. + /// This is usually used in case a custom `virtual_fs::FileSystem` is needed. pub fn sandbox_fs(mut self, fs: TmpFileSystem) -> Self { self.fs = Some(WasiFsRoot::Sandbox(Arc::new(fs))); self diff --git a/lib/wasi/src/state/env.rs b/lib/wasi/src/state/env.rs index ace93a1955f..ce108df9f86 100644 --- a/lib/wasi/src/state/env.rs +++ b/lib/wasi/src/state/env.rs @@ -3,8 +3,8 @@ use std::{collections::HashMap, ops::Deref, path::PathBuf, sync::Arc, time::Dura use derivative::Derivative; use rand::Rng; use tracing::{trace, warn}; -use virtfs::{FsError, VirtualFile}; -use virtnet::DynVirtualNetworking; +use virtual_fs::{FsError, VirtualFile}; +use virtual_net::DynVirtualNetworking; #[cfg(feature = "sys")] use wasmer::NativeEngineExt; use wasmer::{ @@ -766,7 +766,7 @@ impl WasiEnv { use std::{borrow::Cow, collections::VecDeque}; #[allow(unused_imports)] - use virtfs::FileSystem; + use virtual_fs::FileSystem; let mut already: HashMap> = HashMap::new(); @@ -859,7 +859,7 @@ impl WasiEnv { use std::path::Path; #[allow(unused_imports)] - use virtfs::FileSystem; + use virtual_fs::FileSystem; #[cfg(feature = "sys")] for (command, target) in map_commands.iter() { diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index 23dd529d7ed..20c4293a30d 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -32,7 +32,7 @@ use std::{ use derivative::Derivative; #[cfg(feature = "enable-serde")] use serde::{Deserialize, Serialize}; -use virtfs::{FileOpener, FileSystem, FsError, OpenOptions, VirtualFile}; +use virtual_fs::{FileOpener, FileSystem, FsError, OpenOptions, VirtualFile}; use wasmer::Store; use wasmer_wasix_types::wasi::{Errno, Fd as WasiFd, Rights, Snapshot0Clockid}; @@ -61,8 +61,8 @@ impl FileOpener for WasiStateOpener { fn open( &self, path: &Path, - conf: &virtfs::OpenOptionsConfig, - ) -> virtfs::Result> { + conf: &virtual_fs::OpenOptionsConfig, + ) -> virtual_fs::Result> { let mut new_options = self.root_fs.new_open_options(); new_options.options(conf.clone()); new_options.open(path) @@ -177,7 +177,7 @@ impl WasiState { // Implementations of direct to FS calls so that we can easily change their implementation impl WasiState { - pub(crate) fn fs_read_dir>(&self, path: P) -> Result { + pub(crate) fn fs_read_dir>(&self, path: P) -> Result { self.fs .root_fs .read_dir(path.as_ref()) diff --git a/lib/wasi/src/state/types.rs b/lib/wasi/src/state/types.rs index 3af247a9074..4b15fc6285f 100644 --- a/lib/wasi/src/state/types.rs +++ b/lib/wasi/src/state/types.rs @@ -11,9 +11,9 @@ use crate::VirtualBusError; cfg_if! { if #[cfg(feature = "host-fs")] { - pub use virtfs::host_fs::{Stderr, Stdin, Stdout}; + pub use virtual_fs::host_fs::{Stderr, Stdin, Stdout}; } else { - pub use virtfs::mem_fs::{Stderr, Stdin, Stdout}; + pub use virtual_fs::mem_fs::{Stderr, Stdin, Stdout}; } } diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index ccb55b50d35..08622ff8449 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -63,10 +63,10 @@ pub use unix::*; #[cfg(any(target_family = "wasm"))] pub use wasm::*; -pub(crate) use virtfs::{ +pub(crate) use virtual_fs::{ AsyncSeekExt, AsyncWriteExt, DuplexPipe, FileSystem, FsError, VirtualFile, }; -pub(crate) use virtnet::StreamSecurity; +pub(crate) use virtual_net::StreamSecurity; pub(crate) use wasmer::{ AsStoreMut, AsStoreRef, Extern, Function, FunctionEnv, FunctionEnvMut, Global, Instance, Memory, Memory32, Memory64, MemoryAccessError, MemoryError, MemorySize, MemoryView, Module, diff --git a/lib/wasi/src/syscalls/wasi/fd_read.rs b/lib/wasi/src/syscalls/wasi/fd_read.rs index 0b3b73367f7..7d7ad723ad2 100644 --- a/lib/wasi/src/syscalls/wasi/fd_read.rs +++ b/lib/wasi/src/syscalls/wasi/fd_read.rs @@ -1,6 +1,6 @@ use std::{collections::VecDeque, task::Waker}; -use virtfs::{AsyncReadExt, ReadBuf}; +use virtual_fs::{AsyncReadExt, ReadBuf}; use super::*; use crate::{fs::NotificationInner, syscalls::*}; @@ -280,7 +280,7 @@ fn fd_read_internal( .map_err(mem_error_to_wasi)?; total_read += - virtfs::AsyncReadExt::read(&mut pipe, buf.as_mut()).await?; + virtual_fs::AsyncReadExt::read(&mut pipe, buf.as_mut()).await?; } Ok(total_read) } diff --git a/lib/wasi/src/syscalls/wasi/path_open.rs b/lib/wasi/src/syscalls/wasi/path_open.rs index 67414ecb336..54ceb01e0d3 100644 --- a/lib/wasi/src/syscalls/wasi/path_open.rs +++ b/lib/wasi/src/syscalls/wasi/path_open.rs @@ -109,7 +109,7 @@ pub fn path_open( (false, false, false) }; - virtfs::OpenOptionsConfig { + virtual_fs::OpenOptionsConfig { read: fs_rights_base.contains(Rights::FD_READ), write: write_permission, create_new: create_permission && o_flags.contains(Oflags::EXCL), @@ -118,7 +118,7 @@ pub fn path_open( truncate: truncate_permission, } } - Err(_) => virtfs::OpenOptionsConfig { + Err(_) => virtual_fs::OpenOptionsConfig { append: fs_flags.contains(Fdflags::APPEND), write: fs_rights_base.contains(Rights::FD_WRITE), read: fs_rights_base.contains(Rights::FD_READ), @@ -128,7 +128,7 @@ pub fn path_open( }, }; - let parent_rights = virtfs::OpenOptionsConfig { + let parent_rights = virtual_fs::OpenOptionsConfig { read: working_dir.rights.contains(Rights::FD_READ), write: working_dir.rights.contains(Rights::FD_WRITE), // The parent is a directory, which is why these options diff --git a/lib/wasi/src/syscalls/wasix/fd_pipe.rs b/lib/wasi/src/syscalls/wasix/fd_pipe.rs index fc0cc3650ba..99db209d1cb 100644 --- a/lib/wasi/src/syscalls/wasix/fd_pipe.rs +++ b/lib/wasi/src/syscalls/wasix/fd_pipe.rs @@ -1,4 +1,4 @@ -use virtfs::Pipe; +use virtual_fs::Pipe; use super::*; use crate::syscalls::*; diff --git a/lib/wasi/src/syscalls/wasix/proc_spawn.rs b/lib/wasi/src/syscalls/wasix/proc_spawn.rs index 65e2334d3de..9fb4de0700f 100644 --- a/lib/wasi/src/syscalls/wasix/proc_spawn.rs +++ b/lib/wasi/src/syscalls/wasix/proc_spawn.rs @@ -1,4 +1,4 @@ -use virtfs::Pipe; +use virtual_fs::Pipe; use super::*; use crate::syscalls::*; diff --git a/lib/wasi/src/syscalls/wasix/sock_send_file.rs b/lib/wasi/src/syscalls/wasix/sock_send_file.rs index 90fceca2015..49e7d149ffa 100644 --- a/lib/wasi/src/syscalls/wasix/sock_send_file.rs +++ b/lib/wasi/src/syscalls/wasix/sock_send_file.rs @@ -1,4 +1,4 @@ -use virtfs::AsyncReadExt; +use virtual_fs::AsyncReadExt; use super::*; use crate::{syscalls::*, WasiInodes}; @@ -130,7 +130,7 @@ pub fn sock_send_file( // TODO: optimize with MaybeUninit let mut buf = vec![0u8; sub_count as usize]; let amt = - virtfs::AsyncReadExt::read(pipe, &mut buf[..]) + virtual_fs::AsyncReadExt::read(pipe, &mut buf[..]) .await .map_err(map_io_err)?; buf.truncate(amt); diff --git a/lib/wasi/src/wapm/mod.rs b/lib/wasi/src/wapm/mod.rs index 374e520677a..3be033b89f3 100644 --- a/lib/wasi/src/wapm/mod.rs +++ b/lib/wasi/src/wapm/mod.rs @@ -4,7 +4,7 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; -use virtfs::FileSystem; +use virtual_fs::FileSystem; use tracing::*; #[allow(unused_imports)] @@ -364,7 +364,7 @@ where } // Add the file system from the webc - let webc_fs = virtfs::webc_fs::WebcFileSystem::init_all(ownership.clone()); + let webc_fs = virtual_fs::webc_fs::WebcFileSystem::init_all(ownership.clone()); let top_level_dirs = webc_fs.top_level_dirs().clone(); pck.webc_fs = Some(Arc::new(webc_fs)); pck.webc_top_level_dirs = top_level_dirs; diff --git a/lib/wasi/tests/stdio.rs b/lib/wasi/tests/stdio.rs index fe5264857eb..b4a695e72ac 100644 --- a/lib/wasi/tests/stdio.rs +++ b/lib/wasi/tests/stdio.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use virtfs::{AsyncReadExt, AsyncWriteExt}; +use virtual_fs::{AsyncReadExt, AsyncWriteExt}; use wasmer::{Module, Store}; use wasmer_wasix::{Pipe, PluggableRuntimeImplementation, WasiEnv}; diff --git a/tests/lib/wast/Cargo.toml b/tests/lib/wast/Cargo.toml index 8d959c111b3..e10fb5e9b06 100644 --- a/tests/lib/wast/Cargo.toml +++ b/tests/lib/wast/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" anyhow = "1.0" wasmer = { path = "../../../lib/api", version = "=3.2.0-alpha.1", default-features = false } wasmer-wasix = { path = "../../../lib/wasi", version = "0.1.0" } -virtfs = { path = "../../../lib/vfs", version = "0.1.0" } +virtual-fs = { path = "../../../lib/vfs", version = "0.1.0" } wast = "38.0" serde = "1" tempfile = "3.4.0" diff --git a/tests/lib/wast/src/wasi_wast.rs b/tests/lib/wast/src/wasi_wast.rs index a19e696dc26..0ba623d1538 100644 --- a/tests/lib/wast/src/wasi_wast.rs +++ b/tests/lib/wast/src/wasi_wast.rs @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf}; use std::pin::Pin; use std::sync::{mpsc, Arc, Mutex}; use std::task::{Context, Poll}; -use virtfs::{ +use virtual_fs::{ host_fs, mem_fs, passthru_fs, tmp_fs, union_fs, AsyncRead, AsyncSeek, AsyncWrite, AsyncWriteExt, FileSystem, Pipe, ReadBuf, RootFileSystemBuilder, }; @@ -20,22 +20,22 @@ use wast::parser::{self, Parse, ParseBuffer, Parser}; /// The kind of filesystem `WasiTest` is going to use. #[derive(Debug)] pub enum WasiFileSystemKind { - /// Instruct the test runner to use `virtfs::host_fs`. + /// Instruct the test runner to use `virtual_fs::host_fs`. Host, - /// Instruct the test runner to use `virtfs::mem_fs`. + /// Instruct the test runner to use `virtual_fs::mem_fs`. InMemory, - /// Instruct the test runner to use `virtfs::tmp_fs` + /// Instruct the test runner to use `virtual_fs::tmp_fs` Tmp, - /// Instruct the test runner to use `virtfs::passtru_fs` + /// Instruct the test runner to use `virtual_fs::passtru_fs` PassthruMemory, - /// Instruct the test runner to use `virtfs::union_fs` + /// Instruct the test runner to use `virtual_fs::union_fs` UnionHostMemory, - /// Instruct the test runner to use the TempFs returned by `virtfs::builder::RootFileSystemBuilder` + /// Instruct the test runner to use the TempFs returned by `virtual_fs::builder::RootFileSystemBuilder` RootFileSystemBuilder, } @@ -690,7 +690,7 @@ impl AsyncRead for OutputCapturerer { } } -/// When using `virtfs::mem_fs`, we cannot rely on `BASE_TEST_DIR` +/// When using `virtual_fs::mem_fs`, we cannot rely on `BASE_TEST_DIR` /// because the host filesystem cannot be used. Instead, we are /// copying `BASE_TEST_DIR` to the `mem_fs`. fn map_host_fs_to_mem_fs<'a>( From d6981ae3a92dc578e0534a8fd82680a7b78639d6 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 16 Mar 2023 10:56:51 +0100 Subject: [PATCH 3/4] Moved vnet-host functions inside virtual-net --- Cargo.lock | 16 ++------------ Cargo.toml | 1 - lib/c-api/src/wasm_c_api/wasi/mod.rs | 4 ++-- lib/cli/Cargo.toml | 4 ++-- lib/cli/src/commands/run/wasi.rs | 2 +- lib/vnet/Cargo.toml | 7 +++++- .../src/lib.rs => vnet/src/host.rs} | 12 +++++----- lib/vnet/src/lib.rs | 3 +++ lib/wasi-local-networking/Cargo.toml | 22 ------------------- lib/wasi-local-networking/README.md | 1 - lib/wasi/Cargo.toml | 3 +-- lib/wasi/src/lib.rs | 2 +- lib/wasi/src/os/console/mod.rs | 9 +++++--- lib/wasi/src/runtime/mod.rs | 2 +- lib/wasi/src/state/mod.rs | 5 ++++- 15 files changed, 35 insertions(+), 58 deletions(-) rename lib/{wasi-local-networking/src/lib.rs => vnet/src/host.rs} (99%) delete mode 100644 lib/wasi-local-networking/Cargo.toml delete mode 100644 lib/wasi-local-networking/README.md diff --git a/Cargo.lock b/Cargo.lock index b91374579d6..197e3776f47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4369,18 +4369,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "virtnet-native" -version = "0.1.0" -dependencies = [ - "async-trait", - "bytes", - "libc", - "tokio", - "tracing", - "virtual-net", -] - [[package]] name = "virtual-fs" version = "0.1.0" @@ -4410,7 +4398,9 @@ version = "0.1.0" dependencies = [ "async-trait", "bytes", + "libc", "thiserror", + "tokio", "tracing", ] @@ -4938,7 +4928,6 @@ dependencies = [ "tracing-subscriber 0.3.16", "unix_mode", "url", - "virtnet-native", "virtual-fs", "virtual-net", "walkdir", @@ -5313,7 +5302,6 @@ dependencies = [ "tracing-wasm", "typetag", "urlencoding", - "virtnet-native", "virtual-fs", "virtual-net", "wai-bindgen-wasmer", diff --git a/Cargo.toml b/Cargo.toml index a482900c96f..5c753eaf9c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,6 @@ members = [ "lib/wasi", "lib/wasi-types", "lib/wasi-experimental-io-devices", - "lib/wasi-local-networking", "lib/wasix/wasix-http-client", "lib/wasm-interface", "lib/c-api/tests/wasmer-c-api-test-runner", diff --git a/lib/c-api/src/wasm_c_api/wasi/mod.rs b/lib/c-api/src/wasm_c_api/wasi/mod.rs index d37a7bd2c70..360ba0ebda8 100644 --- a/lib/c-api/src/wasm_c_api/wasi/mod.rs +++ b/lib/c-api/src/wasm_c_api/wasi/mod.rs @@ -19,8 +19,8 @@ use std::slice; #[cfg(feature = "webc_runner")] use wasmer_api::{AsStoreMut, Imports, Module}; use wasmer_wasix::{ - default_fs_backing, get_wasi_version, virtual_fs::AsyncReadExt, Pipe, VirtualTaskManager, WasiEnv, - WasiEnvBuilder, WasiFile, WasiFunctionEnv, WasiVersion, + default_fs_backing, get_wasi_version, virtual_fs::AsyncReadExt, Pipe, VirtualTaskManager, + WasiEnv, WasiEnvBuilder, WasiFile, WasiFunctionEnv, WasiVersion, }; #[derive(Debug)] diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index a50aaee49b2..98f31c99863 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -34,7 +34,6 @@ wasmer-emscripten = { version = "=3.2.0-alpha.1", path = "../emscripten", option wasmer-vm = { version = "=3.2.0-alpha.1", path = "../vm" } wasmer-wasix = { version = "0.1.0", path = "../wasi", optional = true } wasmer-wasix-experimental-io-devices = { version = "0.1.0", path = "../wasi-experimental-io-devices", optional = true, features = ["link_external_libs"] } -virtnet-native = { version = "0.1.0", path = "../wasi-local-networking", optional = true } wasmer-wast = { version = "=3.2.0-alpha.1", path = "../../tests/lib/wast", optional = true } wasmer-cache = { version = "=3.2.0-alpha.1", path = "../cache", optional = true } wasmer-types = { version = "=3.2.0-alpha.1", path = "../types", features = ["enable-serde"] } @@ -116,7 +115,8 @@ default = [ cache = ["wasmer-cache"] cache-blake3-pure = ["wasmer-cache/blake3-pure"] wast = ["wasmer-wast"] -wasi = ["wasmer-wasix", "virtnet-native"] +wasi = ["wasmer-wasix", "host-net"] +host-net = [ "virtual-net/host-net" ] emscripten = ["wasmer-emscripten"] wat = ["wasmer/wat"] webc_runner = [ diff --git a/lib/cli/src/commands/run/wasi.rs b/lib/cli/src/commands/run/wasi.rs index 77a2ef6d794..5bd7a31ca3c 100644 --- a/lib/cli/src/commands/run/wasi.rs +++ b/lib/cli/src/commands/run/wasi.rs @@ -121,7 +121,7 @@ impl Wasi { let mut rt = PluggableRuntimeImplementation::default(); if self.networking { - rt.set_networking_implementation(virtnet_native::LocalNetworking::default()); + rt.set_networking_implementation(virtual_net::host::LocalNetworking::default()); } else { rt.set_networking_implementation(virtual_net::UnsupportedVirtualNetworking::default()); } diff --git a/lib/vnet/Cargo.toml b/lib/vnet/Cargo.toml index 09c9fb45ba0..aa25859a700 100644 --- a/lib/vnet/Cargo.toml +++ b/lib/vnet/Cargo.toml @@ -8,6 +8,11 @@ edition = "2018" [dependencies] thiserror = "1" -bytes = "1" +bytes = "1.1" async-trait = { version = "^0.1" } tracing = "0.1" +tokio = { version = "1", features = [ "sync", "macros", "io-util", "signal" ], default_features = false, optional = true } +libc = { version = "0.2.139", optional = true } + +[features] +host-net = [ "tokio", "libc" ] diff --git a/lib/wasi-local-networking/src/lib.rs b/lib/vnet/src/host.rs similarity index 99% rename from lib/wasi-local-networking/src/lib.rs rename to lib/vnet/src/host.rs index f201e067021..0866f1a20f3 100644 --- a/lib/wasi-local-networking/src/lib.rs +++ b/lib/vnet/src/host.rs @@ -1,4 +1,10 @@ #![allow(unused_variables)] +#[allow(unused_imports)] +use crate::{ + IpCidr, IpRoute, NetworkError, Result, SocketStatus, StreamSecurity, VirtualConnectedSocket, + VirtualConnectionlessSocket, VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, + VirtualSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, +}; use std::future::Future; use std::mem::MaybeUninit; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; @@ -10,12 +16,6 @@ use std::time::Duration; use tokio::sync::mpsc; #[allow(unused_imports, dead_code)] use tracing::{debug, error, info, trace, warn}; -#[allow(unused_imports)] -use virtual_net::{ - IpCidr, IpRoute, NetworkError, Result, SocketStatus, StreamSecurity, VirtualConnectedSocket, - VirtualConnectionlessSocket, VirtualIcmpSocket, VirtualNetworking, VirtualRawSocket, - VirtualSocket, VirtualTcpListener, VirtualTcpSocket, VirtualUdpSocket, -}; #[derive(Debug)] pub struct LocalNetworking { diff --git a/lib/vnet/src/lib.rs b/lib/vnet/src/lib.rs index 4ae1cdc72c9..e48bf2384ea 100644 --- a/lib/vnet/src/lib.rs +++ b/lib/vnet/src/lib.rs @@ -529,3 +529,6 @@ pub enum NetworkError { #[error("unknown error found")] UnknownError, } + +#[cfg(feature = "host-net")] +pub mod host; diff --git a/lib/wasi-local-networking/Cargo.toml b/lib/wasi-local-networking/Cargo.toml deleted file mode 100644 index 83ebbf6756a..00000000000 --- a/lib/wasi-local-networking/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "virtnet-native" -version = "0.1.0" -description = "An WASIX extension for local networking" -categories = ["wasm"] -keywords = ["wasm", "webassembly", "types", "wasix"] -authors = ["Wasmer Engineering Team "] -repository = "https://github.com/wasmerio/wasmer" -license = "MIT" -readme = "README.md" -edition = "2018" - -[badges] -maintenance = { status = "experimental" } - -[dependencies] -virtual-net = { version = "0.1.0", path = "../vnet" } -tracing = "0.1" -bytes = "1.1" -tokio = { version = "1", features = [ "sync", "macros", "io-util", "signal" ], default_features = false } -async-trait = { version = "^0.1" } -libc = "0.2.139" diff --git a/lib/wasi-local-networking/README.md b/lib/wasi-local-networking/README.md deleted file mode 100644 index 52a966a2046..00000000000 --- a/lib/wasi-local-networking/README.md +++ /dev/null @@ -1 +0,0 @@ -This is experimental extension of WASIX for networking. diff --git a/lib/wasi/Cargo.toml b/lib/wasi/Cargo.toml index f6567e9b93e..f791f24481c 100644 --- a/lib/wasi/Cargo.toml +++ b/lib/wasi/Cargo.toml @@ -21,7 +21,6 @@ wasmer = { path = "../api", version = "=3.2.0-alpha.1", default-features = false wasmer-vm = { path = "../vm", version = "=3.2.0-alpha.1", optional = true } virtual-fs = { path = "../vfs", version = "0.1.0", default-features = false, features = ["webc-fs"] } virtual-net = { path = "../vnet", version = "0.1.0", default-features = false } -virtnet-native = { path = "../wasi-local-networking", version = "0.1.0", default-features = false, optional = true } wasmer-emscripten = { path = "../emscripten", version = "=3.2.0-alpha.1", optional = true } typetag = { version = "0.1", optional = true } serde = { version = "1.0", default-features = false, features = ["derive"] } @@ -112,7 +111,7 @@ js = ["wasmer/js", "virtual-fs/no-time", "getrandom/js", "chrono", "wasmer-wasix js-default = ["js", "wasmer/js-default"] test-js = ["js", "wasmer/js-default", "wasmer/wat"] -host-vnet = [ "virtnet-native" ] +host-vnet = [ "virtual-net/host-net" ] host-threads = [] host-reqwest = ["reqwest"] host-fs = ["virtual-fs/host-fs"] diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 5b3c26b8dbf..2034e0eb935 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -82,7 +82,7 @@ pub use virtual_net; pub use virtual_net::{UnsupportedVirtualNetworking, VirtualNetworking}; #[cfg(feature = "host-vnet")] -pub use virtnet_native::{ +pub use virtual_net::host::{ io_err_into_net_error, LocalNetworking, LocalTcpListener, LocalTcpStream, LocalUdpSocket, }; use wasmer_wasix_types::wasi::{BusErrno, Errno, ExitCode}; diff --git a/lib/wasi/src/os/console/mod.rs b/lib/wasi/src/os/console/mod.rs index 27ce2e913b0..52ae0ea1050 100644 --- a/lib/wasi/src/os/console/mod.rs +++ b/lib/wasi/src/os/console/mod.rs @@ -229,9 +229,12 @@ impl Console { if let Err(err) = env.uses(self.uses.clone()) { let mut stderr = self.stderr.clone(); tasks.block_on(async { - virtual_fs::AsyncWriteExt::write_all(&mut stderr, format!("{}\r\n", err).as_bytes()) - .await - .ok(); + virtual_fs::AsyncWriteExt::write_all( + &mut stderr, + format!("{}\r\n", err).as_bytes(), + ) + .await + .ok(); }); tracing::debug!("failed to load used dependency - {}", err); return Err(VirtualBusError::BadRequest); diff --git a/lib/wasi/src/runtime/mod.rs b/lib/wasi/src/runtime/mod.rs index 02a9a06388e..c84e236aa6d 100644 --- a/lib/wasi/src/runtime/mod.rs +++ b/lib/wasi/src/runtime/mod.rs @@ -83,7 +83,7 @@ impl PluggableRuntimeImplementation { // TODO: the cfg flags below should instead be handled by separate implementations. cfg_if::cfg_if! { if #[cfg(feature = "host-vnet")] { - let networking = Arc::new(virtnet_native::LocalNetworking::default()); + let networking = Arc::new(virtual_net::host::LocalNetworking::default()); } else { let networking = Arc::new(virtual_net::UnsupportedVirtualNetworking::default()); } diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index 20c4293a30d..ef221e3035f 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -177,7 +177,10 @@ impl WasiState { // Implementations of direct to FS calls so that we can easily change their implementation impl WasiState { - pub(crate) fn fs_read_dir>(&self, path: P) -> Result { + pub(crate) fn fs_read_dir>( + &self, + path: P, + ) -> Result { self.fs .root_fs .read_dir(path.as_ref()) From c979d6f00c9d08b8c54c1e0fdd2d0aa3246aad1b Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 16 Mar 2023 14:21:10 +0100 Subject: [PATCH 4/4] Adapted a doc test of overlay-fs --- lib/vfs/src/overlay_fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vfs/src/overlay_fs.rs b/lib/vfs/src/overlay_fs.rs index b1e96a8bd18..d65a81c0ecd 100644 --- a/lib/vfs/src/overlay_fs.rs +++ b/lib/vfs/src/overlay_fs.rs @@ -26,7 +26,7 @@ use crate::{ /// might do something like this: /// /// ```rust -/// use wasmer_vfs::{ +/// use virtual_fs::{ /// mem_fs::FileSystem as MemFS, /// host_fs::FileSystem as HostFS, /// OverlayFileSystem,