Skip to content

Commit ce3c8fd

Browse files
committed
metrics: add metric for KVM_KVMCLOCK_CTRL ioctl failures
Add a metric that counts KVM_KVMCLOCK_CTRL ioctl call failures. These failures might happen because the guest simply doesn't use the KVM clock, but we still it doesn't hurt tracking this. Signed-off-by: Babis Chalios <[email protected]>
1 parent a3fa5d6 commit ce3c8fd

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/vmm/src/logger/metrics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@ pub struct VcpuMetrics {
779779
pub exit_mmio_write: SharedIncMetric,
780780
/// Number of errors during this VCPU's run.
781781
pub failures: SharedIncMetric,
782+
/// Number of times that the `KVM_KVMCLOCK_CTRL` ioctl failed.
783+
pub kvmclock_ctrl_fails: SharedIncMetric,
782784
/// Provides Min/max/sum for KVM exits handling input IO.
783785
pub exit_io_in_agg: LatencyAggregateMetrics,
784786
/// Provides Min/max/sum for KVM exits handling output IO.
@@ -797,6 +799,7 @@ impl VcpuMetrics {
797799
exit_mmio_read: SharedIncMetric::new(),
798800
exit_mmio_write: SharedIncMetric::new(),
799801
failures: SharedIncMetric::new(),
802+
kvmclock_ctrl_fails: SharedIncMetric::new(),
800803
exit_io_in_agg: LatencyAggregateMetrics::new(),
801804
exit_io_out_agg: LatencyAggregateMetrics::new(),
802805
exit_mmio_read_agg: LatencyAggregateMetrics::new(),

src/vmm/src/vstate/vcpu/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,9 @@ impl Vcpu {
340340
// does not panic on resume, see https://docs.kernel.org/virt/kvm/api.html .
341341
// We do not want to fail if the call is not successful, because depending
342342
// that may be acceptable depending on the workload.
343-
// TODO: add a metric
344343
#[cfg(target_arch = "x86_64")]
345344
if let Err(err) = self.kvm_vcpu.fd.kvmclock_ctrl() {
345+
METRICS.vcpu.kvmclock_ctrl_fails.inc();
346346
warn!("KVM_KVMCLOCK_CTRL call failed {}", err);
347347
}
348348

0 commit comments

Comments
 (0)