MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / create

Method create

crates/openshell-driver-vm/src/runtime.rs:983–1006  ·  view source on GitHub ↗
(runtime_dir: &Path, log_level: u32)

Source from the content-addressed store, hash-verified

981
982impl VmContext {
983 fn create(runtime_dir: &Path, log_level: u32) -> Result<Self, String> {
984 let krun = ffi::libkrun(runtime_dir)?;
985 check(
986 unsafe {
987 (krun.krun_init_log)(
988 ffi::KRUN_LOG_TARGET_DEFAULT,
989 clamp_log_level(log_level),
990 ffi::KRUN_LOG_STYLE_AUTO,
991 ffi::KRUN_LOG_OPTION_NO_ENV,
992 )
993 },
994 "krun_init_log",
995 )?;
996
997 let ctx_id = unsafe { (krun.krun_create_ctx)() };
998 if ctx_id < 0 {
999 return Err(format!("krun_create_ctx failed with error code {ctx_id}"));
1000 }
1001
1002 Ok(Self {
1003 krun,
1004 ctx_id: ctx_id.cast_unsigned(),
1005 })
1006 }
1007
1008 fn set_vm_config(&self, vcpus: u8, mem_mib: u32) -> Result<(), String> {
1009 check(

Callers 1

create_sandboxMethod · 0.45

Calls 3

libkrunFunction · 0.85
checkFunction · 0.85
clamp_log_levelFunction · 0.85

Tested by

no test coverage detected