Skip to main content

Vm

Trait Vm 

Source
pub trait Vm: Send + Sync {
    // Required methods
    fn map_memory(&self, region: &GuestMemoryRegion) -> Result<()>;
    fn unmap_memory(&self, region: &GuestMemoryRegion) -> Result<()>;
    fn protect_memory(&self, range: GuestRange, prot: Protection) -> Result<()>;
    fn create_vcpu(&self, index: u32) -> Result<Box<dyn Vcpu>>;
}
Expand description

A live virtual machine handle owned by a HypervisorBackend.

The trait is split from HypervisorBackend because a backend may host multiple VMs (in principle) and because vCPU lifetimes are scoped to a single Vm.

Required Methods§

Source

fn map_memory(&self, region: &GuestMemoryRegion) -> Result<()>

Map a region of guest-physical memory.

Source

fn unmap_memory(&self, region: &GuestMemoryRegion) -> Result<()>

Unmap a previously-mapped region.

Source

fn protect_memory(&self, range: GuestRange, prot: Protection) -> Result<()>

Change the protection of an already-mapped range. Used for software dirty-page tracking on backends without a native dirty bitmap.

Source

fn create_vcpu(&self, index: u32) -> Result<Box<dyn Vcpu>>

Create a vCPU with the given index.

The returned Vcpu must be driven from a dedicated OS thread (HVF rule); the backend is permitted to enforce that by panicking on misuse, but callers should never depend on that.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§