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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DeviceCtx
impl !UnwindSafe for DeviceCtx
impl Freeze for DeviceCtx
impl Send for DeviceCtx
impl Sync for DeviceCtx
impl Unpin for DeviceCtx
impl UnsafeUnpin for DeviceCtx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more