mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
pci, vmm: Include VFIO devices in device tree
Fixes: #1687 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
ba71390d6a
commit
593a958fe5
@ -221,9 +221,9 @@ impl Interrupt {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct MmioRegion {
|
||||
start: GuestAddress,
|
||||
length: GuestUsize,
|
||||
pub struct MmioRegion {
|
||||
pub start: GuestAddress,
|
||||
pub length: GuestUsize,
|
||||
type_: PciBarRegionType,
|
||||
index: u32,
|
||||
mem_slot: Option<u32>,
|
||||
@ -615,6 +615,10 @@ impl VfioPciDevice {
|
||||
.extend_dma_map(new_region)
|
||||
.map_err(VfioPciError::UpdateMemory)
|
||||
}
|
||||
|
||||
pub fn mmio_regions(&self) -> Vec<MmioRegion> {
|
||||
self.mmio_regions.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for VfioPciDevice {
|
||||
|
@ -2539,6 +2539,15 @@ impl DeviceManager {
|
||||
})
|
||||
.map_err(DeviceManagerError::VfioMapRegion)?;
|
||||
|
||||
let mut node = device_node!(vfio_name);
|
||||
|
||||
for region in vfio_pci_device.mmio_regions() {
|
||||
node.resources.push(Resource::MmioAddressRange {
|
||||
base: region.start.0,
|
||||
size: region.length as u64,
|
||||
});
|
||||
}
|
||||
|
||||
let vfio_pci_device = Arc::new(Mutex::new(vfio_pci_device));
|
||||
|
||||
self.add_pci_device(
|
||||
@ -2549,6 +2558,10 @@ impl DeviceManager {
|
||||
pci_device_bdf,
|
||||
vfio_name.clone(),
|
||||
)?;
|
||||
self.device_tree
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(vfio_name.clone(), node);
|
||||
|
||||
Ok((pci_device_bdf, vfio_name))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user