mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-migration: Make snapshot() mutable
There will be some cases where the implementation of the snapshot() function from the Snapshottable trait will require to modify some internal data, therefore we make this possible by updating the trait definition with snapshot(&mut self). Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
7b898285d5
commit
871138d5cc
@@ -400,7 +400,7 @@ impl Snapshottable for Vcpu {
|
||||
VCPU_SNAPSHOT_ID.to_string()
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
let snapshot = serde_json::to_vec(&self.saved_state)
|
||||
.map_err(|e| MigratableError::Snapshot(e.into()))?;
|
||||
|
||||
@@ -1368,7 +1368,7 @@ impl Snapshottable for CpuManager {
|
||||
CPU_MANAGER_SNAPSHOT_ID.to_string()
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
let mut cpu_manager_snapshot = Snapshot::new(CPU_MANAGER_SNAPSHOT_ID);
|
||||
|
||||
// The CpuManager snapshot is a collection of all vCPUs snapshots.
|
||||
|
||||
@@ -3626,7 +3626,7 @@ impl Snapshottable for DeviceManager {
|
||||
DEVICE_MANAGER_SNAPSHOT_ID.to_string()
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
let mut snapshot = Snapshot::new(DEVICE_MANAGER_SNAPSHOT_ID);
|
||||
|
||||
// We aggregate all devices snapshots.
|
||||
|
||||
@@ -1526,7 +1526,7 @@ impl Snapshottable for MemoryManager {
|
||||
MEMORY_MANAGER_SNAPSHOT_ID.to_string()
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> result::Result<Snapshot, MigratableError> {
|
||||
fn snapshot(&mut self) -> result::Result<Snapshot, MigratableError> {
|
||||
if self.use_zones {
|
||||
return Err(MigratableError::Snapshot(anyhow!(
|
||||
"Not allowed to snapshot guest memory when backed with user \
|
||||
|
||||
@@ -1267,7 +1267,7 @@ impl Snapshottable for Vm {
|
||||
VM_SNAPSHOT_ID.to_string()
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
let current_state = self.get_state().unwrap();
|
||||
if current_state != VmState::Paused {
|
||||
return Err(MigratableError::Snapshot(anyhow!(
|
||||
|
||||
Reference in New Issue
Block a user