Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions alioth/src/virtio/dev/balloon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,15 @@ impl Virtio for Balloon {

fn spawn_worker<S, E>(
self,
event_rx: Receiver<WakeEvent<S>>,
event_rx: Receiver<WakeEvent<S, E>>,
memory: Arc<RamBus>,
queue_regs: Arc<[Queue]>,
fds: Arc<[(E, bool)]>,
) -> Result<(JoinHandle<()>, Arc<Waker>)>
where
S: IrqSender,
E: IoeventFd,
{
Mio::spawn_worker(self, event_rx, memory, queue_regs, fds)
Mio::spawn_worker(self, event_rx, memory, queue_regs)
}

fn num_queues(&self) -> u16 {
Expand All @@ -227,11 +226,16 @@ impl Virtio for Balloon {
}

impl VirtioMio for Balloon {
fn activate<'a, 'm, Q: VirtQueue<'m>, S: IrqSender>(
fn activate<'a, 'm, Q, S, E>(
&mut self,
feature: u64,
_active_mio: &mut ActiveMio<'a, 'm, Q, S>,
) -> Result<()> {
_active_mio: &mut ActiveMio<'a, 'm, Q, S, E>,
) -> Result<()>
where
Q: VirtQueue<'m>,
S: IrqSender,
E: IoeventFd,
{
let feature = BalloonFeature::from_bits_retain(feature);
self.queues[0] = BalloonQueue::Inflate;
self.queues[1] = BalloonQueue::Deflate;
Expand All @@ -250,11 +254,16 @@ impl VirtioMio for Balloon {
Ok(())
}

fn handle_queue<'a, 'm, Q: VirtQueue<'m>, S: IrqSender>(
fn handle_queue<'a, 'm, Q, S, E>(
&mut self,
index: u16,
active_mio: &mut ActiveMio<'a, 'm, Q, S>,
) -> Result<()> {
active_mio: &mut ActiveMio<'a, 'm, Q, S, E>,
) -> Result<()>
where
Q: VirtQueue<'m>,
S: IrqSender,
E: IoeventFd,
{
let Some(Some(queue)) = active_mio.queues.get_mut(index as usize) else {
log::error!("{}: invalid queue index {index}", self.name);
return Ok(());
Expand Down Expand Up @@ -288,11 +297,16 @@ impl VirtioMio for Balloon {
})
}

fn handle_event<'a, 'm, Q: VirtQueue<'m>, S: IrqSender>(
fn handle_event<'a, 'm, Q, S, E>(
&mut self,
_event: &Event,
_active_mio: &mut ActiveMio<'a, 'm, Q, S>,
) -> Result<()> {
_active_mio: &mut ActiveMio<'a, 'm, Q, S, E>,
) -> Result<()>
where
Q: VirtQueue<'m>,
S: IrqSender,
E: IoeventFd,
{
Ok(())
}

Expand Down
57 changes: 36 additions & 21 deletions alioth/src/virtio/dev/blk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,12 @@ use snafu::ResultExt;
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes};

use crate::hv::IoeventFd;
#[cfg(target_os = "linux")]
use crate::mem::mapped::Ram;
use crate::mem::mapped::RamBus;
use crate::virtio::dev::{DevParam, Virtio, WakeEvent};
use crate::virtio::queue::handlers::handle_desc;
use crate::virtio::queue::{Descriptor, Queue, VirtQueue};
#[cfg(target_os = "linux")]
use crate::virtio::worker::io_uring::{BufferAction, IoUring, VirtioIoUring};
use crate::virtio::worker::io_uring::{ActiveIoUring, BufferAction, IoUring, VirtioIoUring};
use crate::virtio::worker::mio::{ActiveMio, Mio, VirtioMio};
use crate::virtio::worker::{Waker, WorkerApi};
use crate::virtio::{DeviceId, FEATURE_BUILT_IN, IrqSender, Result, error};
Expand Down Expand Up @@ -300,47 +298,61 @@ impl Virtio for Block {

fn spawn_worker<S, E>(
self,
event_rx: Receiver<WakeEvent<S>>,
event_rx: Receiver<WakeEvent<S, E>>,
memory: Arc<RamBus>,
queue_regs: Arc<[Queue]>,
fds: Arc<[(E, bool)]>,
) -> Result<(JoinHandle<()>, Arc<Waker>)>
where
S: IrqSender,
E: IoeventFd,
{
match self.api {
#[cfg(target_os = "linux")]
WorkerApi::IoUring => IoUring::spawn_worker(self, event_rx, memory, queue_regs, fds),
WorkerApi::Mio => Mio::spawn_worker(self, event_rx, memory, queue_regs, fds),
WorkerApi::IoUring => IoUring::spawn_worker(self, event_rx, memory, queue_regs),
WorkerApi::Mio => Mio::spawn_worker(self, event_rx, memory, queue_regs),
}
}
}

impl VirtioMio for Block {
fn reset(&mut self, _registry: &Registry) {}

fn activate<'a, 'm, Q: VirtQueue<'m>, S: IrqSender>(
fn activate<'a, 'm, Q, S, E>(
&mut self,
_feature: u64,
_active_mio: &mut ActiveMio<'a, 'm, Q, S>,
) -> Result<()> {
_active_mio: &mut ActiveMio<'a, 'm, Q, S, E>,
) -> Result<()>
where
Q: VirtQueue<'m>,
S: IrqSender,
E: IoeventFd,
{
Ok(())
}

fn handle_event<'a, 'm, Q: VirtQueue<'m>, S: IrqSender>(
fn handle_event<'a, 'm, Q, S, E>(
&mut self,
_event: &Event,
_active_mio: &mut ActiveMio<'a, 'm, Q, S>,
) -> Result<()> {
_active_mio: &mut ActiveMio<'a, 'm, Q, S, E>,
) -> Result<()>
where
Q: VirtQueue<'m>,
S: IrqSender,
E: IoeventFd,
{
Ok(())
}

fn handle_queue<'a, 'm, Q: VirtQueue<'m>, S: IrqSender>(
fn handle_queue<'a, 'm, Q, S, E>(
&mut self,
index: u16,
active_mio: &mut ActiveMio<'a, 'm, Q, S>,
) -> Result<()> {
active_mio: &mut ActiveMio<'a, 'm, Q, S, E>,
) -> Result<()>
where
Q: VirtQueue<'m>,
S: IrqSender,
E: IoeventFd,
{
let Some(Some(queue)) = active_mio.queues.get_mut(index as usize) else {
log::error!("{}: invalid queue index {index}", self.name);
return Ok(());
Expand Down Expand Up @@ -400,13 +412,16 @@ impl VirtioMio for Block {

#[cfg(target_os = "linux")]
impl VirtioIoUring for Block {
fn activate<'m, S: IrqSender, Q: VirtQueue<'m>>(
fn activate<'a, 'm, Q, S, E>(
&mut self,
_feature: u64,
_memory: &Ram,
_irq_sender: &S,
_queues: &mut [Option<Q>],
) -> Result<()> {
_ring: &mut ActiveIoUring<'a, 'm, Q, S, E>,
) -> Result<()>
where
S: IrqSender,
Q: VirtQueue<'m>,
E: IoeventFd,
{
Ok(())
}

Expand Down
Loading