From 3fb0a02fa22c9aad749b7e96bc8ed9ee0393bb15 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 20 Apr 2020 15:54:17 +0200 Subject: [PATCH] vm-virtio: Get userspace mappings from VirtioDevice Introduce new getter function to the VirtioDevice trait, as it will allow the caller to retrieve the list of userspace mappings associated with the device. Signed-off-by: Sebastien Boeuf --- vm-virtio/src/device.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vm-virtio/src/device.rs b/vm-virtio/src/device.rs index ab05ef073..f149fafda 100644 --- a/vm-virtio/src/device.rs +++ b/vm-virtio/src/device.rs @@ -34,6 +34,15 @@ pub trait VirtioInterrupt: Send + Sync { pub type VirtioIommuRemapping = Box std::result::Result + Send + Sync>; +#[derive(Clone)] +pub struct UserspaceMapping { + pub host_addr: u64, + pub mem_slot: u32, + pub addr: GuestAddress, + pub len: GuestUsize, + pub mergeable: bool, +} + #[derive(Clone)] pub struct VirtioSharedMemory { pub offset: u64, @@ -120,6 +129,11 @@ pub trait VirtioDevice: Send { fn update_memory(&mut self, _mem: &GuestMemoryMmap) -> std::result::Result<(), Error> { Ok(()) } + + /// Returns the list of userspace mappings associated with this device. + fn userspace_mappings(&self) -> Vec { + Vec::new() + } } /// Trait providing address translation the same way a physical DMA remapping