-
Notifications
You must be signed in to change notification settings - Fork 95
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
add wasm-mico-runtime shim implementation #642
Conversation
|
||
impl Clone for WamrEngine { | ||
fn clone(&self) -> Self { | ||
let runtime = Runtime::new().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: is this a deep clone or shallow clone? Runwasi clones the runtime so that it could share to different instances. (i.e. https://github.com/containerd/runwasi/blob/main/crates/containerd-shim-wasm/src/sandbox/instance.rs#L98)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In wamr-rust-sdk, it'll execute +1 on runtime's reference counter.
log::info!("Create a WASI context"); | ||
|
||
let wasi_ctx = WasiCtxBuilder::new() | ||
.set_pre_open_path(vec!["/"], vec!["/"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.set_pre_open_path(vec!["/"], vec!["/"]) | |
.set_pre_open_path(vec!["/"], vec![]) |
let wasi_ctx = WasiCtxBuilder::new() | ||
.set_pre_open_path(vec!["/"], vec!["/"]) | ||
.set_env_vars(envs.iter().map(String::as_str).collect()) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.build(); | |
.set_arguments(args.iter().map(String::as_str).collect()) | |
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in order to pass arguments (like "wasi-demo-oci.wasm echo 'hi'") to wasm functions.
let function = Function::find_export_func(&instance, &func) | ||
.map_err(|e| anyhow::Error::msg(format!("Failed to find function: {:?}", e)))?; | ||
let status = function | ||
.call(&instance, &Vec::new()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just in case.
.call(&instance, &Vec::new()) | |
.call(&instance, &vec![])) |
diff --git a/crates/containerd-shim-wamr/Cargo.toml b/crates/containerd-shim-wamr/Cargo.toml
index 2dd3178..7ea5e0a 100644
--- a/crates/containerd-shim-wamr/Cargo.toml
+++ b/crates/containerd-shim-wamr/Cargo.toml
@@ -13,7 +13,7 @@ oci-spec = { workspace = true, features = ["runtime"] }
ttrpc = { workspace = true }
sha256 = { workspace = true }
-wamr-rust-sdk = { git = "https://github.com/macko99/wamr-rust-sdk", branch = "main" }
+wamr-rust-sdk = { git = "https://github.com/bytecodealliance/wamr-rust-sdk", branch = "main" }
[dev-dependencies]
containerd-shim-wasm = { workspace = true, features = ["testing"] }
diff --git a/crates/containerd-shim-wamr/src/instance.rs b/crates/containerd-shim-wamr/src/instance.rs
index b1f15e3..8632a53 100644
--- a/crates/containerd-shim-wamr/src/instance.rs
+++ b/crates/containerd-shim-wamr/src/instance.rs
@@ -66,9 +66,10 @@ impl Engine for WamrEngine {
log::info!("Create a WASI context");
let wasi_ctx = WasiCtxBuilder::new()
- .set_pre_open_path(vec!["/"], vec![])
- .set_env_vars(envs.iter().map(String::as_str).collect())
- .build();
+ .set_pre_open_path(vec!["/"], vec![])
+ .set_env_vars(envs.iter().map(String::as_str).collect())
+ .set_arguments(args.iter().map(String::as_str).collect())
+ .build();
module.set_wasi_context(wasi_ctx); Then it should work |
@Mossaka any update? Let me know if you need any help. |
this is an updated PR using adding addtional shim implementation: Wamr using latest wamr-rust-sdk.
It is still not working, the shim exits with one of the errors:
-"thread signal env initialized failed"
-without any error
-"error running start function: Failed to create instance: InstantiationFailure("error while pre-opening mapped directory: invalid map"
-"Running "_start"" then "Error: ExecutionError("Exception: unreachable")"
My module has only the main function defined.
I have tried disabling hardware checks in WAMR since I'm working on the VM, commit
FYI @squillace @0xE282B0 @lum1n0us @Mossaka