From 31145060b278dabc85215892e2d9e5b20c54aabe Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 3 Feb 2021 15:04:02 -0800 Subject: [PATCH] remove virtfs - it is not suitable for use --- Cargo.lock | 11 - Cargo.toml | 1 - crates/test-programs/Cargo.toml | 1 - crates/test-programs/build.rs | 1 - .../tests/wasm_tests/runtime/mod.rs | 1 - .../tests/wasm_tests/runtime/virtfs.rs | 71 --- crates/wasi-common/virtfs/Cargo.toml | 19 - crates/wasi-common/virtfs/src/lib.rs | 507 ------------------ 8 files changed, 612 deletions(-) delete mode 100644 crates/test-programs/tests/wasm_tests/runtime/virtfs.rs delete mode 100644 crates/wasi-common/virtfs/Cargo.toml delete mode 100644 crates/wasi-common/virtfs/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index e5616ca01c..441aaba6a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2806,7 +2806,6 @@ dependencies = [ "tempfile", "wasi-cap-std-sync", "wasi-common", - "wasi-virtfs", "wasmtime", "wasmtime-wasi", "wat", @@ -3127,16 +3126,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "wasi-virtfs" -version = "0.22.0" -dependencies = [ - "anyhow", - "cap-std", - "tracing", - "wasi-common", -] - [[package]] name = "wasm-encoder" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 376a40bea8..4321fda023 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,7 +77,6 @@ members = [ "crates/wiggle/wasmtime", "crates/wasi-common", "crates/wasi-common/cap-std-sync", - "crates/wasi-common/virtfs", "examples/fib-debug/wasm", "examples/wasi/wasm", "fuzz", diff --git a/crates/test-programs/Cargo.toml b/crates/test-programs/Cargo.toml index 3dc15366b3..598bbc203a 100644 --- a/crates/test-programs/Cargo.toml +++ b/crates/test-programs/Cargo.toml @@ -12,7 +12,6 @@ cfg-if = "1.0" [dev-dependencies] wasi-common = { path = "../wasi-common", version = "0.22.0" } -wasi-virtfs = { path = "../wasi-common/virtfs", version = "0.22.0" } wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync", version = "0.22.0" } wasmtime = { path = "../wasmtime", version = "0.22.0" } wasmtime-wasi = { path = "../wasi", version = "0.22.0" } diff --git a/crates/test-programs/build.rs b/crates/test-programs/build.rs index 3b9273334f..6de5c1172b 100644 --- a/crates/test-programs/build.rs +++ b/crates/test-programs/build.rs @@ -41,7 +41,6 @@ mod wasi_tests { build_tests("wasi-tests", &out_dir).expect("building tests"); test_directory(&mut out, "wasi-cap-std-sync", "cap_std_sync", &out_dir) .expect("generating tests"); - test_directory(&mut out, "wasi-virtfs", "virtfs", &out_dir).expect("generating tests"); } fn build_tests(testsuite: &str, out_dir: &Path) -> io::Result<()> { diff --git a/crates/test-programs/tests/wasm_tests/runtime/mod.rs b/crates/test-programs/tests/wasm_tests/runtime/mod.rs index e78d578b80..035b1e83ea 100644 --- a/crates/test-programs/tests/wasm_tests/runtime/mod.rs +++ b/crates/test-programs/tests/wasm_tests/runtime/mod.rs @@ -1,2 +1 @@ pub mod cap_std_sync; -pub mod virtfs; diff --git a/crates/test-programs/tests/wasm_tests/runtime/virtfs.rs b/crates/test-programs/tests/wasm_tests/runtime/virtfs.rs deleted file mode 100644 index 58ea75ae8f..0000000000 --- a/crates/test-programs/tests/wasm_tests/runtime/virtfs.rs +++ /dev/null @@ -1,71 +0,0 @@ -use anyhow::Context; -use std::cell::RefCell; -use std::path::Path; -use std::rc::Rc; -use wasi_common::{ - pipe::{ReadPipe, WritePipe}, - table::Table, - WasiCtx, -}; -use wasmtime::{Linker, Module, Store}; - -pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> anyhow::Result<()> { - let stdout = WritePipe::new_in_memory(); - let stderr = WritePipe::new_in_memory(); - - let r = { - let store = Store::default(); - - // Create our wasi context. - let mut builder = WasiCtx::builder( - wasi_cap_std_sync::random_ctx(), - wasi_cap_std_sync::clocks_ctx(), - wasi_cap_std_sync::sched_ctx(), // We shouldnt actually use this, but we will until we make a virtual scheduler - Rc::new(RefCell::new(Table::new())), - ); - - builder = builder - .arg(bin_name)? - .arg(".")? - .stdin(Box::new(ReadPipe::from(Vec::new()))) - .stdout(Box::new(stdout.clone())) - .stderr(Box::new(stderr.clone())); - - if workspace.is_some() { - let fs = wasi_virtfs::Filesystem::new(wasi_cap_std_sync::clocks_ctx().system, 420); // XXX this is duplicated - should be reference counted so I can use the same in the builder... - builder = builder.preopened_dir(fs.root(), ".")?; - } - let wasi = wasmtime_wasi::Wasi::new(&store, builder.build()?); - - let mut linker = Linker::new(&store); - - wasi.add_to_linker(&mut linker)?; - - let module = Module::new(store.engine(), &data).context("failed to create wasm module")?; - let instance = linker.instantiate(&module)?; - let start = instance.get_func("_start").unwrap(); - let with_type = start.get0::<()>()?; - with_type().map_err(anyhow::Error::from) - }; - - match r { - Ok(()) => Ok(()), - Err(trap) => { - let stdout = stdout - .try_into_inner() - .expect("sole ref to stdout") - .into_inner(); - if !stdout.is_empty() { - println!("guest stdout:\n{}\n===", String::from_utf8_lossy(&stdout)); - } - let stderr = stderr - .try_into_inner() - .expect("sole ref to stderr") - .into_inner(); - if !stderr.is_empty() { - println!("guest stderr:\n{}\n===", String::from_utf8_lossy(&stderr)); - } - Err(trap.context(format!("error while testing Wasm module '{}'", bin_name,))) - } - } -} diff --git a/crates/wasi-common/virtfs/Cargo.toml b/crates/wasi-common/virtfs/Cargo.toml deleted file mode 100644 index 0be09ac1e9..0000000000 --- a/crates/wasi-common/virtfs/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "wasi-virtfs" -version = "0.22.0" -authors = ["The Wasmtime Project Developers"] -description = "WASI implementation in Rust" -license = "Apache-2.0 WITH LLVM-exception" -categories = ["wasm"] -keywords = ["webassembly", "wasm"] -repository = "https://github.com/bytecodealliance/wasmtime" -readme = "README.md" -edition = "2018" -include = ["src/**/*", "LICENSE" ] -publish = false - -[dependencies] -wasi-common = { path = "../", version = "0.22.0" } -anyhow = "1.0" -cap-std = "0.12" -tracing = "0.1.19" diff --git a/crates/wasi-common/virtfs/src/lib.rs b/crates/wasi-common/virtfs/src/lib.rs deleted file mode 100644 index 52fe3652e9..0000000000 --- a/crates/wasi-common/virtfs/src/lib.rs +++ /dev/null @@ -1,507 +0,0 @@ -#![allow(dead_code, unused_variables, unused_imports)] -use cap_std::time::{Duration, SystemTime}; -use std::any::Any; -use std::cell::{Cell, Ref, RefCell, RefMut}; -use std::collections::{hash_map::Entry, HashMap}; -use std::convert::TryInto; -use std::io::{Cursor, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write}; -use std::ops::Deref; -use std::path::PathBuf; -use std::rc::{Rc, Weak}; -use tracing::trace; -use wasi_common::{ - clocks::WasiSystemClock, - dir::{ReaddirCursor, ReaddirEntity, WasiDir}, - file::{Advice, FdFlags, FileCaps, FileType, Filestat, OFlags, WasiFile}, - Error, ErrorExt, SystemTimeSpec, -}; - -pub struct Filesystem { - // Always .get() out a Some - this is an RefCell