diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs index d22e7b2b3..a644d5cd9 100644 --- a/hypervisor/src/lib.rs +++ b/hypervisor/src/lib.rs @@ -200,6 +200,8 @@ pub enum IrqRoutingEntry { pub enum VcpuInit { #[cfg(all(feature = "kvm", target_arch = "aarch64"))] Kvm(kvm_bindings::kvm_vcpu_init), + #[cfg(all(feature = "mshv", target_arch = "aarch64"))] + Mshv(mshv_bindings::MshvVcpuInit), } #[derive(Debug, Clone, PartialEq)] diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index a31461ef3..15cfe8fbd 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -210,6 +210,25 @@ impl From for mshv_bindings::MshvRegList { } } +#[cfg(target_arch = "aarch64")] +impl From for crate::VcpuInit { + fn from(s: mshv_bindings::MshvVcpuInit) -> Self { + crate::VcpuInit::Mshv(s) + } +} + +#[cfg(target_arch = "aarch64")] +impl From for mshv_bindings::MshvVcpuInit { + fn from(e: crate::VcpuInit) -> Self { + match e { + crate::VcpuInit::Mshv(e) => e, + /* Needed in case other hypervisors are enabled */ + #[allow(unreachable_patterns)] + _ => panic!("VcpuInit is not valid"), + } + } +} + struct MshvDirtyLogSlot { guest_pfn: u64, memory_size: u64,