From f893d5a31690711aeed6eaa7e13374122c8c48f2 Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Wed, 11 Sep 2019 15:54:32 -0400 Subject: [PATCH] allow direct access to ioevent and next chain of virtqueue --- rust/src/virtio/virtqueue.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rust/src/virtio/virtqueue.rs b/rust/src/virtio/virtqueue.rs index 9544b42..2b3ccf1 100644 --- a/rust/src/virtio/virtqueue.rs +++ b/rust/src/virtio/virtqueue.rs @@ -1,5 +1,6 @@ use std::sync::atomic::{Ordering, AtomicUsize, AtomicBool}; use std::sync::Arc; +use std::os::unix::io::AsRawFd; use crate::memory::GuestRam; use crate::kvm::Kvm; @@ -64,6 +65,11 @@ impl VirtQueue { } } + pub fn next_chain(&self) -> Option { + self.pop_avail_entry() + .map(|idx| Chain::new(self.memory.clone(), self.clone(), idx, self.vring.size())) + } + pub fn on_each_chain(&self, mut f: F) where F: FnMut(Chain) { loop { @@ -112,6 +118,10 @@ impl VirtQueue { pub fn load_descriptor(&self, idx: u16) -> Option { self.vring.load_descriptor(idx) } + + pub fn ioevent(&self) -> &IoEventFd { + &self.ioeventfd + } } pub struct QueueIter { @@ -141,7 +151,7 @@ impl InterruptLine { fn new(kvm: &Kvm, irq: u8) -> Result> { let irqfd = EventFd::new()?; - kvm.irqfd(irqfd.raw_fd() as u32, irq as u32)?; + kvm.irqfd(irqfd.as_raw_fd() as u32, irq as u32)?; Ok(Arc::new(InterruptLine{ irqfd, isr: AtomicUsize::new(0)