virtio-devices: introduce ActivationContext for device activation

Signed-off-by: Peter Oskolkov <posk@google.com>
This commit is contained in:
Peter Oskolkov
2026-03-12 09:50:37 -07:00
committed by Bo Chen
parent ab8169c855
commit f77c6ef78b
30 changed files with 183 additions and 177 deletions

View File

@@ -53,6 +53,12 @@ pub struct VirtioSharedMemoryList {
pub region_list: Vec<VirtioSharedMemory>,
}
pub struct ActivationContext {
pub mem: GuestMemoryAtomic<GuestMemoryMmap>,
pub interrupt_cb: Arc<dyn VirtioInterrupt>,
pub queues: Vec<(usize, Queue, EventFd)>,
}
/// Trait for virtio devices to be driven by a virtio transport.
///
/// The lifecycle of a virtio device is to be moved to a virtio transport, which will then query the
@@ -94,12 +100,7 @@ pub trait VirtioDevice: Send {
}
/// Activates this device for real usage.
fn activate(
&mut self,
mem: GuestMemoryAtomic<GuestMemoryMmap>,
interrupt_evt: Arc<dyn VirtioInterrupt>,
queues: Vec<(usize, Queue, EventFd)>,
) -> ActivateResult;
fn activate(&mut self, context: ActivationContext) -> ActivateResult;
/// Optionally deactivates this device and returns ownership of the guest memory map, interrupt
/// event, and queue events.