mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
virtio-devices: make ioeventfds() return an iterator
MSHV's SEV-SNP implementation calls ioeventfds whenever there is an event. This change removes the need frequent allocation and deallocation of a vector, while at the same time makes sure other call sites are unaffected. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
d2e798944a
commit
a1af4238ae
@ -9,5 +9,5 @@ pub use pci_common_config::{VirtioPciCommonConfig, VIRTIO_PCI_COMMON_CONFIG_ID};
|
||||
pub use pci_device::{VirtioPciDevice, VirtioPciDeviceActivator, VirtioPciDeviceError};
|
||||
|
||||
pub trait VirtioTransport {
|
||||
fn ioeventfds(&self, base_addr: u64) -> Vec<(&EventFd, u64)>;
|
||||
fn ioeventfds(&self, base_addr: u64) -> impl Iterator<Item = (&EventFd, u64)>;
|
||||
}
|
||||
|
@ -830,18 +830,14 @@ impl VirtioPciDevice {
|
||||
}
|
||||
|
||||
impl VirtioTransport for VirtioPciDevice {
|
||||
fn ioeventfds(&self, base_addr: u64) -> Vec<(&EventFd, u64)> {
|
||||
fn ioeventfds(&self, base_addr: u64) -> impl Iterator<Item = (&EventFd, u64)> {
|
||||
let notify_base = base_addr + NOTIFICATION_BAR_OFFSET;
|
||||
self.queue_evts()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, event)| {
|
||||
(
|
||||
event,
|
||||
notify_base + i as u64 * u64::from(NOTIFY_OFF_MULTIPLIER),
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
self.queue_evts().iter().enumerate().map(move |(i, event)| {
|
||||
(
|
||||
event,
|
||||
notify_base + i as u64 * u64::from(NOTIFY_OFF_MULTIPLIER),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user