mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
hypervisor: Implement StandardRegisters as union of KVM & MSHV
Currently we are redefining StandardRegisters instead of using the ones coming from bindings. With this we can remove the unnecessary construction of global structure which contains fields from different hypervisor dependent structs. Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
This commit is contained in:
parent
3645654c39
commit
feb0a36067
@ -337,6 +337,23 @@ impl From<ClockData> for kvm_clock_data {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<kvm_bindings::kvm_regs> for crate::StandardRegisters {
|
||||
fn from(s: kvm_bindings::kvm_regs) -> Self {
|
||||
crate::StandardRegisters::Kvm(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::StandardRegisters> for kvm_bindings::kvm_regs {
|
||||
fn from(e: crate::StandardRegisters) -> Self {
|
||||
match e {
|
||||
crate::StandardRegisters::Kvm(e) => e,
|
||||
/* Needed in case other hypervisors are enabled */
|
||||
#[allow(unreachable_patterns)]
|
||||
_ => panic!("StandardRegisters are not valid"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<kvm_irq_routing_entry> for IrqRoutingEntry {
|
||||
fn from(s: kvm_irq_routing_entry) -> Self {
|
||||
IrqRoutingEntry::Kvm(s)
|
||||
|
@ -187,3 +187,11 @@ pub enum IrqRoutingEntry {
|
||||
#[cfg(feature = "mshv")]
|
||||
Mshv(mshv_bindings::mshv_msi_routing_entry),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum StandardRegisters {
|
||||
#[cfg(feature = "kvm")]
|
||||
Kvm(kvm_bindings::kvm_regs),
|
||||
#[cfg(all(feature = "mshv", target_arch = "x86_64"))]
|
||||
Mshv(mshv_bindings::StandardRegisters),
|
||||
}
|
||||
|
@ -165,6 +165,23 @@ impl From<CpuState> for VcpuMshvState {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<mshv_bindings::StandardRegisters> for crate::StandardRegisters {
|
||||
fn from(s: mshv_bindings::StandardRegisters) -> Self {
|
||||
crate::StandardRegisters::Mshv(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::StandardRegisters> for mshv_bindings::StandardRegisters {
|
||||
fn from(e: crate::StandardRegisters) -> Self {
|
||||
match e {
|
||||
crate::StandardRegisters::Mshv(e) => e,
|
||||
/* Needed in case other hypervisors are enabled */
|
||||
#[allow(unreachable_patterns)]
|
||||
_ => panic!("StandardRegisters are not valid"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<mshv_msi_routing_entry> for IrqRoutingEntry {
|
||||
fn from(s: mshv_msi_routing_entry) -> Self {
|
||||
IrqRoutingEntry::Mshv(s)
|
||||
|
Loading…
Reference in New Issue
Block a user