mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-22 04:25:21 +00:00
virtio-devices: iommu: Propagate errors of processing request queue
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
84105992b7
commit
5b706422e8
@ -318,6 +318,8 @@ enum Error {
|
|||||||
ExternalMapping(io::Error),
|
ExternalMapping(io::Error),
|
||||||
#[error("Failed to performing external unmapping: {0}.")]
|
#[error("Failed to performing external unmapping: {0}.")]
|
||||||
ExternalUnmapping(io::Error),
|
ExternalUnmapping(io::Error),
|
||||||
|
#[error("Failed adding used index: {0}")]
|
||||||
|
QueueAddUsed(virtio_queue::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Request {}
|
struct Request {}
|
||||||
@ -639,29 +641,24 @@ struct IommuEpollHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IommuEpollHandler {
|
impl IommuEpollHandler {
|
||||||
fn request_queue(&mut self) -> bool {
|
fn request_queue(&mut self) -> Result<bool, Error> {
|
||||||
let mut used_descs = false;
|
let mut used_descs = false;
|
||||||
while let Some(mut desc_chain) = self.queues[0].pop_descriptor_chain(self.mem.memory()) {
|
while let Some(mut desc_chain) = self.queues[0].pop_descriptor_chain(self.mem.memory()) {
|
||||||
let len = match Request::parse(
|
let len = Request::parse(
|
||||||
&mut desc_chain,
|
&mut desc_chain,
|
||||||
&self.mapping,
|
&self.mapping,
|
||||||
&self.ext_mapping.lock().unwrap(),
|
&self.ext_mapping.lock().unwrap(),
|
||||||
self.msi_iova_space,
|
self.msi_iova_space,
|
||||||
) {
|
)?;
|
||||||
Ok(len) => len as u32,
|
|
||||||
Err(e) => {
|
|
||||||
error!("failed parsing descriptor: {}", e);
|
|
||||||
0
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
self.queues[0]
|
self.queues[0]
|
||||||
.add_used(desc_chain.memory(), desc_chain.head_index(), len)
|
.add_used(desc_chain.memory(), desc_chain.head_index(), len as u32)
|
||||||
.unwrap();
|
.map_err(Error::QueueAddUsed)?;
|
||||||
|
|
||||||
used_descs = true;
|
used_descs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
used_descs
|
Ok(used_descs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event_queue(&mut self) -> bool {
|
fn event_queue(&mut self) -> bool {
|
||||||
@ -704,7 +701,13 @@ impl EpollHelperHandler for IommuEpollHandler {
|
|||||||
EpollHelperError::HandleEvent(anyhow!("Failed to get queue event: {:?}", e))
|
EpollHelperError::HandleEvent(anyhow!("Failed to get queue event: {:?}", e))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
if self.request_queue() {
|
let needs_notification = self.request_queue().map_err(|e| {
|
||||||
|
EpollHelperError::HandleEvent(anyhow!(
|
||||||
|
"Failed to process request queue : {:?}",
|
||||||
|
e
|
||||||
|
))
|
||||||
|
})?;
|
||||||
|
if needs_notification {
|
||||||
self.signal_used_queue(0).map_err(|e| {
|
self.signal_used_queue(0).map_err(|e| {
|
||||||
EpollHelperError::HandleEvent(anyhow!(
|
EpollHelperError::HandleEvent(anyhow!(
|
||||||
"Failed to signal used queue: {:?}",
|
"Failed to signal used queue: {:?}",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user