Skip to main content

Module tracer

Module tracer 

Source
Expand description

The tracing engine: a session shared by all vCPUs, and one VcpuTracer per vCPU.

The engine does not run the guest. Whoever owns the vCPU (your Rust VMM through crate::kvm::KvmTracer, or QEMU through the interposer) runs it one step at a time and calls VcpuTracer::on_stop each time it stops. on_stop receives the state after the previous step, which is also the state before the next one, so a single register read per step is enough:

  stop k-1          step k            stop k
 ───●────────────[ instruction ]────────●──────▶
    │ pre-state of k                    │ post-state of k
    │ decode, plan accesses,            │ = pre-state of k+1
    │ predict successor                 │ classify step k, emit records

Structs§

FileSink
Writes trace_<vcpu>.raw (MacSim) and vcpu<vcpu>.kvt (extended) into a directory.
MemorySink
Keeps every record in memory, behind a shared handle; handy in tests.
NullSink
Discards everything.
Session
A tracing session: options, output directory, and the state all vCPUs share (breakpoints, global sequence, statistics).
Stats
A snapshot of a session’s counters.
StopAction
What the owner of the vCPU must do before running it again.
Token
Proof that this vCPU holds the serialization token; dropping it passes the token to the next waiting vCPU.
TraceOptions
Everything you can switch on and off.
VcpuTracer
The tracer for one vCPU.

Enums§

Ordering
How steps of different vCPUs are ordered against each other.
StopReason
Why the vCPU stopped.

Constants§

PACING_WINDOW
How many instructions an interrupt window (see TraceOptions::interrupt_pacing) stays open. A few, so that an interrupt pending while the guest briefly has IF = 0 still gets in.

Traits§

StopContext
Services the tracer needs from whoever owns the vCPU, at a stop.
TraceSink
Where a vCPU’s records go.