Trait vmcore::device_state::ChangeDeviceState
source · pub trait ChangeDeviceState {
// Required methods
fn start(&mut self);
fn stop(&mut self) -> impl Send + Future<Output = ()>;
fn reset(&mut self) -> impl Send + Future<Output = ()>;
}
Expand description
Trait for transitioning device state.
Required Methods§
sourcefn start(&mut self)
fn start(&mut self)
Starts a device, allowing it to interact with the guest asynchronously.
For example, a device might process work queues that reside in guest memory on a separate thread.
Callers must ensure that the device is in a stopped state before calling this method.
This is a synchronous method instead of an asynchronous one because it is a notification only–callers do not need to wait for the device to finish starting to consider the VM started. Devices should kick off any tasks that need to run any return, without waiting.
sourcefn stop(&mut self) -> impl Send + Future<Output = ()>
fn stop(&mut self) -> impl Send + Future<Output = ()>
Stops a device’s asynchronous work.
After this returns, the device must not process any additional work. It should be in a stable state where it can be saved without losing data (if it implements the appropriate trait).
Callers must ensure that the device is in a started state before calling this method.