Open lauralt opened 2 years ago
I will add trait QueueEvents in virtio-queue, like below:
/// Define a QueueEvents trait and let the backend decide how they want to handle different events
pub trait QueueEvents {
// some methods
....
}
And the device in the devices crate will implement this trait.
@uran0sH I assigned you to the issue. Thanks!
I try to add QueueEvents
to QueueState
as its field, like below. And I find some problems.
pub struct QueueState<EV: QueueEvents> {
...
/// Queue Events
pub queue_evts: EV,
}
pub struct Queue<M: GuestAddressSpace, EV: 'static + QueueEvents, S: QueueStateT<EV> = QueueState<EV>> {
/// Guest memory object associated with the queue.
pub mem: M,
/// Virtio queue state.
pub state: S,
_marker: PhantomData<EV>,
}
queue_evts
to QueueState , we need modify new
method of QueueStateT
, like fn new(max_size: u16, queue_evts: EV) -> Self
virtio-queue-ser
impl From<&QueueStateSer> for QueueState {
fn from(state: &QueueStateSer) -> Self {
QueueState {
queue_evts: ?
}
}
}
What value should we assign to queue_evts?
QueueState
must be static, since pub trait QueueStateT<EV: 'static + QueueEvents>: for<'a> QueueStateGuard<'a, EV>
. I can't find other methods to solve this. Maybe you have other methods?
In case of a queue misconfiguration, we log an error by using the
log
crate. We can get rid of this dependency by defining aQueueEvents
trait and let the backend decide how they want to handle different events, an example here for the serial console. Another option would be to return errors instead of logging an error. Related to: https://github.com/rust-vmm/vm-virtio/issues/94.