mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
pci: Remove ioeventfds() from PciDevice trait
The PciDevice trait is supposed to describe only functions related to PCI. The specific method ioeventfds() has nothing to do with PCI, but instead would be more specific to virtio transport devices. This commit removes the ioeventfds() method from the PciDevice trait, adding some convenient helper as_any() to retrieve the Any trait from the structure behing the PciDevice trait. This is the only way to keep calling into ioeventfds() function from VirtioPciDevice, so that we can still properly reprogram the PCI BAR. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
3be95dbf93
commit
de21c9ba4f
@@ -14,6 +14,7 @@ extern crate vm_memory;
|
||||
extern crate vmm_sys_util;
|
||||
|
||||
use libc::EFD_NONBLOCK;
|
||||
use std::any::Any;
|
||||
use std::sync::atomic::{AtomicU16, AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
|
||||
@@ -361,6 +362,22 @@ impl VirtioPciDevice {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ioeventfds(&self) -> Vec<(&EventFd, u64, u64)> {
|
||||
let bar0 = self.configuration.get_bar_addr(self.settings_bar as usize);
|
||||
let notify_base = bar0 + NOTIFICATION_BAR_OFFSET;
|
||||
self.queue_evts()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, event)| {
|
||||
(
|
||||
event,
|
||||
notify_base + i as u64 * u64::from(NOTIFY_OFF_MULTIPLIER),
|
||||
i as u64,
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn add_pci_capabilities(
|
||||
&mut self,
|
||||
settings_bar: u8,
|
||||
@@ -528,22 +545,6 @@ impl PciDevice for VirtioPciDevice {
|
||||
self.configuration.detect_bar_reprogramming(reg_idx, data)
|
||||
}
|
||||
|
||||
fn ioeventfds(&self) -> Vec<(&EventFd, u64, u64)> {
|
||||
let bar0 = self.configuration.get_bar_addr(self.settings_bar as usize);
|
||||
let notify_base = bar0 + NOTIFICATION_BAR_OFFSET;
|
||||
self.queue_evts()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, event)| {
|
||||
(
|
||||
event,
|
||||
notify_base + i as u64 * u64::from(NOTIFY_OFF_MULTIPLIER),
|
||||
i as u64,
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn allocate_bars(
|
||||
&mut self,
|
||||
allocator: &mut SystemAllocator,
|
||||
@@ -733,6 +734,10 @@ impl PciDevice for VirtioPciDevice {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn as_any(&mut self) -> &mut dyn Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl BusDevice for VirtioPciDevice {
|
||||
|
||||
Reference in New Issue
Block a user