mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Split VM config and VM state for snapshot/restore
In order to allow for human readable output for the VM configuration, we pull it out of the snapshot, which becomes effectively the list of states from the VM. The configuration is stored through a dedicated file in JSON format (not including any binary output). Having the ability to read and modify the VM configuration manually between the snapshot and restore phases makes debugging easier, as well as empowers users for extending the use cases relying on the snapshot/restore feature. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
6717ac0cf2
commit
10676b74dc
@@ -20,7 +20,9 @@ use crate::config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig, UserDeviceConfig,
|
||||
VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::migration::{get_vm_snapshot, recv_vm_snapshot};
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
use crate::migration::get_vm_snapshot;
|
||||
use crate::migration::{recv_vm_config, recv_vm_state};
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
use crate::vm::{Error as VmError, Vm, VmState};
|
||||
use anyhow::anyhow;
|
||||
@@ -443,14 +445,18 @@ impl Vmm {
|
||||
// Safe to unwrap as we checked it was Some(&str).
|
||||
let source_url = source_url.unwrap();
|
||||
|
||||
let snapshot = recv_vm_snapshot(source_url).map_err(VmError::Restore)?;
|
||||
let vm_config = Arc::new(Mutex::new(
|
||||
recv_vm_config(source_url).map_err(VmError::Restore)?,
|
||||
));
|
||||
let snapshot = recv_vm_state(source_url).map_err(VmError::Restore)?;
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
let vm_snapshot = get_vm_snapshot(&snapshot).map_err(VmError::Restore)?;
|
||||
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
self.vm_check_cpuid_compatibility(&vm_snapshot.config, &vm_snapshot.common_cpuid)
|
||||
self.vm_check_cpuid_compatibility(&vm_config, &vm_snapshot.common_cpuid)
|
||||
.map_err(VmError::Restore)?;
|
||||
|
||||
self.vm_config = Some(Arc::clone(&vm_snapshot.config));
|
||||
self.vm_config = Some(Arc::clone(&vm_config));
|
||||
|
||||
let exit_evt = self.exit_evt.try_clone().map_err(VmError::EventFdClone)?;
|
||||
let reset_evt = self.reset_evt.try_clone().map_err(VmError::EventFdClone)?;
|
||||
@@ -461,6 +467,7 @@ impl Vmm {
|
||||
|
||||
let vm = Vm::new_from_snapshot(
|
||||
&snapshot,
|
||||
vm_config,
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
Some(source_url),
|
||||
|
||||
Reference in New Issue
Block a user