WatchRegisterCallback

Type Alias WatchRegisterCallback 

Source
pub type WatchRegisterCallback = Arc<dyn Fn(&str) -> Result<(), String> + Send + Sync + 'static>;
Expand description

Closure type the bridge invokes to register a hardware-watchpoint snapshot.

This callback is the host-side unit-testing seam — it lets in-process executor tests record the symbol and return without arming any hardware. In a booted VM the bridge’s register_watch is not installed; the in-guest Op::WatchSnapshot arm rings an SHM doorbell and the host’s freeze coordinator runs arm_user_watchpoint (src/vmm/freeze_coord/mod.rs), which resolves the symbol via a verbatim match against the vmlinux ELF symtab, allocates a free user watchpoint slot (3 user slots are available; slot 0 is reserved for the existing *scx_root->exit_kind trigger), and arms the hardware watchpoint via KVM_SET_GUEST_DEBUG.

Once armed, the capture tagged with the symbol fires on every guest write without any further userspace round-trip — the debug exit dispatches into the freeze coordinator directly, mirroring the existing reserved-slot path the error-class trigger already uses.

Returns Err(reason) when:

  • The symbol does not match any vmlinux ELF symtab entry (typo, symbol stripped from the build, or a non-ELF kernel image).
  • The resolved KVA is not 4-byte aligned (the 4-byte watch length the framework arms requires addr & 0x3 == 0 on every supported architecture).
  • All three available user watchpoint slots are already allocated.
  • KVM_SET_GUEST_DEBUG rejected the arm (host kernel limitation).

Aliased Type§

pub struct WatchRegisterCallback { /* private fields */ }