Skip to main content

Vcpu

Trait Vcpu 

Source
pub trait Vcpu: Send {
    // Required methods
    fn run(&mut self) -> Result<VmExit>;
    fn cancel(&self);
    fn get_regs(&self) -> Result<Regs>;
    fn set_regs(&mut self, regs: &Regs) -> Result<()>;
    fn inject_irq(&mut self, irq: Irq) -> Result<()>;
}
Expand description

A virtual CPU running inside a Vm.

Each implementation of Vcpu is bound to a single OS thread for the duration of its lifetime, mirroring the hv_vcpu_create/hv_vcpu_run pthread-affinity rule on macOS Hypervisor.framework. Callers must not move a Vcpu between threads.

Required Methods§

Source

fn run(&mut self) -> Result<VmExit>

Run the vCPU until the next exit and return the reason.

Source

fn cancel(&self)

Cancel a concurrent Self::run call. On HVF this maps to hv_vcpus_exit; on KVM it sends SIGRTMIN. Idempotent and safe to call from any thread.

Source

fn get_regs(&self) -> Result<Regs>

Read the architecture-tagged register file.

Source

fn set_regs(&mut self, regs: &Regs) -> Result<()>

Overwrite the architecture-tagged register file.

Source

fn inject_irq(&mut self, irq: Irq) -> Result<()>

Inject an interrupt that will be delivered to the guest at the next entry.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§