mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-12 15:42:57 +00:00
vm-virtio: Extend VirtioDevice trait to retrieve shared memory regions
Based on the newly added SharedMemoryConfig capability to the virtio specification, and based on the fact that it is not tied to the type of transport (pci or mmio), we can create as part of the VirtioDevice trait a new method that will provide the shared memory regions associated with the device. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
d97079d793
commit
e2b38cc050
@ -9,7 +9,7 @@
|
||||
use super::*;
|
||||
use pci::{PciBarConfiguration, PciCapability};
|
||||
use std::sync::Arc;
|
||||
use vm_memory::GuestMemoryMmap;
|
||||
use vm_memory::{GuestAddress, GuestMemoryMmap, GuestUsize};
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
pub enum VirtioInterruptType {
|
||||
@ -23,6 +23,19 @@ pub type VirtioInterrupt = Box<
|
||||
+ Sync,
|
||||
>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct VirtioSharedMemory {
|
||||
pub offset: u64,
|
||||
pub len: u64,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct VirtioSharedMemoryList {
|
||||
pub addr: GuestAddress,
|
||||
pub len: GuestUsize,
|
||||
pub region_list: Vec<VirtioSharedMemory>,
|
||||
}
|
||||
|
||||
/// 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
|
||||
@ -76,4 +89,9 @@ pub trait VirtioDevice: Send {
|
||||
fn get_device_caps(&self) -> Vec<Box<dyn PciCapability>> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// Returns the list of shared memory regions required by the device.
|
||||
fn get_shm_regions(&self) -> Option<VirtioSharedMemoryList> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user