You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Emit KVM binary stats (KVM_GET_STATS_FD) per vCPU as part of metrics #6288
When a VM is slow, we want to know where its vCPUs spent their time: running guest code, exiting to KVM, halted, or halt-polling. KVM counts this per vCPU and, since Linux 5.14, exposes it through binary stats (KVM_GET_STATS_FD), including histograms such as halt_wait_hist. Firecracker's metrics only cover the exits that reach Firecracker itself (vcpu.exit_mmio_*, vcpu.exit_io_*).
Describe the desired solution
An opt-in metrics config field, next to emit_id and properties:
Firecracker opens the stats descriptors for the VM and each vCPU when the vCPUs are created, re-reads them before each metrics write, and emits them as kvm_stats:
Before Linux 5.14: logs a warning once and leaves the field out.
The descriptors are opened before the VMM thread's seccomp filter is installed; reading them needs pread64 in that filter.
Firecracker already owns the VM and vCPU fds, so this needs no extra privilege.
We have a working implementation and are happy to open a PR if this approach sounds good.
Describe possible alternatives
Today, the only routes are from outside the process: debugfs (needs root, sums over vCPUs, no full histograms), or opening the descriptors through ptrace-attach access to the Firecracker process.
Alternatively, we can have a new request/response endpoint instead of the metrics, like QEMU's query-stats or Firecracker's GET /balloon/statistics. That keeps the metrics schema fixed, but callers would have to query this separately.
Additional context
This follows QEMU, which exposes the same stats through QMP since 7.1 (query-stats, targets vm and vcpu, provider kvm; qapi/stats.json): the full set KVM reports, as running totals, with names defined by the kernel rather than a fixed list. libvirt exposes them as virsh domstats --vm and per vCPU (vcpu.<n>.<name>) since 8.9.0.
Checks
Have you searched the Firecracker Issues database for similar requests?
Have you read all the existing relevant Firecracker documentation?
Have you read and understood Firecracker's core tenets?
Thanks for the feature request. This sounds like something we would be interested in taking. If you have a PR out for it, it would be great to see your implementation. I'll need to have a think regarding the API surface, whether we want to emit w/ other metrics or to have a separate query endpoint. In my head, I'm favouring a separate endpoint, but happy to see how it looks with your current implementation.
Activity
JamesC1305 commentedon Oct 21, 2026
Hey @lisasgoh,
Thanks for the feature request. This sounds like something we would be interested in taking. If you have a PR out for it, it would be great to see your implementation. I'll need to have a think regarding the API surface, whether we want to emit w/ other metrics or to have a separate query endpoint. In my head, I'm favouring a separate endpoint, but happy to see how it looks with your current implementation.