1 use alloc::{string::ToString, sync::Arc}; 2 3 use system_error::SystemError; 4 5 use super::kset::KSet; 6 7 /// `/sys/hypervisor`的kset 8 static mut HYPERVISOR_KSET_INSTANCE: Option<Arc<KSet>> = None; 9 10 #[inline(always)] 11 #[allow(dead_code)] sys_hypervisor_kset() -> Arc<KSet>12pub fn sys_hypervisor_kset() -> Arc<KSet> { 13 unsafe { HYPERVISOR_KSET_INSTANCE.clone().unwrap() } 14 } 15 16 /// 初始化`/sys/hypervisor`的kset hypervisor_init() -> Result<(), SystemError>17pub(super) fn hypervisor_init() -> Result<(), SystemError> { 18 let hypervisor_kset = KSet::new("hypervisor".to_string()); 19 hypervisor_kset 20 .register(None) 21 .expect("register hypervisor kset failed"); 22 unsafe { 23 HYPERVISOR_KSET_INSTANCE = Some(hypervisor_kset); 24 } 25 return Ok(()); 26 } 27