vmm: Get and set clock during pause and resume operations

In order to maintain correct time when doing pause/resume and
snapshot/restore operations, this patch stores the clock value
on pause, and restore it on resume. Because snapshot/restore
expects a VM to be paused before the snapshot and paused after
the restore, this covers the migration use case too.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-06-23 11:39:39 +02:00
committed by Rob Bradford
parent 68ec0eb7a8
commit 8038161861
3 changed files with 52 additions and 21 deletions

View File

@@ -2,13 +2,11 @@
//
// SPDX-License-Identifier: Apache-2.0
use crate::config::VmConfig;
use crate::vm::{VmSnapshot, VM_SNAPSHOT_ID};
use anyhow::anyhow;
use std::fs::File;
use std::io::BufReader;
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use url::Url;
use vm_migration::{MigratableError, Snapshot};
@@ -63,19 +61,14 @@ pub fn recv_vm_snapshot(source_url: &str) -> std::result::Result<Snapshot, Migra
}
}
pub fn vm_config_from_snapshot(
snapshot: &Snapshot,
) -> std::result::Result<Arc<Mutex<VmConfig>>, MigratableError> {
pub fn get_vm_snapshot(snapshot: &Snapshot) -> std::result::Result<VmSnapshot, MigratableError> {
if let Some(vm_section) = snapshot
.snapshot_data
.get(&format!("{}-section", VM_SNAPSHOT_ID))
{
let vm_snapshot: VmSnapshot =
serde_json::from_slice(&vm_section.snapshot).map_err(|e| {
MigratableError::Restore(anyhow!("Could not deserialize VM snapshot {}", e))
})?;
return Ok(vm_snapshot.config);
return serde_json::from_slice(&vm_section.snapshot).map_err(|e| {
MigratableError::Restore(anyhow!("Could not deserialize VM snapshot {}", e))
});
}
Err(MigratableError::Restore(anyhow!(