mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-03 20:15:45 +00:00
hypervisor: mshv: Add Microsoft Hypervisor specific data to Mshv{Vm,Vcpu}
Adding hv_state (hyperv state) to Vm and Vcpu struct for mshv. This state is needed to keep some kernel data(for now hypercall page) in the vmm. Co-Developed-by: Praveen Paladugu <prapal@microsoft.com> Signed-off-by: Praveen Paladugu <prapal@microsoft.com> Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
parent
23c46b162e
commit
3a93487b82
@ -108,7 +108,11 @@ impl hypervisor::Hypervisor for MshvHypervisor {
|
|||||||
}
|
}
|
||||||
let vm_fd = Arc::new(fd);
|
let vm_fd = Arc::new(fd);
|
||||||
|
|
||||||
Ok(Arc::new(MshvVm { fd: vm_fd, msrs }))
|
Ok(Arc::new(MshvVm {
|
||||||
|
fd: vm_fd,
|
||||||
|
msrs,
|
||||||
|
hv_state: hv_state_init(),
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
/// Get the supported CpuID
|
/// Get the supported CpuID
|
||||||
@ -133,6 +137,7 @@ pub struct MshvVcpu {
|
|||||||
vp_index: u8,
|
vp_index: u8,
|
||||||
cpuid: CpuId,
|
cpuid: CpuId,
|
||||||
msrs: MsrEntries,
|
msrs: MsrEntries,
|
||||||
|
hv_state: Arc<RwLock<HvState>>, // Mshv State
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation of Vcpu trait for Microsoft Hypervisor
|
/// Implementation of Vcpu trait for Microsoft Hypervisor
|
||||||
@ -327,11 +332,19 @@ impl cpu::Vcpu for MshvVcpu {
|
|||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper over Mshv VM ioctls.
|
/// Wrapper over Mshv VM ioctls.
|
||||||
pub struct MshvVm {
|
pub struct MshvVm {
|
||||||
fd: Arc<VmFd>,
|
fd: Arc<VmFd>,
|
||||||
msrs: MsrEntries,
|
msrs: MsrEntries,
|
||||||
|
// Hypervisor State
|
||||||
|
hv_state: Arc<RwLock<HvState>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn hv_state_init() -> Arc<RwLock<HvState>> {
|
||||||
|
Arc::new(RwLock::new(HvState { hypercall_page: 0 }))
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Implementation of Vm trait for Mshv
|
/// Implementation of Vm trait for Mshv
|
||||||
/// Example:
|
/// Example:
|
||||||
@ -386,6 +399,7 @@ impl vm::Vm for MshvVm {
|
|||||||
vp_index: id,
|
vp_index: id,
|
||||||
cpuid: CpuId::new(1 as usize),
|
cpuid: CpuId::new(1 as usize),
|
||||||
msrs: self.msrs.clone(),
|
msrs: self.msrs.clone(),
|
||||||
|
hv_state: self.hv_state.clone(),
|
||||||
};
|
};
|
||||||
Ok(Arc::new(vcpu))
|
Ok(Arc::new(vcpu))
|
||||||
}
|
}
|
||||||
@ -449,12 +463,13 @@ impl vm::Vm for MshvVm {
|
|||||||
/// Get the Vm state. Return VM specific data
|
/// Get the Vm state. Return VM specific data
|
||||||
///
|
///
|
||||||
fn state(&self) -> vm::Result<VmState> {
|
fn state(&self) -> vm::Result<VmState> {
|
||||||
unimplemented!();
|
Ok(*self.hv_state.read().unwrap())
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
/// Set the VM state
|
/// Set the VM state
|
||||||
///
|
///
|
||||||
fn set_state(&self, state: VmState) -> vm::Result<()> {
|
fn set_state(&self, state: VmState) -> vm::Result<()> {
|
||||||
|
self.hv_state.write().unwrap().hypercall_page = state.hypercall_page;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user