-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equivalence for WasiCtx.insert_file
from wasmtime_wasi Rust crate
#187
Comments
What I am trying to achieve is basically passing a socket (say, |
Thanks for the report! I believe this is similar and/or the same as #34 though where the C API doesn't support this yet so the first step here would be to add support there which these bindings could then use. |
Thanks for getting back to me. Is the support for such C APIs an officially planed feature to be implemented? |
Just waiting on a PR! No one is currently signed up to make such a PR if that's what you're asking though. |
Thanks for the clarification. May I ask why |
/**
* \brief Configures a "preopened" listen socket to be available to WASI APIs.
*
* By default WASI programs do not have access to open up network sockets on
* the host. This API can be used to grant WASI programs access to a network
* socket file descriptor on the host.
*
* The fd_num argument is the number of the file descriptor by which it will be
* known in WASM and the host_port is the IP address and port (e.g.
* "127.0.0.1:8080") requested to listen on.
*/
WASI_API_EXTERN bool wasi_config_preopen_socket(wasi_config_t* config, uint32_t fd_num, const char* host_port); |
No reason other than someone hasn't gotten around to adding it yet, if you'd like to do that that'd be welcome! |
We are planning on perhaps implementing and linking some of the missing C-APIs related to this. Before a PR is available, are there any compelling reason for |
That'd be great, and thank you! I'm not sure I understand what you mean though about |
If I understood correctly, the current flow in wasmtime-go of setting #[cfg(feature = "wasi")]
#[no_mangle]
pub extern "C" fn wasmtime_context_set_wasi(
mut context: CStoreContextMut<'_>,
wasi: Box<crate::wasi_config_t>,
) -> Option<Box<wasmtime_error_t>> {
crate::handle_result(wasi.into_wasi_ctx(), |wasi| {
context.data_mut().wasi = Some(wasi);
})
} A downside of this is that while wasmtime (Rust) could update the |
Ah ok I think I understand now, and in that case I think it's ok to skip this for now unless needed. AFAIK even in Rust it's intended that you don't do much with Do you have a use case though for accessing |
One possible use case is to allow WASI modules dynamically requesting new sockets/pipes to be made available from the host program (wasmtime), e.g., dialing/listening for TCP. |
Good point! For something like this I think I'd recommend exposing it as |
@alexcrichton Please see #190. Which is still pending on bytecodealliance/wasmtime#7001. I actually also implemented a few tests for |
Hi, thanks for this amazing project.
I came across the wasmtime_wasi Rust crate and found the
WasiCtx
struct really handy, and especially for itsinsert_file
function.While not being able to identify the equivalence of
WasiCtx
fromwasmtime-go
, I seeWasiConfig
implements some similar functions, including SetStderrFile, SetStdinFile, and SetStdoutFile.I was wondering if I missed anything or is it not yet supported? If so, are there such a plan to support some more (if not all) APIs available to the rust crates?
The text was updated successfully, but these errors were encountered: