pub struct VmResources {Show 14 fields
pub machine_config: MachineConfig,
pub boot_source: BootSource,
pub block: BlockBuilder,
pub vsock: VsockBuilder,
pub balloon: BalloonBuilder,
pub net_builder: NetBuilder,
pub entropy: EntropyDeviceBuilder,
pub pmem: PmemBuilder,
pub memory_hotplug: Option<MemoryHotplugConfig>,
pub mmds: Option<Arc<Mutex<Mmds>>>,
pub mmds_size_limit: usize,
pub boot_timer: bool,
pub pci_enabled: bool,
pub serial_out_path: Option<PathBuf>,
}Expand description
A data structure that encapsulates the device configurations held in the Vmm.
Fields§
§machine_config: MachineConfigThe vCpu and memory configuration for this microVM.
boot_source: BootSourceThe boot source spec (contains both config and builder) for this microVM.
block: BlockBuilderThe block devices.
vsock: VsockBuilderThe vsock device.
balloon: BalloonBuilderThe balloon device.
net_builder: NetBuilderThe network devices builder.
entropy: EntropyDeviceBuilderThe entropy device builder.
pmem: PmemBuilderThe pmem devices.
memory_hotplug: Option<MemoryHotplugConfig>The memory hotplug configuration.
mmds: Option<Arc<Mutex<Mmds>>>The optional Mmds data store.
mmds_size_limit: usizeData store limit for the mmds.
boot_timer: boolWhether or not to load boot timer device.
pci_enabled: boolWhether or not to use PCIe transport for VirtIO devices.
serial_out_path: Option<PathBuf>Where serial console output should be written to
Implementations§
Source§impl VmResources
impl VmResources
Sourcepub fn from_json(
config_json: &str,
instance_info: &InstanceInfo,
mmds_size_limit: usize,
metadata_json: Option<&str>,
) -> Result<Self, ResourcesError>
pub fn from_json( config_json: &str, instance_info: &InstanceInfo, mmds_size_limit: usize, metadata_json: Option<&str>, ) -> Result<Self, ResourcesError>
Configures Vmm resources as described by the config_json param.
Sourcepub fn mmds_or_default(&mut self) -> Result<&Arc<Mutex<Mmds>>, MmdsConfigError>
pub fn mmds_or_default(&mut self) -> Result<&Arc<Mutex<Mmds>>, MmdsConfigError>
If not initialised, create the mmds data store with the default config.
Sourcepub fn locked_mmds_or_default(
&mut self,
) -> Result<MutexGuard<'_, Mmds>, MmdsConfigError>
pub fn locked_mmds_or_default( &mut self, ) -> Result<MutexGuard<'_, Mmds>, MmdsConfigError>
If not initialised, create the mmds data store with the default config.
Sourcepub fn set_custom_cpu_template(&mut self, cpu_template: CustomCpuTemplate)
pub fn set_custom_cpu_template(&mut self, cpu_template: CustomCpuTemplate)
Add a custom CPU template to the VM resources to configure vCPUs.
Sourcepub fn update_machine_config(
&mut self,
update: &MachineConfigUpdate,
) -> Result<(), MachineConfigError>
pub fn update_machine_config( &mut self, update: &MachineConfigUpdate, ) -> Result<(), MachineConfigError>
Updates the configuration of the microVM.
Sourcepub fn set_balloon_device(
&mut self,
config: BalloonDeviceConfig,
) -> Result<(), BalloonConfigError>
pub fn set_balloon_device( &mut self, config: BalloonDeviceConfig, ) -> Result<(), BalloonConfigError>
Sets a balloon device to be attached when the VM starts.
Sourcepub fn build_boot_source(
&mut self,
boot_source_cfg: BootSourceConfig,
) -> Result<(), BootSourceConfigError>
pub fn build_boot_source( &mut self, boot_source_cfg: BootSourceConfig, ) -> Result<(), BootSourceConfigError>
Obtains the boot source hooks (kernel fd, command line creation and validation).
Sourcepub fn set_block_device(
&mut self,
block_device_config: BlockDeviceConfig,
) -> Result<(), DriveError>
pub fn set_block_device( &mut self, block_device_config: BlockDeviceConfig, ) -> Result<(), DriveError>
Inserts a block to be attached when the VM starts.
Sourcepub fn build_net_device(
&mut self,
body: NetworkInterfaceConfig,
) -> Result<(), NetworkInterfaceError>
pub fn build_net_device( &mut self, body: NetworkInterfaceConfig, ) -> Result<(), NetworkInterfaceError>
Builds a network device to be attached when the VM starts.
Sourcepub fn set_vsock_device(
&mut self,
config: VsockDeviceConfig,
) -> Result<(), VsockConfigError>
pub fn set_vsock_device( &mut self, config: VsockDeviceConfig, ) -> Result<(), VsockConfigError>
Sets a vsock device to be attached when the VM starts.
Sourcepub fn build_entropy_device(
&mut self,
body: EntropyDeviceConfig,
) -> Result<(), EntropyDeviceError>
pub fn build_entropy_device( &mut self, body: EntropyDeviceConfig, ) -> Result<(), EntropyDeviceError>
Builds an entropy device to be attached when the VM starts.
Sourcepub fn build_pmem_device(
&mut self,
body: PmemConfig,
) -> Result<(), PmemConfigError>
pub fn build_pmem_device( &mut self, body: PmemConfig, ) -> Result<(), PmemConfigError>
Builds a pmem device to be attached when the VM starts.
Sourcepub fn set_memory_hotplug_config(
&mut self,
config: MemoryHotplugConfig,
) -> Result<(), MemoryHotplugConfigError>
pub fn set_memory_hotplug_config( &mut self, config: MemoryHotplugConfig, ) -> Result<(), MemoryHotplugConfigError>
Sets the memory hotplug configuration.
Sourcepub fn set_mmds_config(
&mut self,
config: MmdsConfig,
instance_id: &str,
) -> Result<(), MmdsConfigError>
pub fn set_mmds_config( &mut self, config: MmdsConfig, instance_id: &str, ) -> Result<(), MmdsConfigError>
Setter for mmds config.
Sourcepub fn set_mmds_basic_config(
&mut self,
version: MmdsVersion,
imds_compat: bool,
instance_id: &str,
) -> Result<(), MmdsConfigError>
pub fn set_mmds_basic_config( &mut self, version: MmdsVersion, imds_compat: bool, instance_id: &str, ) -> Result<(), MmdsConfigError>
Updates MMDS-related config other than MMDS network stack.
Sourcepub fn allocate_guest_memory(&self) -> Result<Vec<GuestRegionMmap>, MemoryError>
pub fn allocate_guest_memory(&self) -> Result<Vec<GuestRegionMmap>, MemoryError>
Allocates guest memory in a configuration most appropriate for these VmResources.
Sourcepub fn allocate_memory_region(
&self,
start: GuestAddress,
size: usize,
) -> Result<GuestRegionMmap, MemoryError>
pub fn allocate_memory_region( &self, start: GuestAddress, size: usize, ) -> Result<GuestRegionMmap, MemoryError>
Allocates a single guest memory region.
Trait Implementations§
Source§impl Debug for VmResources
impl Debug for VmResources
Source§impl Default for VmResources
impl Default for VmResources
Source§fn default() -> VmResources
fn default() -> VmResources
Source§impl From<&VmResources> for VmInfo
impl From<&VmResources> for VmInfo
Source§fn from(value: &VmResources) -> Self
fn from(value: &VmResources) -> Self
Source§impl From<&VmResources> for VmmConfig
impl From<&VmResources> for VmmConfig
Source§fn from(resources: &VmResources) -> Self
fn from(resources: &VmResources) -> Self
Source§impl From<MockVmResources> for VmResources
impl From<MockVmResources> for VmResources
Source§fn from(src: MockVmResources) -> VmResources
fn from(src: MockVmResources) -> VmResources
Auto Trait Implementations§
impl Freeze for VmResources
impl RefUnwindSafe for VmResources
impl Send for VmResources
impl Sync for VmResources
impl Unpin for VmResources
impl UnwindSafe for VmResources
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.