pub struct StateUnits { /* private fields */ }
Expand description
A set of state units.
Implementations§
Source§impl StateUnits
impl StateUnits
Sourcepub fn inspector(&self) -> StateUnitsInspector
pub fn inspector(&self) -> StateUnitsInspector
Returns an inspector that can be used to inspect the state units while state transitions are in process.
Sourcepub fn add(&self, name: impl Into<Arc<str>>) -> UnitBuilder<'_>
pub fn add(&self, name: impl Into<Arc<str>>) -> UnitBuilder<'_>
Save and restore will use name
as the save ID, so this forms part of
the saved state.
Note that the added unit will not be running after it is built/spawned,
even if the other units are running. Call
StateUnits::start_stopped_units
when finished adding units.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if state units are currently running.
Sourcepub async fn start_stopped_units(&mut self)
pub async fn start_stopped_units(&mut self)
Starts any units that are individually stopped (either because of a call
to StateUnits::stop_subset
or because they were added via
StateUnits::add
while the VM was running.
Does nothing if all units are stopped, via StateUnits::stop
.
Sourcepub async fn stop_subset(
&mut self,
units: impl IntoIterator<Item = &UnitHandle>,
)
pub async fn stop_subset( &mut self, units: impl IntoIterator<Item = &UnitHandle>, )
Stops just the units in units
.
This can be useful, for example, if you need to temporarily stop the virtual processors for a short time without stopping the VM devices (which might itself take too long).
Units within this set will be stopped in reverse dependency order, but other units that have dependencies on the units being stopped will continue running.
Sourcepub async fn force_reset(
&mut self,
units: impl IntoIterator<Item = &UnitHandle>,
) -> Result<(), StateTransitionError>
pub async fn force_reset( &mut self, units: impl IntoIterator<Item = &UnitHandle>, ) -> Result<(), StateTransitionError>
Resets just the units in units
. The units must be stopped, either via
a call to StateUnits::stop
or StateUnits::stop_subset
.
Units within this set will be reset in dependency order, but other units that have dependencies on the units being reset will not be reset. This may cause inconsistencies in VM state depending on the details of the state units being reset, so this must be used with knowledge of the state units.
Panics if the specified units are not stopped.
Sourcepub async fn reset(&mut self) -> Result<(), StateTransitionError>
pub async fn reset(&mut self) -> Result<(), StateTransitionError>
Resets all the state units.
Panics if running.
Sourcepub async fn save(
&mut self,
) -> Result<Vec<SavedStateUnit>, StateTransitionError>
pub async fn save( &mut self, ) -> Result<Vec<SavedStateUnit>, StateTransitionError>
Saves all the state units.
Panics if running.
Sourcepub async fn restore(
&mut self,
states: Vec<SavedStateUnit>,
) -> Result<(), StateTransitionError>
pub async fn restore( &mut self, states: Vec<SavedStateUnit>, ) -> Result<(), StateTransitionError>
Restores all the state units.
Panics if running.