mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: add a generic guest-clock save/restore abstraction
Preserving the guest clock across pause/resume and snapshot/restore is currently open-coded in the VMM against the x86-only get_clock/set_clock. aarch64 needs the same correction but via a different mechanism (i.e. the architected counter, CNTVCT). Having a common backend-agnostic interface that VMM can drive uniformly allows us to keep the architecture details behind the Hypervisor abstraction. This commit only introduces the abstraction while the future commits will actually move the implementation to use it. Use this opportunity to fix the full path to get SystemTime as well. Suggested-by: Sebastien Boeuf <sboeuf@meta.com> Signed-off-by: Atish Patra <atishp@meta.com>
This commit is contained in:
committed by
Rob Bradford
parent
00edf5b34d
commit
d68b93ea93
@@ -78,7 +78,7 @@ pub use {
|
||||
};
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::ClockData;
|
||||
use crate::{ClockData, ClockState};
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use crate::arch::aarch64::gic::{Vgic, VgicConfig};
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
@@ -2200,6 +2200,18 @@ impl vm::Vm for MshvVm {
|
||||
.map_err(|e| vm::HypervisorVmError::SetClock(e.into()))
|
||||
}
|
||||
|
||||
/// Capture the partition reference time for snapshot/migration.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn snapshot_clock(&self) -> vm::Result<Option<ClockState>> {
|
||||
Ok(Some(self.get_clock()?.with_realtime_filled()))
|
||||
}
|
||||
|
||||
/// Restore the partition reference time before the vCPUs resume.
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn restore_clock(&self, state: &ClockState) -> vm::Result<()> {
|
||||
self.set_clock(state)
|
||||
}
|
||||
|
||||
/// Downcast to the underlying MshvVm type
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
|
||||
Reference in New Issue
Block a user