vmm: restore KVM clock before resuming vCPUs

Reorder resume() to: set_clock, device_manager.resume,
cpu_manager.resume. This matches the inverse of pause()
which correctly saves the clock before pausing vCPUs.

Signed-off-by: CMGS <ilskdw@gmail.com>
This commit is contained in:
CMGS
2026-03-31 06:12:21 +00:00
committed by Rob Bradford
parent c52e151439
commit ff20f18364

View File

@@ -3111,7 +3111,8 @@ impl Pausable for Vm {
.valid_transition(new_state)
.map_err(|e| MigratableError::Resume(anyhow!("Invalid transition: {e:?}")))?;
self.cpu_manager.lock().unwrap().resume()?;
// Restore KVM clock BEFORE vCPUs start running, so they see correct
// TSC/kvmclock from the first instruction after resume.
#[cfg(target_arch = "x86_64")]
{
if let Some(clock) = &self.saved_clock {
@@ -3128,6 +3129,7 @@ impl Pausable for Vm {
}
self.device_manager.lock().unwrap().resume()?;
self.cpu_manager.lock().unwrap().resume()?;
// And we're back to the Running state.
self.state = new_state;