VmEngine

Trait VmEngine 

Source
pub trait VmEngine:
    Send
    + Sync
    + Debug
    + Network
    + Storage {
Show 13 methods // Required methods fn init(&self) -> Result<()>; fn check_feat(&self, feat_wanted: &[VmEngineFeat]) -> Result<bool>; fn start_vm(&self, vm: &mut Vm) -> Result<()>; fn stop_vm(&self, vm: &mut Vm) -> Result<()>; fn update_vm(&mut self, vm: Vm) -> Result<()>; fn cache_meta(&self, vm: &Vm) -> Result<PathBuf>; fn gen_vm_from_meta(&self, path: &Path) -> Result<Vm>; // Provided methods fn create_vm(&self, vm: &mut Vm) -> Result<()> { ... } fn destroy_vm(&self, vm: &mut Vm) -> Result<()> { ... } fn rm_meta(&self, vm: &mut Vm, path: &Path) -> Result<()> { ... } fn create_snapshot( &self, vm: &mut Vm, name: &str, life_time: Option<u64>, ) -> Result<()> { ... } fn destroy_snapshot(&self, vm: &mut Vm, name: &str) -> Result<()> { ... } fn apply_snapshot(&mut self, vm: &mut Vm, name: &str) -> Result<()> { ... }
}
Expand description

Common methods for each engine, such as ‘Firecracker’, ‘Qemu’, ‘Docker’ …

Required Methods§

Source

fn init(&self) -> Result<()>

Will be called once during system starting.

Source

fn check_feat(&self, feat_wanted: &[VmEngineFeat]) -> Result<bool>

Check if all features the client wanted can be supported.

Source

fn start_vm(&self, vm: &mut Vm) -> Result<()>

Start a stopped VM.

Source

fn stop_vm(&self, vm: &mut Vm) -> Result<()>

Stop(aka pause) a running VM.

Source

fn update_vm(&mut self, vm: Vm) -> Result<()>

Use the new Vm instead of the old one, apply all configs in the new Vm.

Source

fn cache_meta(&self, vm: &Vm) -> Result<PathBuf>

Cache all infomations of the ‘Vm’ to disk.

Source

fn gen_vm_from_meta(&self, path: &Path) -> Result<Vm>

Restruct a Vm from a cached config.

Provided Methods§

Source

fn create_vm(&self, vm: &mut Vm) -> Result<()>

Create the VM instance, and update necessary data of the Vm.

Source

fn destroy_vm(&self, vm: &mut Vm) -> Result<()>

Destroy the VM instance, and update necessary data of the Vm.

Source

fn rm_meta(&self, vm: &mut Vm, path: &Path) -> Result<()>

Remove a cached config of Vm.

Source

fn create_snapshot( &self, vm: &mut Vm, name: &str, life_time: Option<u64>, ) -> Result<()>

Add a snapshot for the runtime image:

  1. stop the runtime instance
  2. cache current meta-config
  3. snapshot storage
  4. restart the runtime instance
Source

fn destroy_snapshot(&self, vm: &mut Vm, name: &str) -> Result<()>

Delete a snapshot of the runtime image:

  1. remove the storage of snapshot
  2. remove the cached-meta of snapshot
Source

fn apply_snapshot(&mut self, vm: &mut Vm, name: &str) -> Result<()>

Revert to the state of this snapshot:

  1. stop the runtime instance
  2. relink runtime image to the one in snapshot
  3. restore the responding Vm from cached-meta
  4. restart the runtime instance

Implementors§