diff --git a/hypervisor/src/cpu.rs b/hypervisor/src/cpu.rs index f5cbe0e06..4d1cd784f 100644 --- a/hypervisor/src/cpu.rs +++ b/hypervisor/src/cpu.rs @@ -321,6 +321,12 @@ pub type Result = anyhow::Result; /// Trait to represent a generic Vcpu /// pub trait Vcpu: Send + Sync { + /// + /// Returns StandardRegisters with default value set + /// + fn create_standard_regs(&self) -> StandardRegisters { + unimplemented!(); + } /// /// Returns the vCPU general purpose registers. /// diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index a2df76769..3f8fc4469 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1190,6 +1190,13 @@ pub struct KvmVcpu { /// let vcpu = vm.create_vcpu(0, None).unwrap(); /// ``` impl cpu::Vcpu for KvmVcpu { + /// + /// Returns StandardRegisters with default value set + /// + #[cfg(target_arch = "x86_64")] + fn create_standard_regs(&self) -> StandardRegisters { + kvm_bindings::kvm_regs::default().into() + } #[cfg(target_arch = "x86_64")] /// /// Returns the vCPU general purpose registers. diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index cb6ad2bb2..19dfe0a9a 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -413,6 +413,13 @@ pub struct MshvVcpu { /// let vcpu = vm.create_vcpu(0, None).unwrap(); /// ``` impl cpu::Vcpu for MshvVcpu { + /// + /// Returns StandardRegisters with default value set + /// + #[cfg(target_arch = "x86_64")] + fn create_standard_regs(&self) -> crate::arch::x86::StandardRegisters { + mshv_bindings::StandardRegisters::default().into() + } #[cfg(target_arch = "x86_64")] /// /// Returns the vCPU general purpose registers.