From 019d6bace72691fca10bfa7c867ce0b300fb1dde Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 22 Jun 2023 15:41:22 -0700 Subject: [PATCH] devices: virtio: remove SignalableInterrupt trait Use the concrete Interrupt type in its place, since Interrupt now works for all virtio and vhost transports. No functional change intended. BUG=b:244204463 TEST=tools/dev_container tools/presubmit Change-Id: Ie08c396b7eee997dfde7ae46a5ab7c728ba3584c Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4639203 Commit-Queue: Daniel Verkamp Reviewed-by: Alexandre Courbot --- devices/src/virtio/async_utils.rs | 1 - devices/src/virtio/balloon.rs | 1 - devices/src/virtio/block/asynchronous.rs | 9 ++-- devices/src/virtio/console.rs | 13 +++--- devices/src/virtio/console/asynchronous.rs | 17 ++++---- devices/src/virtio/fs/worker.rs | 5 +-- devices/src/virtio/gpu/mod.rs | 1 - devices/src/virtio/input/mod.rs | 1 - devices/src/virtio/interrupt.rs | 41 +++++++------------ devices/src/virtio/iommu.rs | 5 +-- devices/src/virtio/mod.rs | 1 - devices/src/virtio/net.rs | 5 +-- devices/src/virtio/net/sys/unix.rs | 10 ++--- devices/src/virtio/net/sys/windows.rs | 10 ++--- devices/src/virtio/p9.rs | 1 - devices/src/virtio/pvclock.rs | 1 - devices/src/virtio/queue.rs | 8 +--- devices/src/virtio/queue/split_queue.rs | 8 +--- devices/src/virtio/rng.rs | 1 - .../virtio/snd/common_backend/async_funcs.rs | 18 ++++---- devices/src/virtio/snd/vios_backend/worker.rs | 1 - devices/src/virtio/tpm.rs | 1 - .../vhost/user/device/net/sys/windows.rs | 1 - devices/src/virtio/vhost/user/device/vsock.rs | 1 - devices/src/virtio/vhost/user/proxy.rs | 1 - devices/src/virtio/vhost/user/vmm/handler.rs | 1 - .../virtio/vhost/user/vmm/handler/worker.rs | 1 - devices/src/virtio/vhost/worker.rs | 1 - devices/src/virtio/video/worker.rs | 14 +++---- devices/src/virtio/vsock/sys/windows/vsock.rs | 1 - devices/src/virtio/wl.rs | 9 ++-- docs/book/src/tracing.md | 8 ++-- 32 files changed, 77 insertions(+), 120 deletions(-) diff --git a/devices/src/virtio/async_utils.rs b/devices/src/virtio/async_utils.rs index 0a15583cd9..757dbb4a99 100644 --- a/devices/src/virtio/async_utils.rs +++ b/devices/src/virtio/async_utils.rs @@ -11,7 +11,6 @@ use cros_async::EventAsync; use cros_async::Executor; use super::Interrupt; -use super::SignalableInterrupt; /// Async task that waits for a signal from `event`. Once this event is readable, exit. Exiting /// this future will cause the main loop to break and the worker thread to exit. diff --git a/devices/src/virtio/balloon.rs b/devices/src/virtio/balloon.rs index 5c57aaa090..3f3ade68c8 100644 --- a/devices/src/virtio/balloon.rs +++ b/devices/src/virtio/balloon.rs @@ -66,7 +66,6 @@ use super::DeviceType; use super::Interrupt; use super::Queue; use super::Reader; -use super::SignalableInterrupt; use super::VirtioDevice; use crate::UnpinRequest; use crate::UnpinResponse; diff --git a/devices/src/virtio/block/asynchronous.rs b/devices/src/virtio/block/asynchronous.rs index c8bbc479a9..0d6a6ea723 100644 --- a/devices/src/virtio/block/asynchronous.rs +++ b/devices/src/virtio/block/asynchronous.rs @@ -85,7 +85,6 @@ use crate::virtio::DeviceType; use crate::virtio::Interrupt; use crate::virtio::Queue; use crate::virtio::Reader; -use crate::virtio::SignalableInterrupt; use crate::virtio::VirtioDevice; use crate::virtio::Writer; @@ -276,12 +275,12 @@ async fn process_one_request( } /// Process one descriptor chain asynchronously. -pub async fn process_one_chain( +pub async fn process_one_chain( queue: &RefCell, mut avail_desc: DescriptorChain, disk_state: &AsyncRwLock, mem: &GuestMemory, - interrupt: &I, + interrupt: &Interrupt, flush_timer: &RefCell>, flush_timer_armed: &RefCell, ) { @@ -303,12 +302,12 @@ pub async fn process_one_chain( // There is one async task running `handle_queue` per virtio queue in use. // Receives messages from the guest and queues a task to complete the operations with the async // executor. -async fn handle_queue( +async fn handle_queue( mem: GuestMemory, disk_state: Rc>, queue: Rc>, evt: EventAsync, - interrupt: I, + interrupt: Interrupt, flush_timer: Rc>>, flush_timer_armed: Rc>, mut stop_rx: oneshot::Receiver<()>, diff --git a/devices/src/virtio/console.rs b/devices/src/virtio/console.rs index e49be68611..b329633ce6 100644 --- a/devices/src/virtio/console.rs +++ b/devices/src/virtio/console.rs @@ -48,7 +48,6 @@ use crate::virtio::DeviceType; use crate::virtio::Interrupt; use crate::virtio::Queue; use crate::virtio::Reader; -use crate::virtio::SignalableInterrupt; use crate::virtio::VirtioDevice; pub(crate) const QUEUE_SIZE: u16 = 256; @@ -79,12 +78,12 @@ pub struct virtio_console_config { /// # Arguments /// /// * `mem` - The GuestMemory to write the data into -/// * `interrupt` - SignalableInterrupt used to signal that the queue has been used +/// * `interrupt` - Interrupt used to signal that the queue has been used /// * `buffer` - Ring buffer providing data to put into the guest /// * `receive_queue` - The receive virtio Queue -fn handle_input( +fn handle_input( mem: &GuestMemory, - interrupt: &I, + interrupt: &Interrupt, buffer: &mut VecDeque, receive_queue: &Arc>, ) -> result::Result<(), ConsoleError> { @@ -142,12 +141,12 @@ fn process_transmit_request(reader: &mut Reader, output: &mut dyn io::Write) -> /// # Arguments /// /// * `mem` - The GuestMemory to take the data from -/// * `interrupt` - SignalableInterrupt used to signal (if required) that the queue has been used +/// * `interrupt` - Interrupt used to signal (if required) that the queue has been used /// * `transmit_queue` - The transmit virtio Queue /// * `output` - The output sink we are going to write the data into -fn process_transmit_queue( +fn process_transmit_queue( mem: &GuestMemory, - interrupt: &I, + interrupt: &Interrupt, transmit_queue: &Arc>, output: &mut dyn io::Write, ) { diff --git a/devices/src/virtio/console/asynchronous.rs b/devices/src/virtio/console/asynchronous.rs index 85a7c1ab38..03efae27f0 100644 --- a/devices/src/virtio/console/asynchronous.rs +++ b/devices/src/virtio/console/asynchronous.rs @@ -43,7 +43,6 @@ use crate::virtio::copy_config; use crate::virtio::DeviceType; use crate::virtio::Interrupt; use crate::virtio::Queue; -use crate::virtio::SignalableInterrupt; use crate::virtio::VirtioDevice; use crate::SerialDevice; @@ -57,10 +56,10 @@ impl AsRawDescriptor for AsyncSerialInput { } impl IntoAsync for AsyncSerialInput {} -async fn run_tx_queue( +async fn run_tx_queue( queue: &Arc>, mem: GuestMemory, - doorbell: I, + doorbell: Interrupt, kick_evt: EventAsync, output: &mut Box, ) { @@ -73,10 +72,10 @@ async fn run_tx_queue( } } -async fn run_rx_queue( +async fn run_rx_queue( queue: &Arc>, mem: GuestMemory, - doorbell: I, + doorbell: Interrupt, kick_evt: EventAsync, input: &IoSource, ) { @@ -126,12 +125,12 @@ impl ConsoleDevice { self.avail_features } - pub fn start_receive_queue( + pub fn start_receive_queue( &mut self, ex: &Executor, mem: GuestMemory, queue: Arc>, - doorbell: I, + doorbell: Interrupt, kick_evt: Event, ) -> anyhow::Result<()> { let input_queue = match self.input.as_mut() { @@ -170,12 +169,12 @@ impl ConsoleDevice { } } - pub fn start_transmit_queue( + pub fn start_transmit_queue( &mut self, ex: &Executor, mem: GuestMemory, queue: Arc>, - doorbell: I, + doorbell: Interrupt, kick_evt: Event, ) -> anyhow::Result<()> { let kick_evt = diff --git a/devices/src/virtio/fs/worker.rs b/devices/src/virtio/fs/worker.rs index 475b9ec3e2..7e9ca7e1eb 100644 --- a/devices/src/virtio/fs/worker.rs +++ b/devices/src/virtio/fs/worker.rs @@ -32,7 +32,6 @@ use crate::virtio::fs::Result; use crate::virtio::Interrupt; use crate::virtio::Queue; use crate::virtio::Reader; -use crate::virtio::SignalableInterrupt; use crate::virtio::Writer; impl fuse::Reader for Reader {} @@ -151,9 +150,9 @@ pub struct Worker { slot: u32, } -pub fn process_fs_queue( +pub fn process_fs_queue( mem: &GuestMemory, - interrupt: &I, + interrupt: &Interrupt, queue: &Rc>, server: &Arc>, tube: &Arc>, diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs index ce6737f0bf..9e6d38922f 100644 --- a/devices/src/virtio/gpu/mod.rs +++ b/devices/src/virtio/gpu/mod.rs @@ -79,7 +79,6 @@ use super::Queue; use super::Reader; use super::SharedMemoryMapper; use super::SharedMemoryRegion; -use super::SignalableInterrupt; use super::VirtioDevice; use super::Writer; diff --git a/devices/src/virtio/input/mod.rs b/devices/src/virtio/input/mod.rs index e8334ed738..1e8945387c 100644 --- a/devices/src/virtio/input/mod.rs +++ b/devices/src/virtio/input/mod.rs @@ -46,7 +46,6 @@ use super::DescriptorChain; use super::DeviceType; use super::Interrupt; use super::Queue; -use super::SignalableInterrupt; use super::VirtioDevice; const EVENT_QUEUE_SIZE: u16 = 64; diff --git a/devices/src/virtio/interrupt.rs b/devices/src/virtio/interrupt.rs index d52556abe7..7d0941f620 100644 --- a/devices/src/virtio/interrupt.rs +++ b/devices/src/virtio/interrupt.rs @@ -19,26 +19,6 @@ use crate::irq_event::IrqEdgeEvent; use crate::irq_event::IrqLevelEvent; use crate::pci::MsixConfig; -pub trait SignalableInterrupt: Clone { - /// Writes to the irqfd to VMM to deliver virtual interrupt to the guest. - fn signal(&self, vector: u16, interrupt_status_mask: u32); - - /// Notify the driver that buffers have been placed in the used queue. - fn signal_used_queue(&self, vector: u16) { - self.signal(vector, INTERRUPT_STATUS_USED_RING) - } - - /// Notify the driver that the device configuration has changed. - fn signal_config_changed(&self); - - /// Get the event to signal resampling is needed if it exists. - fn get_resample_evt(&self) -> Option<&Event>; - - /// Reads the status and writes to the interrupt event. Doesn't read the resample event, it - /// assumes the resample has been requested. - fn do_interrupt_resample(&self); -} - struct TransportPci { irq_evt_lvl: IrqLevelEvent, msix_config: Option>>, @@ -93,12 +73,12 @@ pub struct InterruptSnapshot { interrupt_status: usize, } -impl SignalableInterrupt for Interrupt { - /// Virtqueue Interrupts From The Device +impl Interrupt { + /// Writes to the irqfd to VMM to deliver virtual interrupt to the guest. /// /// If MSI-X is enabled in this device, MSI-X interrupt is preferred. /// Write to the irqfd to VMM to deliver virtual interrupt to the guest - fn signal(&self, vector: u16, interrupt_status_mask: u32) { + pub fn signal(&self, vector: u16, interrupt_status_mask: u32) { match &self.inner.transport { Transport::Pci { pci } => { // Don't need to set ISR for MSI-X interrupts @@ -137,7 +117,13 @@ impl SignalableInterrupt for Interrupt { } } - fn signal_config_changed(&self) { + /// Notify the driver that buffers have been placed in the used queue. + pub fn signal_used_queue(&self, vector: u16) { + self.signal(vector, INTERRUPT_STATUS_USED_RING) + } + + /// Notify the driver that the device configuration has changed. + pub fn signal_config_changed(&self) { let vector = match &self.inner.as_ref().transport { Transport::Pci { pci } => pci.config_msix_vector, _ => VIRTIO_MSI_NO_VECTOR, @@ -145,14 +131,17 @@ impl SignalableInterrupt for Interrupt { self.signal(vector, INTERRUPT_STATUS_CONFIG_CHANGED) } - fn get_resample_evt(&self) -> Option<&Event> { + /// Get the event to signal resampling is needed if it exists. + pub fn get_resample_evt(&self) -> Option<&Event> { match &self.inner.as_ref().transport { Transport::Pci { pci } => Some(pci.irq_evt_lvl.get_resample()), _ => None, } } - fn do_interrupt_resample(&self) { + /// Reads the status and writes to the interrupt event. Doesn't read the resample event, it + /// assumes the resample has been requested. + pub fn do_interrupt_resample(&self) { if self.inner.interrupt_status.load(Ordering::SeqCst) != 0 { match &self.inner.as_ref().transport { Transport::Pci { pci } => pci.irq_evt_lvl.trigger().unwrap(), diff --git a/devices/src/virtio/iommu.rs b/devices/src/virtio/iommu.rs index 05222bb4da..b222d1a92e 100644 --- a/devices/src/virtio/iommu.rs +++ b/devices/src/virtio/iommu.rs @@ -68,7 +68,6 @@ use crate::virtio::DeviceType; use crate::virtio::Interrupt; use crate::virtio::Queue; use crate::virtio::Reader; -use crate::virtio::SignalableInterrupt; use crate::virtio::VirtioDevice; #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] use crate::virtio::Writer; @@ -580,11 +579,11 @@ impl State { } } -async fn request_queue( +async fn request_queue( state: &Rc>, mut queue: Queue, mut queue_event: EventAsync, - interrupt: I, + interrupt: Interrupt, ) -> Result<()> { loop { let mem = state.borrow().mem.clone(); diff --git a/devices/src/virtio/mod.rs b/devices/src/virtio/mod.rs index c24952f6d9..d0b17e9ba3 100644 --- a/devices/src/virtio/mod.rs +++ b/devices/src/virtio/mod.rs @@ -69,7 +69,6 @@ pub use self::gpu::GpuParameters; pub use self::gpu::GpuWsi; pub use self::interrupt::Interrupt; pub use self::interrupt::InterruptSnapshot; -pub use self::interrupt::SignalableInterrupt; pub use self::iommu::ipc_memory_mapper; pub use self::iommu::memory_mapper; pub use self::iommu::memory_util; diff --git a/devices/src/virtio/net.rs b/devices/src/virtio/net.rs index 42e62eaff4..23e34e945f 100644 --- a/devices/src/virtio/net.rs +++ b/devices/src/virtio/net.rs @@ -53,7 +53,6 @@ use super::DeviceType; use super::Interrupt; use super::Queue; use super::Reader; -use super::SignalableInterrupt; use super::VirtioDevice; /// The maximum buffer size when segmentation offload is enabled. This @@ -299,8 +298,8 @@ fn process_ctrl_request( Ok(()) } -pub fn process_ctrl( - interrupt: &I, +pub fn process_ctrl( + interrupt: &Interrupt, ctrl_queue: &Arc>, mem: &GuestMemory, tap: &mut T, diff --git a/devices/src/virtio/net/sys/unix.rs b/devices/src/virtio/net/sys/unix.rs index 34f37f6c80..5f7726c1af 100644 --- a/devices/src/virtio/net/sys/unix.rs +++ b/devices/src/virtio/net/sys/unix.rs @@ -18,11 +18,11 @@ use vm_memory::GuestMemory; use super::super::super::net::NetError; use super::super::super::net::Token; use super::super::super::net::Worker; +use super::super::super::Interrupt; use super::super::super::Queue; -use super::super::super::SignalableInterrupt; -pub fn process_rx( - interrupt: &I, +pub fn process_rx( + interrupt: &Interrupt, rx_queue: &Arc>, mem: &GuestMemory, mut tap: &mut T, @@ -80,8 +80,8 @@ pub fn process_rx( } } -pub fn process_tx( - interrupt: &I, +pub fn process_tx( + interrupt: &Interrupt, tx_queue: &Arc>, mem: &GuestMemory, mut tap: &mut T, diff --git a/devices/src/virtio/net/sys/windows.rs b/devices/src/virtio/net/sys/windows.rs index 11e0d079c6..c641e6ef4e 100644 --- a/devices/src/virtio/net/sys/windows.rs +++ b/devices/src/virtio/net/sys/windows.rs @@ -27,10 +27,10 @@ use super::super::super::net::NetError; use super::super::super::net::Token; use super::super::super::net::Worker; use super::super::super::net::MAX_BUFFER_SIZE; +use super::super::super::Interrupt; use super::super::super::ProtectionType; use super::super::super::Queue; use super::super::super::Reader; -use super::super::super::SignalableInterrupt; // This file should not be included at virtio mod level if slirp is not include. In case it is, // throw a user friendly message. @@ -71,8 +71,8 @@ fn rx_single_frame( true } -pub fn process_rx( - interrupt: &I, +pub fn process_rx( + interrupt: &Interrupt, rx_queue: &Arc>, mem: &GuestMemory, tap: &mut T, @@ -152,8 +152,8 @@ pub fn process_rx( needs_interrupt } -pub fn process_tx( - interrupt: &I, +pub fn process_tx( + interrupt: &Interrupt, tx_queue: &Arc>, mem: &GuestMemory, tap: &mut T, diff --git a/devices/src/virtio/p9.rs b/devices/src/virtio/p9.rs index 99881622c3..cd3d386743 100644 --- a/devices/src/virtio/p9.rs +++ b/devices/src/virtio/p9.rs @@ -25,7 +25,6 @@ use super::copy_config; use super::queue::Queue; use super::DeviceType; use super::Interrupt; -use super::SignalableInterrupt; use super::VirtioDevice; const QUEUE_SIZE: u16 = 128; diff --git a/devices/src/virtio/pvclock.rs b/devices/src/virtio/pvclock.rs index bf731d287d..d1ede21dfe 100644 --- a/devices/src/virtio/pvclock.rs +++ b/devices/src/virtio/pvclock.rs @@ -47,7 +47,6 @@ use super::copy_config; use super::DeviceType; use super::Interrupt; use super::Queue; -use super::SignalableInterrupt; use super::VirtioDevice; // Pvclock has one virtio queue: set_pvclock_page diff --git a/devices/src/virtio/queue.rs b/devices/src/virtio/queue.rs index b7bfd95fa1..5cc44d972c 100644 --- a/devices/src/virtio/queue.rs +++ b/devices/src/virtio/queue.rs @@ -24,7 +24,7 @@ use vm_memory::GuestMemory; use crate::virtio::ipc_memory_mapper::IpcMemoryMapper; use crate::virtio::DescriptorChain; -use crate::virtio::SignalableInterrupt; +use crate::virtio::Interrupt; /// Usage: define_queue_method!(method_name, return_type[, mut][, arg1: arg1_type, arg2: arg2_type, ...]) /// @@ -130,11 +130,7 @@ impl Queue { /// inject interrupt into guest on this queue /// return true: interrupt is injected into guest for this queue /// false: interrupt isn't injected - pub fn trigger_interrupt( - &mut self, - mem: &GuestMemory, - interrupt: &I, - ) -> bool { + pub fn trigger_interrupt(&mut self, mem: &GuestMemory, interrupt: &Interrupt) -> bool { match self { Queue::SplitVirtQueue(sq) => sq.trigger_interrupt(mem, interrupt), } diff --git a/devices/src/virtio/queue/split_queue.rs b/devices/src/virtio/queue/split_queue.rs index b4d5ae3691..d0a9e28ae5 100644 --- a/devices/src/virtio/queue/split_queue.rs +++ b/devices/src/virtio/queue/split_queue.rs @@ -25,7 +25,7 @@ use crate::virtio::ipc_memory_mapper::IpcMemoryMapper; use crate::virtio::memory_util::read_obj_from_addr_wrapper; use crate::virtio::memory_util::write_obj_at_addr_wrapper; use crate::virtio::DescriptorChain; -use crate::virtio::SignalableInterrupt; +use crate::virtio::Interrupt; use crate::virtio::SplitDescriptorChain; use crate::virtio::VIRTIO_MSI_NO_VECTOR; @@ -622,11 +622,7 @@ impl SplitQueue { /// inject interrupt into guest on this queue /// return true: interrupt is injected into guest for this queue /// false: interrupt isn't injected - pub fn trigger_interrupt( - &mut self, - mem: &GuestMemory, - interrupt: &I, - ) -> bool { + pub fn trigger_interrupt(&mut self, mem: &GuestMemory, interrupt: &Interrupt) -> bool { if self.queue_wants_interrupt(mem) { self.last_used = self.next_used; interrupt.signal_used_queue(self.vector); diff --git a/devices/src/virtio/rng.rs b/devices/src/virtio/rng.rs index 23ea73339b..e45df69c5b 100644 --- a/devices/src/virtio/rng.rs +++ b/devices/src/virtio/rng.rs @@ -22,7 +22,6 @@ use vm_memory::GuestMemory; use super::DeviceType; use super::Interrupt; use super::Queue; -use super::SignalableInterrupt; use super::VirtioDevice; const QUEUE_SIZE: u16 = 256; diff --git a/devices/src/virtio/snd/common_backend/async_funcs.rs b/devices/src/virtio/snd/common_backend/async_funcs.rs index 3758d3ccaa..bbad3a71f3 100644 --- a/devices/src/virtio/snd/common_backend/async_funcs.rs +++ b/devices/src/virtio/snd/common_backend/async_funcs.rs @@ -41,9 +41,9 @@ use crate::virtio::snd::common_backend::PcmResponse; use crate::virtio::snd::constants::*; use crate::virtio::snd::layout::*; use crate::virtio::DescriptorChain; +use crate::virtio::Interrupt; use crate::virtio::Queue; use crate::virtio::Reader; -use crate::virtio::SignalableInterrupt; use crate::virtio::Writer; // TODO(b/246601226): Remove once a generic audio_stream solution that can accpet @@ -472,11 +472,11 @@ async fn defer_pcm_response_to_worker( .map_err(Error::MpscSend) } -fn send_pcm_response( +fn send_pcm_response( mut desc_chain: DescriptorChain, mem: &GuestMemory, queue: &mut Queue, - interrupt: &I, + interrupt: &Interrupt, status: virtio_snd_pcm_status, ) -> Result<(), Error> { let writer = &mut desc_chain.writer; @@ -506,10 +506,10 @@ async fn await_reset_signal(reset_signal_option: Option<&(AsyncRwLock, Con }; } -pub async fn send_pcm_response_worker( +pub async fn send_pcm_response_worker( mem: &GuestMemory, queue: Rc>, - interrupt: I, + interrupt: Interrupt, recv: &mut mpsc::UnboundedReceiver, reset_signal: Option<&(AsyncRwLock, Condvar)>, ) -> Result<(), Error> { @@ -631,14 +631,14 @@ pub async fn handle_pcm_queue( } /// Handle all the control messages from the ctrl queue. -pub async fn handle_ctrl_queue( +pub async fn handle_ctrl_queue( ex: &Executor, mem: &GuestMemory, streams: &Rc>>>, snd_data: &SndData, queue: Rc>, queue_event: &mut EventAsync, - interrupt: I, + interrupt: Interrupt, tx_send: mpsc::UnboundedSender, rx_send: mpsc::UnboundedSender, reset_signal: Option<&(AsyncRwLock, Condvar)>, @@ -878,11 +878,11 @@ pub async fn handle_ctrl_queue( } /// Send events to the audio driver. -pub async fn handle_event_queue( +pub async fn handle_event_queue( mem: &GuestMemory, mut queue: Queue, mut queue_event: EventAsync, - interrupt: I, + interrupt: Interrupt, ) -> Result<(), Error> { loop { let desc_chain = queue diff --git a/devices/src/virtio/snd/vios_backend/worker.rs b/devices/src/virtio/snd/vios_backend/worker.rs index 754e56b2f5..dfc836b625 100644 --- a/devices/src/virtio/snd/vios_backend/worker.rs +++ b/devices/src/virtio/snd/vios_backend/worker.rs @@ -26,7 +26,6 @@ use super::*; use crate::virtio::DescriptorChain; use crate::virtio::Interrupt; use crate::virtio::Queue; -use crate::virtio::SignalableInterrupt; pub struct Worker { // Lock order: Must never hold more than one queue lock at the same time. diff --git a/devices/src/virtio/tpm.rs b/devices/src/virtio/tpm.rs index 8fbfd4e8ea..12dd990831 100644 --- a/devices/src/virtio/tpm.rs +++ b/devices/src/virtio/tpm.rs @@ -23,7 +23,6 @@ use super::DescriptorChain; use super::DeviceType; use super::Interrupt; use super::Queue; -use super::SignalableInterrupt; use super::VirtioDevice; // A single queue of size 2. The guest kernel driver will enqueue a single diff --git a/devices/src/virtio/vhost/user/device/net/sys/windows.rs b/devices/src/virtio/vhost/user/device/net/sys/windows.rs index 6daf5856f1..1cc68d79ac 100644 --- a/devices/src/virtio/vhost/user/device/net/sys/windows.rs +++ b/devices/src/virtio/vhost/user/device/net/sys/windows.rs @@ -55,7 +55,6 @@ use crate::virtio::vhost::user::device::net::NetBackend; use crate::virtio::vhost::user::device::net::NET_EXECUTOR; use crate::virtio::Interrupt; use crate::virtio::Queue; -use crate::virtio::SignalableInterrupt; impl NetBackend where diff --git a/devices/src/virtio/vhost/user/device/vsock.rs b/devices/src/virtio/vhost/user/device/vsock.rs index 878657ba8c..c2966dbecf 100644 --- a/devices/src/virtio/vhost/user/device/vsock.rs +++ b/devices/src/virtio/vhost/user/device/vsock.rs @@ -51,7 +51,6 @@ use crate::virtio::vhost::user::VhostUserListener; use crate::virtio::vhost::user::VhostUserListenerTrait; use crate::virtio::Queue; use crate::virtio::QueueType::Split; -use crate::virtio::SignalableInterrupt; const MAX_VRING_LEN: u16 = QUEUE_SIZE; const EVENT_QUEUE: usize = NUM_QUEUES - 1; diff --git a/devices/src/virtio/vhost/user/proxy.rs b/devices/src/virtio/vhost/user/proxy.rs index a52b2d11a4..c578c41723 100644 --- a/devices/src/virtio/vhost/user/proxy.rs +++ b/devices/src/virtio/vhost/user/proxy.rs @@ -89,7 +89,6 @@ use crate::virtio::DeviceType; use crate::virtio::Interrupt; use crate::virtio::PciCapabilityType; use crate::virtio::Queue; -use crate::virtio::SignalableInterrupt; use crate::virtio::VirtioDevice; use crate::virtio::VirtioPciCap; use crate::virtio::VIRTIO_F_ACCESS_PLATFORM; diff --git a/devices/src/virtio/vhost/user/vmm/handler.rs b/devices/src/virtio/vhost/user/vmm/handler.rs index 43a96feefb..eefb74b989 100644 --- a/devices/src/virtio/vhost/user/vmm/handler.rs +++ b/devices/src/virtio/vhost/user/vmm/handler.rs @@ -39,7 +39,6 @@ use crate::virtio::Interrupt; use crate::virtio::Queue; use crate::virtio::SharedMemoryMapper; use crate::virtio::SharedMemoryRegion; -use crate::virtio::SignalableInterrupt; type BackendReqHandler = MasterReqHandler>; diff --git a/devices/src/virtio/vhost/user/vmm/handler/worker.rs b/devices/src/virtio/vhost/user/vmm/handler/worker.rs index 6dda38e1fa..7bfc686447 100644 --- a/devices/src/virtio/vhost/user/vmm/handler/worker.rs +++ b/devices/src/virtio/vhost/user/vmm/handler/worker.rs @@ -11,7 +11,6 @@ use futures::pin_mut; use vm_memory::GuestMemory; use crate::virtio::async_utils; -use crate::virtio::interrupt::SignalableInterrupt; use crate::virtio::vhost::user::vmm::handler::sys::run_backend_request_handler; use crate::virtio::vhost::user::vmm::handler::BackendReqHandler; use crate::virtio::Interrupt; diff --git a/devices/src/virtio/vhost/worker.rs b/devices/src/virtio/vhost/worker.rs index 5ca445c454..fd786420c8 100644 --- a/devices/src/virtio/vhost/worker.rs +++ b/devices/src/virtio/vhost/worker.rs @@ -18,7 +18,6 @@ use super::Error; use super::Result; use crate::virtio::Interrupt; use crate::virtio::Queue; -use crate::virtio::SignalableInterrupt; use crate::virtio::VIRTIO_F_ACCESS_PLATFORM; /// Worker that takes care of running the vhost device. diff --git a/devices/src/virtio/video/worker.rs b/devices/src/virtio/video/worker.rs index 3779e180b9..16f42a179e 100644 --- a/devices/src/virtio/video/worker.rs +++ b/devices/src/virtio/video/worker.rs @@ -39,21 +39,21 @@ use crate::virtio::video::response::Response; use crate::virtio::video::Error; use crate::virtio::video::Result; use crate::virtio::DescriptorChain; +use crate::virtio::Interrupt; use crate::virtio::Queue; -use crate::virtio::SignalableInterrupt; /// Worker that takes care of running the virtio video device. -pub struct Worker { +pub struct Worker { /// Memory region of the guest VM mem: GuestMemory, /// VirtIO queue for Command queue cmd_queue: Queue, /// Device-to-driver notification for command queue - cmd_queue_interrupt: I, + cmd_queue_interrupt: Interrupt, /// VirtIO queue for Event queue event_queue: Queue, /// Device-to-driver notification for the event queue. - event_queue_interrupt: I, + event_queue_interrupt: Interrupt, /// Stores descriptor chains in which responses for asynchronous commands will be written desc_map: AsyncCmdDescMap, } @@ -61,13 +61,13 @@ pub struct Worker { /// Pair of a descriptor chain and a response to be written. type WritableResp = (DescriptorChain, response::CmdResponse); -impl Worker { +impl Worker { pub fn new( mem: GuestMemory, cmd_queue: Queue, - cmd_queue_interrupt: I, + cmd_queue_interrupt: Interrupt, event_queue: Queue, - event_queue_interrupt: I, + event_queue_interrupt: Interrupt, ) -> Self { Self { mem, diff --git a/devices/src/virtio/vsock/sys/windows/vsock.rs b/devices/src/virtio/vsock/sys/windows/vsock.rs index 7a0b47b409..377821827d 100644 --- a/devices/src/virtio/vsock/sys/windows/vsock.rs +++ b/devices/src/virtio/vsock/sys/windows/vsock.rs @@ -62,7 +62,6 @@ use crate::virtio::DescriptorChain; use crate::virtio::DeviceType; use crate::virtio::Interrupt; use crate::virtio::Queue; -use crate::virtio::SignalableInterrupt; use crate::virtio::VirtioDevice; use crate::virtio::Writer; use crate::Suspendable; diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs index 06c9b3a954..e4ea440062 100644 --- a/devices/src/virtio/wl.rs +++ b/devices/src/virtio/wl.rs @@ -133,7 +133,6 @@ use super::Queue; use super::Reader; use super::SharedMemoryMapper; use super::SharedMemoryRegion; -use super::SignalableInterrupt; use super::VirtioDevice; use super::Writer; use crate::virtio::device_constants::wl::QUEUE_SIZES; @@ -1689,8 +1688,8 @@ impl WlState { pub struct DescriptorsExhausted; /// Handle incoming events and forward them to the VM over the input queue. -pub fn process_in_queue( - interrupt: &I, +pub fn process_in_queue( + interrupt: &Interrupt, in_queue: &Rc>, mem: &GuestMemory, state: &mut WlState, @@ -1742,8 +1741,8 @@ pub fn process_in_queue( } /// Handle messages from the output queue and forward them to the display sever, if necessary. -pub fn process_out_queue( - interrupt: &I, +pub fn process_out_queue( + interrupt: &Interrupt, out_queue: &Rc>, mem: &GuestMemory, state: &mut WlState, diff --git a/docs/book/src/tracing.md b/docs/book/src/tracing.md index 4fdbf8190e..25ec7cc47d 100644 --- a/docs/book/src/tracing.md +++ b/docs/book/src/tracing.md @@ -99,9 +99,9 @@ If you just need to add a simple one-off trace point, you can use `trace_simple_ (taken from `devices/src/virtio/fs/worker.rs`): ```rust -pub fn process_fs_queue( +pub fn process_fs_queue( mem: &GuestMemory, - interrupt: &I, + interrupt: &Interrupt, queue: &mut Queue, server: &Arc>, tube: &Arc>, @@ -133,9 +133,9 @@ So far so good, but to get the most out of it you might want to record how long to run and some extra parameters. In that case you want to use `trace_event!()` instead: ```rust -pub fn process_fs_queue( +pub fn process_fs_queue( mem: &GuestMemory, - interrupt: &I, + interrupt: &Interrupt, queue: &mut Queue, server: &Arc>, tube: &Arc>,