mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-04 04:25:45 +00:00
vmm: Restore clock from Vm creation (x86_64 only)
This allows the clock restoration to be moved out of the dedicated restore function, which will eventually be removed. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
a6959a7469
commit
bccfa81368
@ -28,6 +28,8 @@ use crate::gdb::{Debuggable, DebuggableError, GdbRequestPayload, GdbResponsePayl
|
|||||||
use crate::memory_manager::{
|
use crate::memory_manager::{
|
||||||
Error as MemoryManagerError, MemoryManager, MemoryManagerSnapshotData,
|
Error as MemoryManagerError, MemoryManager, MemoryManagerSnapshotData,
|
||||||
};
|
};
|
||||||
|
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||||
|
use crate::migration::get_vm_snapshot;
|
||||||
#[cfg(feature = "guest_debug")]
|
#[cfg(feature = "guest_debug")]
|
||||||
use crate::migration::url_to_file;
|
use crate::migration::url_to_file;
|
||||||
use crate::migration::{url_to_path, SNAPSHOT_CONFIG_FILE, SNAPSHOT_STATE_FILE};
|
use crate::migration::{url_to_path, SNAPSHOT_CONFIG_FILE, SNAPSHOT_STATE_FILE};
|
||||||
@ -595,6 +597,14 @@ impl Vm {
|
|||||||
.transpose()
|
.transpose()
|
||||||
.map_err(Error::InitramfsFile)?;
|
.map_err(Error::InitramfsFile)?;
|
||||||
|
|
||||||
|
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||||
|
let saved_clock = if let Some(snapshot) = snapshot.as_ref() {
|
||||||
|
let vm_snapshot = get_vm_snapshot(snapshot).map_err(Error::Restore)?;
|
||||||
|
vm_snapshot.clock
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
Ok(Vm {
|
Ok(Vm {
|
||||||
#[cfg(feature = "tdx")]
|
#[cfg(feature = "tdx")]
|
||||||
kernel,
|
kernel,
|
||||||
@ -609,7 +619,7 @@ impl Vm {
|
|||||||
memory_manager,
|
memory_manager,
|
||||||
vm,
|
vm,
|
||||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||||
saved_clock: None,
|
saved_clock,
|
||||||
numa_nodes,
|
numa_nodes,
|
||||||
seccomp_action: seccomp_action.clone(),
|
seccomp_action: seccomp_action.clone(),
|
||||||
exit_evt,
|
exit_evt,
|
||||||
@ -2159,18 +2169,6 @@ impl Vm {
|
|||||||
.map(|state| *state)
|
.map(|state| *state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load saved clock from snapshot
|
|
||||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
|
||||||
pub fn load_clock_from_snapshot(
|
|
||||||
&mut self,
|
|
||||||
snapshot: &Snapshot,
|
|
||||||
) -> Result<Option<hypervisor::ClockData>> {
|
|
||||||
use crate::migration::get_vm_snapshot;
|
|
||||||
let vm_snapshot = get_vm_snapshot(snapshot).map_err(Error::Restore)?;
|
|
||||||
self.saved_clock = vm_snapshot.clock;
|
|
||||||
Ok(self.saved_clock)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
/// Add the vGIC section to the VM snapshot.
|
/// Add the vGIC section to the VM snapshot.
|
||||||
fn add_vgic_snapshot_section(
|
fn add_vgic_snapshot_section(
|
||||||
@ -2621,10 +2619,6 @@ impl Snapshottable for Vm {
|
|||||||
MigratableError::Restore(anyhow!("Could not restore VM state: {:#?}", e))
|
MigratableError::Restore(anyhow!("Could not restore VM state: {:#?}", e))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
|
||||||
self.load_clock_from_snapshot(&_snapshot)
|
|
||||||
.map_err(|e| MigratableError::Restore(anyhow!("Error restoring clock: {:?}", e)))?;
|
|
||||||
|
|
||||||
self.device_manager
|
self.device_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user