Skip to content

Commit

Permalink
Merge pull request #4462 from wasmerio/dproxy
Browse files Browse the repository at this point in the history
Implemented DProxy which gives fuse mounting of journals, memory and thread snapshots and implements the majority of the snapshot filters
  • Loading branch information
john-sharratt authored Mar 21, 2024
2 parents c8e5c20 + c09b105 commit 1af8c3c
Show file tree
Hide file tree
Showing 144 changed files with 8,334 additions and 1,661 deletions.
181 changes: 137 additions & 44 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ wasmer-toml = "0.9.2"
wasmparser = { version = "0.121.0", default-features = false }
webc = { version = "5.8.0", default-features = false, features = ["package"] }
shared-buffer = "0.1.4"
rkyv = { version = "0.7.40", features = ["indexmap", "validation", "strict"] }
memmap2 = { version = "0.6.2" }

[build-dependencies]
test-generator = { path = "tests/lib/test-generator" }
Expand Down
10 changes: 10 additions & 0 deletions lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ default = [
# Tun-tap client for connecting to Wasmer Edge VPNs
tun-tap = ["dep:tun-tap", "virtual-net/tokio-tungstenite", "tokio-tungstenite", "mio", "futures-util", "mac_address", "dep:interfaces"]
journal = ["wasmer-wasix/journal"]
fuse = ["dep:fuse", "dep:time01", "dep:shared-buffer", "dep:rkyv"]
backend = []
coredump = ["wasm-coredump-builder"]
sys = ["compiler", "wasmer-vm"]
Expand Down Expand Up @@ -79,6 +80,7 @@ wasmer-wasix = { version = "0.18.2", path = "../wasix", features = [
"logging",
"webc_runner_rt_wcgi",
"webc_runner_rt_dcgi",
"webc_runner_rt_dproxy",
"webc_runner_rt_emscripten",
"host-fs",
] }
Expand All @@ -104,6 +106,14 @@ wasmer-api = { version = "=0.0.24", path = "../backend-api" }
edge-schema = { version = "=0.0.2" }
edge-util = { version = "=0.0.1" }

# Used by the mount command

shared-buffer = { workspace = true, optional = true }
rkyv = { workspace = true, optional = true }
fuse = { version = "0.3", optional = true }
time01 = { package = "time", version = "0.1.45", optional = true }


# Third-party dependencies.

is-terminal = "0.4.7"
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/src/commands/journal/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use crate::commands::CliCommand;
/// Imports events into a journal file. Events are streamed as JSON
/// objects into `stdin`
#[derive(Debug, Parser)]
pub struct CmdJournaImport {
pub struct CmdJournalImport {
/// Path to the journal that will be printed
#[clap(index = 1)]
journal_path: PathBuf,
}

impl CliCommand for CmdJournaImport {
impl CliCommand for CmdJournalImport {
type Output = ();

fn run(self) -> Result<(), anyhow::Error> {
Expand Down
4 changes: 2 additions & 2 deletions lib/cli/src/commands/journal/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use crate::commands::CliCommand;

/// Prints a summarized version of contents of a journal to stdout
#[derive(Debug, Parser)]
pub struct CmdJournaInspect {
pub struct CmdJournalInspect {
/// Path to the journal that will be printed
#[clap(index = 1)]
journal_path: PathBuf,
}

impl CliCommand for CmdJournaInspect {
impl CliCommand for CmdJournalInspect {
type Output = ();

fn run(self) -> Result<(), anyhow::Error> {
Expand Down
13 changes: 11 additions & 2 deletions lib/cli/src/commands/journal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ mod export;
mod filter;
mod import;
mod inspect;
#[cfg(feature = "fuse")]
mod mount;

pub use compact::*;
pub use export::*;
pub use filter::*;
pub use import::*;
pub use inspect::*;
#[cfg(feature = "fuse")]
pub use mount::*;

/// Manage Journal files.
#[derive(clap::Subcommand, Debug)]
Expand All @@ -20,11 +24,14 @@ pub enum CmdJournal {
/// Exports the contents of a journal to stdout as JSON objects
Export(CmdJournalExport),
/// Imports the events into a journal as JSON objects
Import(CmdJournaImport),
Import(CmdJournalImport),
/// Inspects the contents of a journal and summarizes it to `stdout`
Inspect(CmdJournaInspect),
Inspect(CmdJournalInspect),
/// Filters out certain events from a journal
Filter(CmdJournalFilter),
/// Mounts the journal at a particular directory
#[cfg(feature = "fuse")]
Mount(CmdJournalMount),
}

impl CliCommand for CmdJournal {
Expand All @@ -37,6 +44,8 @@ impl CliCommand for CmdJournal {
Self::Export(cmd) => cmd.run(),
Self::Inspect(cmd) => cmd.run(),
Self::Filter(cmd) => cmd.run(),
#[cfg(feature = "fuse")]
Self::Mount(cmd) => cmd.run(),
}
}
}
42 changes: 42 additions & 0 deletions lib/cli/src/commands/journal/mount/cmd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use std::{path::PathBuf, process::Stdio};

use clap::Parser;
use wasmer_wasix::fs::WasiFdSeed;

use super::fs::JournalFileSystemBuilder;
use crate::commands::CliCommand;

/// Mounts a journal as a file system on the local machine
#[derive(Debug, Parser)]
pub struct CmdJournalMount {
/// Path to the journal that will be printed
#[clap(index = 1)]
journal_path: PathBuf,
/// Path to the directory where the file system will be mounted
#[clap(index = 2)]
mount_path: PathBuf,
}

impl CliCommand for CmdJournalMount {
type Output = ();

fn run(self) -> Result<(), anyhow::Error> {
// First we unmount any existing file system on this path
std::process::Command::new("/bin/umount")
.arg(self.mount_path.to_string_lossy().as_ref())
.stderr(Stdio::null())
.stdout(Stdio::null())
.spawn()?
.wait()
.ok();

let fs = JournalFileSystemBuilder::new(&self.journal_path)
.with_fd_seed(WasiFdSeed::default())
.with_progress_bar(false)
.build()?;

// Mounts the journal file system at a path
fuse::mount(fs, &self.mount_path, &[])?;
Ok(())
}
}
Loading

0 comments on commit 1af8c3c

Please sign in to comment.