(runtime_dir: &Path, log_level: u32)
| 981 | |
| 982 | impl 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( |
no test coverage detected