mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
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 <dverkamp@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
parent
84cd6de654
commit
019d6bace7
32 changed files with 77 additions and 120 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<I: SignalableInterrupt>(
|
||||
pub async fn process_one_chain(
|
||||
queue: &RefCell<Queue>,
|
||||
mut avail_desc: DescriptorChain,
|
||||
disk_state: &AsyncRwLock<DiskState>,
|
||||
mem: &GuestMemory,
|
||||
interrupt: &I,
|
||||
interrupt: &Interrupt,
|
||||
flush_timer: &RefCell<TimerAsync<Timer>>,
|
||||
flush_timer_armed: &RefCell<bool>,
|
||||
) {
|
||||
|
@ -303,12 +302,12 @@ pub async fn process_one_chain<I: SignalableInterrupt>(
|
|||
// 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<I: SignalableInterrupt + 'static>(
|
||||
async fn handle_queue(
|
||||
mem: GuestMemory,
|
||||
disk_state: Rc<AsyncRwLock<DiskState>>,
|
||||
queue: Rc<RefCell<Queue>>,
|
||||
evt: EventAsync,
|
||||
interrupt: I,
|
||||
interrupt: Interrupt,
|
||||
flush_timer: Rc<RefCell<TimerAsync<Timer>>>,
|
||||
flush_timer_armed: Rc<RefCell<bool>>,
|
||||
mut stop_rx: oneshot::Receiver<()>,
|
||||
|
|
|
@ -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<I: SignalableInterrupt>(
|
||||
fn handle_input(
|
||||
mem: &GuestMemory,
|
||||
interrupt: &I,
|
||||
interrupt: &Interrupt,
|
||||
buffer: &mut VecDeque<u8>,
|
||||
receive_queue: &Arc<Mutex<Queue>>,
|
||||
) -> 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<I: SignalableInterrupt>(
|
||||
fn process_transmit_queue(
|
||||
mem: &GuestMemory,
|
||||
interrupt: &I,
|
||||
interrupt: &Interrupt,
|
||||
transmit_queue: &Arc<Mutex<Queue>>,
|
||||
output: &mut dyn io::Write,
|
||||
) {
|
||||
|
|
|
@ -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<I: SignalableInterrupt>(
|
||||
async fn run_tx_queue(
|
||||
queue: &Arc<Mutex<virtio::Queue>>,
|
||||
mem: GuestMemory,
|
||||
doorbell: I,
|
||||
doorbell: Interrupt,
|
||||
kick_evt: EventAsync,
|
||||
output: &mut Box<dyn io::Write + Send>,
|
||||
) {
|
||||
|
@ -73,10 +72,10 @@ async fn run_tx_queue<I: SignalableInterrupt>(
|
|||
}
|
||||
}
|
||||
|
||||
async fn run_rx_queue<I: SignalableInterrupt>(
|
||||
async fn run_rx_queue(
|
||||
queue: &Arc<Mutex<virtio::Queue>>,
|
||||
mem: GuestMemory,
|
||||
doorbell: I,
|
||||
doorbell: Interrupt,
|
||||
kick_evt: EventAsync,
|
||||
input: &IoSource<AsyncSerialInput>,
|
||||
) {
|
||||
|
@ -126,12 +125,12 @@ impl ConsoleDevice {
|
|||
self.avail_features
|
||||
}
|
||||
|
||||
pub fn start_receive_queue<I: SignalableInterrupt + 'static>(
|
||||
pub fn start_receive_queue(
|
||||
&mut self,
|
||||
ex: &Executor,
|
||||
mem: GuestMemory,
|
||||
queue: Arc<Mutex<virtio::Queue>>,
|
||||
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<I: SignalableInterrupt + 'static>(
|
||||
pub fn start_transmit_queue(
|
||||
&mut self,
|
||||
ex: &Executor,
|
||||
mem: GuestMemory,
|
||||
queue: Arc<Mutex<virtio::Queue>>,
|
||||
doorbell: I,
|
||||
doorbell: Interrupt,
|
||||
kick_evt: Event,
|
||||
) -> anyhow::Result<()> {
|
||||
let kick_evt =
|
||||
|
|
|
@ -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<F: FileSystem + Sync> {
|
|||
slot: u32,
|
||||
}
|
||||
|
||||
pub fn process_fs_queue<I: SignalableInterrupt, F: FileSystem + Sync>(
|
||||
pub fn process_fs_queue<F: FileSystem + Sync>(
|
||||
mem: &GuestMemory,
|
||||
interrupt: &I,
|
||||
interrupt: &Interrupt,
|
||||
queue: &Rc<RefCell<Queue>>,
|
||||
server: &Arc<fuse::Server<F>>,
|
||||
tube: &Arc<Mutex<Tube>>,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Arc<Mutex<MsixConfig>>>,
|
||||
|
@ -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(),
|
||||
|
|
|
@ -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<I: SignalableInterrupt>(
|
||||
async fn request_queue(
|
||||
state: &Rc<RefCell<State>>,
|
||||
mut queue: Queue,
|
||||
mut queue_event: EventAsync,
|
||||
interrupt: I,
|
||||
interrupt: Interrupt,
|
||||
) -> Result<()> {
|
||||
loop {
|
||||
let mem = state.borrow().mem.clone();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<T: TapT>(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn process_ctrl<I: SignalableInterrupt, T: TapT>(
|
||||
interrupt: &I,
|
||||
pub fn process_ctrl<T: TapT>(
|
||||
interrupt: &Interrupt,
|
||||
ctrl_queue: &Arc<Mutex<Queue>>,
|
||||
mem: &GuestMemory,
|
||||
tap: &mut T,
|
||||
|
|
|
@ -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<I: SignalableInterrupt, T: TapT>(
|
||||
interrupt: &I,
|
||||
pub fn process_rx<T: TapT>(
|
||||
interrupt: &Interrupt,
|
||||
rx_queue: &Arc<Mutex<Queue>>,
|
||||
mem: &GuestMemory,
|
||||
mut tap: &mut T,
|
||||
|
@ -80,8 +80,8 @@ pub fn process_rx<I: SignalableInterrupt, T: TapT>(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn process_tx<I: SignalableInterrupt, T: TapT>(
|
||||
interrupt: &I,
|
||||
pub fn process_tx<T: TapT>(
|
||||
interrupt: &Interrupt,
|
||||
tx_queue: &Arc<Mutex<Queue>>,
|
||||
mem: &GuestMemory,
|
||||
mut tap: &mut T,
|
||||
|
|
|
@ -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<I: SignalableInterrupt, T: TapT>(
|
||||
interrupt: &I,
|
||||
pub fn process_rx<T: TapT>(
|
||||
interrupt: &Interrupt,
|
||||
rx_queue: &Arc<Mutex<Queue>>,
|
||||
mem: &GuestMemory,
|
||||
tap: &mut T,
|
||||
|
@ -152,8 +152,8 @@ pub fn process_rx<I: SignalableInterrupt, T: TapT>(
|
|||
needs_interrupt
|
||||
}
|
||||
|
||||
pub fn process_tx<I: SignalableInterrupt, T: TapT>(
|
||||
interrupt: &I,
|
||||
pub fn process_tx<T: TapT>(
|
||||
interrupt: &Interrupt,
|
||||
tx_queue: &Arc<Mutex<Queue>>,
|
||||
mem: &GuestMemory,
|
||||
tap: &mut T,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<I: SignalableInterrupt>(
|
||||
&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),
|
||||
}
|
||||
|
|
|
@ -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<I: SignalableInterrupt>(
|
||||
&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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<I: SignalableInterrupt>(
|
||||
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<bool>, Con
|
|||
};
|
||||
}
|
||||
|
||||
pub async fn send_pcm_response_worker<I: SignalableInterrupt>(
|
||||
pub async fn send_pcm_response_worker(
|
||||
mem: &GuestMemory,
|
||||
queue: Rc<AsyncRwLock<Queue>>,
|
||||
interrupt: I,
|
||||
interrupt: Interrupt,
|
||||
recv: &mut mpsc::UnboundedReceiver<PcmResponse>,
|
||||
reset_signal: Option<&(AsyncRwLock<bool>, 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<I: SignalableInterrupt>(
|
||||
pub async fn handle_ctrl_queue(
|
||||
ex: &Executor,
|
||||
mem: &GuestMemory,
|
||||
streams: &Rc<AsyncRwLock<Vec<AsyncRwLock<StreamInfo>>>>,
|
||||
snd_data: &SndData,
|
||||
queue: Rc<AsyncRwLock<Queue>>,
|
||||
queue_event: &mut EventAsync,
|
||||
interrupt: I,
|
||||
interrupt: Interrupt,
|
||||
tx_send: mpsc::UnboundedSender<PcmResponse>,
|
||||
rx_send: mpsc::UnboundedSender<PcmResponse>,
|
||||
reset_signal: Option<&(AsyncRwLock<bool>, Condvar)>,
|
||||
|
@ -878,11 +878,11 @@ pub async fn handle_ctrl_queue<I: SignalableInterrupt>(
|
|||
}
|
||||
|
||||
/// Send events to the audio driver.
|
||||
pub async fn handle_event_queue<I: SignalableInterrupt>(
|
||||
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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<T: 'static> NetBackend<T>
|
||||
where
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Mutex<BackendReqHandlerImpl>>;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<I: SignalableInterrupt> {
|
||||
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<I: SignalableInterrupt> {
|
|||
/// Pair of a descriptor chain and a response to be written.
|
||||
type WritableResp = (DescriptorChain, response::CmdResponse);
|
||||
|
||||
impl<I: SignalableInterrupt> Worker<I> {
|
||||
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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<I: SignalableInterrupt>(
|
||||
interrupt: &I,
|
||||
pub fn process_in_queue(
|
||||
interrupt: &Interrupt,
|
||||
in_queue: &Rc<RefCell<Queue>>,
|
||||
mem: &GuestMemory,
|
||||
state: &mut WlState,
|
||||
|
@ -1742,8 +1741,8 @@ pub fn process_in_queue<I: SignalableInterrupt>(
|
|||
}
|
||||
|
||||
/// Handle messages from the output queue and forward them to the display sever, if necessary.
|
||||
pub fn process_out_queue<I: SignalableInterrupt>(
|
||||
interrupt: &I,
|
||||
pub fn process_out_queue(
|
||||
interrupt: &Interrupt,
|
||||
out_queue: &Rc<RefCell<Queue>>,
|
||||
mem: &GuestMemory,
|
||||
state: &mut WlState,
|
||||
|
|
|
@ -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<I: SignalableInterrupt, F: FileSystem + Sync>(
|
||||
pub fn process_fs_queue<F: FileSystem + Sync>(
|
||||
mem: &GuestMemory,
|
||||
interrupt: &I,
|
||||
interrupt: &Interrupt,
|
||||
queue: &mut Queue,
|
||||
server: &Arc<fuse::Server<F>>,
|
||||
tube: &Arc<Mutex<Tube>>,
|
||||
|
@ -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<I: SignalableInterrupt, F: FileSystem + Sync>(
|
||||
pub fn process_fs_queue<F: FileSystem + Sync>(
|
||||
mem: &GuestMemory,
|
||||
interrupt: &I,
|
||||
interrupt: &Interrupt,
|
||||
queue: &mut Queue,
|
||||
server: &Arc<fuse::Server<F>>,
|
||||
tube: &Arc<Mutex<Tube>>,
|
||||
|
|
Loading…
Reference in a new issue