Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] fix(vmm): call KVMCLOCK_CTRL when pausing #4460

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions resources/seccomp/x86_64-unknown-linux-musl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,18 @@
}
]
},
{
"syscall": "ioctl",
"args": [
{
"index": 1,
"type": "dword",
"op": "eq",
"val": 44717,
"comment": "KVM_KVMCLOCK_CTRL"
}
]
},
{
"syscall": "sched_yield",
"comment": "Used by the rust standard library in std::sync::mpmc. Firecracker uses mpsc channels from this module for inter-thread communication"
Expand Down
13 changes: 11 additions & 2 deletions src/vmm/src/vstate/vcpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use std::{fmt, io, thread};
use kvm_bindings::{KVM_SYSTEM_EVENT_RESET, KVM_SYSTEM_EVENT_SHUTDOWN};
use kvm_ioctls::VcpuExit;
use libc::{c_int, c_void, siginfo_t};
#[cfg(target_arch = "x86_64")]
use log::warn;
use log::{error, info};
use seccompiler::{BpfProgram, BpfProgramRef};
use utils::errno;
Expand Down Expand Up @@ -296,8 +298,15 @@ impl Vcpu {
.send(VcpuResponse::Paused)
.expect("vcpu channel unexpectedly closed");

// TODO: we should call `KVM_KVMCLOCK_CTRL` here to make sure
// TODO continued: the guest soft lockup watchdog does not panic on Resume.
// Calling `KVM_KVMCLOCK_CTRL` to make sure the guest softlockup watchdog
// does not panic on resume, see https://docs.kernel.org/virt/kvm/api.html .
// We do not want to fail if the call is not successful, because depending
// that may be acceptable depending on the workload.
// TODO: add a metric
#[cfg(target_arch = "x86_64")]
if let Err(err) = self.kvm_vcpu.fd.kvmclock_ctrl() {
warn!("KVM_KVMCLOCK_CTRL call failed {}", err);
}

// Move to 'paused' state.
state = StateMachine::next(Self::paused);
Expand Down
Loading