mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 21:28:21 +00:00
Updates for the review comments
This commit is contained in:
@@ -7,6 +7,8 @@ use std::{collections::BTreeSet, path::Path};
|
||||
use wasmer::{AsStoreMut, Instance, Module, RuntimeError, Value};
|
||||
use wasmer_vfs::FileSystem;
|
||||
use wasmer_vfs::{DeviceFile, PassthruFileSystem, RootFileSystemBuilder};
|
||||
use wasmer_wasi::os::tty_sys::SysTyy;
|
||||
use wasmer_wasi::os::TtyBridge;
|
||||
use wasmer_wasi::types::__WASI_STDIN_FILENO;
|
||||
use wasmer_wasi::{
|
||||
default_fs_backing, get_wasi_versions, PluggableRuntimeImplementation, WasiEnv, WasiError,
|
||||
@@ -60,6 +62,10 @@ pub struct Wasi {
|
||||
#[clap(long = "net")]
|
||||
pub networking: bool,
|
||||
|
||||
/// Disables the TTY bridge
|
||||
#[clap(long = "no-tty")]
|
||||
pub no_tty: bool,
|
||||
|
||||
/// Allow instances to send http requests.
|
||||
///
|
||||
/// Access to domains is granted by default.
|
||||
@@ -128,6 +134,12 @@ impl Wasi {
|
||||
rt.set_networking_implementation(wasmer_vnet::UnsupportedVirtualNetworking::default());
|
||||
}
|
||||
|
||||
if self.no_tty == false {
|
||||
let tty = Arc::new(SysTyy::default());
|
||||
tty.reset();
|
||||
rt.set_tty(tty)
|
||||
}
|
||||
|
||||
let engine = store.as_store_mut().engine().clone();
|
||||
rt.set_engine(Some(engine));
|
||||
|
||||
|
||||
@@ -2763,10 +2763,7 @@ unsafe impl wasmer::FromToNativeWasmType for Errno {
|
||||
78 => Self::Memviolation,
|
||||
79 => Self::Unknown,
|
||||
|
||||
q => {
|
||||
tracing::debug!("could not serialize number {q} to enum Errno");
|
||||
Self::Unknown
|
||||
}
|
||||
_ => Self::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3758,10 +3755,7 @@ unsafe impl wasmer::FromToNativeWasmType for Signal {
|
||||
30 => Self::Sigpwr,
|
||||
31 => Self::Sigsys,
|
||||
|
||||
q => {
|
||||
tracing::warn!("could not serialize number {q} to enum Signal");
|
||||
Self::Sigunknown
|
||||
}
|
||||
_ => Self::Sigunknown,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ where
|
||||
}
|
||||
|
||||
/// Get access to the TTY used by the environment.
|
||||
fn tty(&self) -> Option<&dyn TtyBridge> {
|
||||
fn tty(&self) -> Option<&(dyn TtyBridge + Send + Sync)> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ pub struct PluggableRuntimeImplementation {
|
||||
#[cfg(feature = "sys")]
|
||||
pub engine: Option<wasmer::Engine>,
|
||||
#[derivative(Debug = "ignore")]
|
||||
pub tty: Arc<dyn TtyBridge + Send + Sync>,
|
||||
pub tty: Option<Arc<dyn TtyBridge + Send + Sync>>,
|
||||
}
|
||||
|
||||
impl PluggableRuntimeImplementation {
|
||||
@@ -109,7 +109,7 @@ impl PluggableRuntimeImplementation {
|
||||
}
|
||||
|
||||
pub fn set_tty(&mut self, tty: Arc<dyn TtyBridge + Send + Sync>) {
|
||||
self.tty = tty;
|
||||
self.tty = Some(tty);
|
||||
}
|
||||
|
||||
pub fn new(rt: Arc<dyn VirtualTaskManager>) -> Self {
|
||||
@@ -130,14 +130,6 @@ impl PluggableRuntimeImplementation {
|
||||
let http_client = None;
|
||||
}
|
||||
}
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(all(feature = "host-termios", unix))] {
|
||||
let tty = Arc::new(crate::os::tty_sys::SysTyy::default());
|
||||
tty.reset();
|
||||
} else {
|
||||
let tty = Arc::new(DefaultTty::default());
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
rt,
|
||||
@@ -145,7 +137,7 @@ impl PluggableRuntimeImplementation {
|
||||
http_client,
|
||||
#[cfg(feature = "sys")]
|
||||
engine: None,
|
||||
tty,
|
||||
tty: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +176,7 @@ impl WasiRuntime for PluggableRuntimeImplementation {
|
||||
&self.rt
|
||||
}
|
||||
|
||||
fn tty(&self) -> Option<&dyn TtyBridge> {
|
||||
Some(self.tty.as_ref())
|
||||
fn tty(&self) -> Option<&(dyn TtyBridge + Send + Sync)> {
|
||||
self.tty.as_deref()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user