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§
Sourcefn check_feat(&self, feat_wanted: &[VmEngineFeat]) -> Result<bool>
fn check_feat(&self, feat_wanted: &[VmEngineFeat]) -> Result<bool>
Check if all features the client wanted can be supported.
Sourcefn update_vm(&mut self, vm: Vm) -> Result<()>
fn update_vm(&mut self, vm: Vm) -> Result<()>
Use the new Vm instead of the old one,
apply all configs in the new Vm.
Sourcefn cache_meta(&self, vm: &Vm) -> Result<PathBuf>
fn cache_meta(&self, vm: &Vm) -> Result<PathBuf>
Cache all infomations of the ‘Vm’ to disk.
Sourcefn gen_vm_from_meta(&self, path: &Path) -> Result<Vm>
fn gen_vm_from_meta(&self, path: &Path) -> Result<Vm>
Restruct a Vm from a cached config.
Provided Methods§
Sourcefn create_vm(&self, vm: &mut Vm) -> Result<()>
fn create_vm(&self, vm: &mut Vm) -> Result<()>
Create the VM instance, and update necessary data of the Vm.
Sourcefn destroy_vm(&self, vm: &mut Vm) -> Result<()>
fn destroy_vm(&self, vm: &mut Vm) -> Result<()>
Destroy the VM instance, and update necessary data of the Vm.
Sourcefn create_snapshot(
&self,
vm: &mut Vm,
name: &str,
life_time: Option<u64>,
) -> Result<()>
fn create_snapshot( &self, vm: &mut Vm, name: &str, life_time: Option<u64>, ) -> Result<()>
Add a snapshot for the runtime image:
- stop the runtime instance
- cache current meta-config
- snapshot storage
- restart the runtime instance