Skip to content

Commit

Permalink
Add an auto-detect plugins mechanism for the Wasmedge shim
Browse files Browse the repository at this point in the history
Signed-off-by: vincent <[email protected]>
  • Loading branch information
CaptainVincent committed Sep 15, 2023
1 parent 390720e commit 4c4e9cf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/containerd-shim-wasmedge/src/instance_linux.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::path::Path;

use anyhow::{Context, Result};
use containerd_shim_wasm::container::{
Engine, Instance, PathResolve, RuntimeContext, Stdio, WasiEntrypoint,
};
use libcontainer::utils::parse_env;
use oci_spec::runtime::Mount;
use wasmedge_sdk::config::{ConfigBuilder, HostRegistrationConfigOptions};
use wasmedge_sdk::plugin::PluginManager;
Expand All @@ -15,13 +18,8 @@ pub struct WasmEdgeEngine {

impl Default for WasmEdgeEngine {
fn default() -> Self {
PluginManager::load(None).unwrap();

let host_options = HostRegistrationConfigOptions::default();
let host_options = host_options.wasi(true);
#[cfg(all(target_os = "linux", feature = "wasi_nn", target_arch = "x86_64"))]
let host_options = host_options.wasi_nn(true);

let config = ConfigBuilder::default()
.with_host_registration_config(host_options)
.build()
Expand Down Expand Up @@ -60,6 +58,9 @@ impl Engine for WasmEdgeEngine {
None => "main".to_string(),
};

let envs = parse_env(&envs);
PluginManager::load(envs.get("WASMEDGE_PLUGIN_PATH").map(Path::new))?;
let vm = vm.auto_detect_plugins()?;
let vm = vm
.register_module_from_file(&mod_name, &path)
.context("registering module")?;
Expand Down

0 comments on commit 4c4e9cf

Please sign in to comment.