Skip to main content

Vcpu

Trait Vcpu 

Source
pub trait Vcpu: Send {
    // Required methods
    fn run(&mut self) -> Result<VcpuExit, HypervisorError>;
    fn get_regs(&self) -> Result<Registers, HypervisorError>;
    fn set_regs(&mut self, regs: &Registers) -> Result<(), HypervisorError>;
    fn id(&self) -> u32;
    fn set_io_result(&mut self, value: u64) -> Result<(), HypervisorError>;
    fn set_mmio_result(&mut self, value: u64) -> Result<(), HypervisorError>;
    fn snapshot(&self) -> Result<VcpuSnapshot, HypervisorError>;
    fn restore(
        &mut self,
        snapshot: &VcpuSnapshot,
    ) -> Result<(), HypervisorError>;
}
Expand description

Virtual CPU trait for executing guest code.

Required Methods§

Source

fn run(&mut self) -> Result<VcpuExit, HypervisorError>

Runs the vCPU until a VM exit occurs.

§Errors

Returns an error if vCPU execution fails.

Source

fn get_regs(&self) -> Result<Registers, HypervisorError>

Gets the current register state.

§Errors

Returns an error if registers cannot be read.

Source

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

Sets the register state.

§Errors

Returns an error if registers cannot be set.

Source

fn id(&self) -> u32

Gets the vCPU ID.

Source

fn set_io_result(&mut self, value: u64) -> Result<(), HypervisorError>

Sets the result of an I/O read operation.

This is called after handling an IoIn exit to provide the value that should be returned to the guest.

§Errors

Returns an error if the result cannot be set.

Source

fn set_mmio_result(&mut self, value: u64) -> Result<(), HypervisorError>

Sets the result of an MMIO read operation.

This is called after handling an MmioRead exit to provide the value that should be returned to the guest.

§Errors

Returns an error if the result cannot be set.

Source

fn snapshot(&self) -> Result<VcpuSnapshot, HypervisorError>

Creates a snapshot of the vCPU state.

§Errors

Returns an error if the snapshot cannot be created.

Source

fn restore(&mut self, snapshot: &VcpuSnapshot) -> Result<(), HypervisorError>

Restores the vCPU state from a snapshot.

§Errors

Returns an error if the state cannot be restored.

Implementors§