mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 23:41:15 +00:00
vm-virtio: Add notifier to VirtioInterrupt trait
The point is to be able to retrieve directly the event fd related to the interrupt, as this might optimize the way VirtioDevice devices are implemented. For instance, this can be used by vhost-user devices to provide vhost-user backends directly with the event fd triggering the interrupt related to a virtqueue. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
c396baca46
commit
1f029dd2dc
@ -23,6 +23,9 @@ pub trait VirtioInterrupt: Send + Sync {
|
|||||||
int_type: &VirtioInterruptType,
|
int_type: &VirtioInterruptType,
|
||||||
queue: Option<&Queue>,
|
queue: Option<&Queue>,
|
||||||
) -> std::result::Result<(), std::io::Error>;
|
) -> std::result::Result<(), std::io::Error>;
|
||||||
|
fn notifier(&self, _int_type: &VirtioInterruptType, _queue: Option<&Queue>) -> Option<EventFd> {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type VirtioIommuRemapping =
|
pub type VirtioIommuRemapping =
|
||||||
|
@ -517,6 +517,26 @@ impl VirtioInterrupt for VirtioInterruptMsix {
|
|||||||
|
|
||||||
config.irq_routes[vector as usize].irq_fd.write(1)
|
config.irq_routes[vector as usize].irq_fd.write(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn notifier(&self, int_type: &VirtioInterruptType, queue: Option<&Queue>) -> Option<EventFd> {
|
||||||
|
let vector = match int_type {
|
||||||
|
VirtioInterruptType::Config => self.config_vector.load(Ordering::SeqCst),
|
||||||
|
VirtioInterruptType::Queue => {
|
||||||
|
if let Some(q) = queue {
|
||||||
|
q.vector
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(
|
||||||
|
self.msix_config.lock().unwrap().irq_routes[vector as usize]
|
||||||
|
.irq_fd
|
||||||
|
.try_clone()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PciDevice for VirtioPciDevice {
|
impl PciDevice for VirtioPciDevice {
|
||||||
|
Loading…
Reference in New Issue
Block a user