From 53613319cccc9639880c9b3de340605c097b38f6 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 2 Apr 2020 08:53:32 +0200 Subject: [PATCH] vmm: Enable snapshot feature This connects the dots together, making the request from the user reach the actual implementation for snapshotting the VM. Signed-off-by: Sebastien Boeuf --- vmm/src/lib.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 4ea18cd87..8a8dff1ff 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -29,7 +29,7 @@ use std::path::PathBuf; use std::sync::mpsc::{Receiver, RecvError, SendError, Sender}; use std::sync::{Arc, Mutex}; use std::{result, thread}; -use vm_migration::Pausable; +use vm_migration::{Pausable, Snapshottable, Transportable}; use vmm_sys_util::eventfd::EventFd; pub mod api; @@ -291,8 +291,17 @@ impl Vmm { } } - fn vm_snapshot(&mut self, _destination_url: &str) -> result::Result<(), VmError> { - Ok(()) + fn vm_snapshot(&mut self, destination_url: &str) -> result::Result<(), VmError> { + if let Some(ref mut vm) = self.vm { + vm.snapshot() + .map_err(VmError::Snapshot) + .and_then(|snapshot| { + vm.send(&snapshot, destination_url) + .map_err(VmError::SnapshotSend) + }) + } else { + Err(VmError::VmNotRunning) + } } fn vm_restore(&mut self, _source_url: &str) -> result::Result<(), VmError> {