pub struct ArchVm {
pub common: VmCommon,
pub pio_bus: Arc<Bus>,
/* private fields */
}Expand description
Structure representing the current architecture’s understand of what a “virtual machine” is.
Fields§
§common: VmCommonArchitecture independent parts of a vm
pio_bus: Arc<Bus>Port IO bus
Implementations§
Source§impl ArchVm
impl ArchVm
Sourcepub fn arch_pre_create_vcpus(&mut self, _: u8) -> Result<(), ArchVmError>
pub fn arch_pre_create_vcpus(&mut self, _: u8) -> Result<(), ArchVmError>
Pre-vCPU creation setup.
Sourcepub fn arch_post_create_vcpus(&mut self, _: u8) -> Result<(), ArchVmError>
pub fn arch_post_create_vcpus(&mut self, _: u8) -> Result<(), ArchVmError>
Post-vCPU creation setup.
Sourcepub fn restore_state(&mut self, state: &VmState) -> Result<(), ArchVmError>
pub fn restore_state(&mut self, state: &VmState) -> Result<(), ArchVmError>
Restores the KVM VM state.
§Errors
When:
- [
kvm_ioctls::VmFd::set_pit] errors. - [
kvm_ioctls::VmFd::set_clock] errors. - [
kvm_ioctls::VmFd::set_irqchip] errors. - [
kvm_ioctls::VmFd::set_irqchip] errors. - [
kvm_ioctls::VmFd::set_irqchip] errors.
Sourcepub fn setup_irqchip(&self) -> Result<(), ArchVmError>
pub fn setup_irqchip(&self) -> Result<(), ArchVmError>
Creates the irq chip and an in-kernel device model for the PIT.
Sourcepub fn save_state(&self) -> Result<VmState, ArchVmError>
pub fn save_state(&self) -> Result<VmState, ArchVmError>
Saves and returns the Kvm Vm state.
Sourcepub fn msrs_to_save(&self) -> &[u32]
pub fn msrs_to_save(&self) -> &[u32]
Gets the list of MSRs to save when creating snapshots
Sourcepub fn xsave2_size(&self) -> Option<usize>
pub fn xsave2_size(&self) -> Option<usize>
Gets the size (in bytes) of the kvm_xsave struct.
Source§impl Vm
Contains Vm functions that are usable across CPU architectures
impl Vm
Contains Vm functions that are usable across CPU architectures
Sourcepub fn create_vcpus(
&mut self,
vcpu_count: u8,
) -> Result<(Vec<Vcpu>, EventFd), VmError>
pub fn create_vcpus( &mut self, vcpu_count: u8, ) -> Result<(Vec<Vcpu>, EventFd), VmError>
Creates the specified number of Vcpus.
The returned [EventFd] is written to whenever any of the vcpus exit.
Sourcepub fn next_kvm_slot(&self, slot_cnt: u32) -> Option<u32>
pub fn next_kvm_slot(&self, slot_cnt: u32) -> Option<u32>
Reserves the next slot_cnt contiguous kvm slot ids and returns the first one
Sourcepub fn register_dram_memory_regions(
&mut self,
regions: Vec<GuestRegionMmap>,
) -> Result<(), VmError>
pub fn register_dram_memory_regions( &mut self, regions: Vec<GuestRegionMmap>, ) -> Result<(), VmError>
Register a list of new memory regions to this Vm.
Sourcepub fn register_hotpluggable_memory_region(
&mut self,
region: GuestRegionMmap,
slot_size: usize,
) -> Result<(), VmError>
pub fn register_hotpluggable_memory_region( &mut self, region: GuestRegionMmap, slot_size: usize, ) -> Result<(), VmError>
Register a new hotpluggable region to this Vm.
Sourcepub fn restore_memory_regions(
&mut self,
regions: Vec<GuestRegionMmap>,
state: &GuestMemoryState,
) -> Result<(), VmError>
pub fn restore_memory_regions( &mut self, regions: Vec<GuestRegionMmap>, state: &GuestMemoryState, ) -> Result<(), VmError>
Register a list of new memory regions to this Vm.
Note: regions and state.regions need to be in the same order.
Sourcepub fn guest_memory(&self) -> &GuestMemoryMmap
pub fn guest_memory(&self) -> &GuestMemoryMmap
Gets a reference to this Vm’s GuestMemoryMmap object
Sourcepub fn resource_allocator(&self) -> MutexGuard<'_, ResourceAllocator>
pub fn resource_allocator(&self) -> MutexGuard<'_, ResourceAllocator>
Gets a mutable reference to this Vm’s ResourceAllocator object
Sourcepub fn reset_dirty_bitmap(&self)
pub fn reset_dirty_bitmap(&self)
Resets the KVM dirty bitmap for each of the guest’s memory regions.
Sourcepub fn reset_dirty_rings(&self) -> Result<(), VmError>
pub fn reset_dirty_rings(&self) -> Result<(), VmError>
Resets the KVM dirty ring tracking for all vcpus.
Sourcepub fn get_dirty_bitmap(&self) -> Result<DirtyBitmap, VmError>
pub fn get_dirty_bitmap(&self) -> Result<DirtyBitmap, VmError>
Retrieves the KVM dirty bitmap for each of the guest’s memory regions.
Sourcepub fn register_irq(&self, fd: &EventFd, gsi: u32) -> Result<(), Error>
pub fn register_irq(&self, fd: &EventFd, gsi: u32) -> Result<(), Error>
Register a device IRQ
Sourcepub fn register_msi(
&self,
route: &MsixVector,
masked: bool,
config: MsixVectorConfig,
) -> Result<(), Error>
pub fn register_msi( &self, route: &MsixVector, masked: bool, config: MsixVectorConfig, ) -> Result<(), Error>
Register an MSI device interrupt
Sourcepub fn create_msix_group(
vm: Arc<Vm>,
count: u16,
) -> Result<MsixVectorGroup, InterruptError>
pub fn create_msix_group( vm: Arc<Vm>, count: u16, ) -> Result<MsixVectorGroup, InterruptError>
Create a group of MSI-X interrupts
Sourcepub fn set_gsi_routes(&self) -> Result<(), InterruptError>
pub fn set_gsi_routes(&self) -> Result<(), InterruptError>
Set GSI routes to KVM
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ArchVm
impl RefUnwindSafe for ArchVm
impl Send for ArchVm
impl Sync for ArchVm
impl Unpin for ArchVm
impl UnwindSafe for ArchVm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.