mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-migration: Snapshot should have a unique SnapshotDataSection
There's no reason to carry a HashMap of SnapshotDataSection per Snapshot. And given we now provide at most one SnapshotDataSection per Snapshot, there's no need to keep the id part of the SnapshotDataSection structure. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -4,10 +4,7 @@
|
||||
|
||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||
use crate::coredump::GuestDebuggableError;
|
||||
use crate::{
|
||||
config::VmConfig,
|
||||
vm::{VmSnapshot, VM_SNAPSHOT_ID},
|
||||
};
|
||||
use crate::{config::VmConfig, vm::VmSnapshot};
|
||||
use anyhow::anyhow;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
@@ -71,13 +68,8 @@ pub fn recv_vm_state(source_url: &str) -> std::result::Result<Snapshot, Migratab
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
return serde_json::from_slice(&vm_section.snapshot).map_err(|e| {
|
||||
MigratableError::Restore(anyhow!("Could not deserialize VM snapshot {}", e))
|
||||
});
|
||||
if let Some(snapshot_data) = snapshot.snapshot_data.as_ref() {
|
||||
return snapshot_data.to_state();
|
||||
}
|
||||
|
||||
Err(MigratableError::Restore(anyhow!(
|
||||
|
||||
Reference in New Issue
Block a user