pub struct DeviceCtx {
pub mem: Arc<GuestMemWriter>,
pub raise_irq: Arc<dyn Fn(u32) + Send + Sync>,
}Expand description
Per-device context shared between the VMM and each VirtioDevice for
accessing guest physical memory and injecting interrupts.
Every device that needs to read descriptors, write completions to
device-owned buffers, or raise a VirtIO used-ring / config-change
interrupt holds a DeviceCtx. Construction happens inside the VMM
at device-registration time, so by the time guest I/O begins both
fields are populated — devices store this by value (no Option).
mem is a shared-lifetime accessor over the single guest RAM mmap.
raise_irq is pre-bound to the device’s GSI and MMIO state; the
only argument is the interrupt reason (INT_VRING = 1 for used-ring
notifications, INT_CONFIG = 2 for config-space changes).
Fields§
§mem: Arc<GuestMemWriter>Guest physical memory accessor.
raise_irq: Arc<dyn Fn(u32) + Send + Sync>Pre-bound interrupt trigger: updates the device’s MMIO
interrupt_status register and then asserts the device’s GSI
on the platform IRQ chip.