1#[macro_use]
7extern crate vmm_sys_util;
8
9use std::io;
10use thiserror::Error;
11use vmm_sys_util::errno::Error as SysError;
12
13pub mod iommufd_ioctls;
14
15pub use iommufd_ioctls::*;
16
17use iommufd_bindings::iommufd::*;
18
19#[derive(Debug, Error)]
20pub enum IommufdError {
21 #[error("failed to open /dev/iommufd: {0}")]
22 OpenIommufd(#[source] io::Error),
23 #[error("failed to destroy iommufd object: {0}")]
24 IommuDestroy(#[source] SysError),
25 #[error("failed to allocate IOAS: {0}")]
26 IommuIoasAlloc(#[source] SysError),
27 #[error("failed to map an IOVA range to the IOAS: {0}")]
28 IommuIoasMap(#[source] SysError),
29 #[error("failed to unmap an IOVA range from the IOAS: {0}")]
30 IommuIoasUnmap(#[source] SysError),
31 #[error("failed to allocate HWPT: {0}")]
32 IommuHwptAlloc(#[source] SysError),
33 #[error("failed to allocate vIOMMU: {0}")]
34 IommuViommuAlloc(#[source] SysError),
35 #[error("failed to allocate vDevice: {0}")]
36 IommuVdeviceAlloc(#[source] SysError),
37 #[error("failed to get HW info: {0}")]
38 IommuGetHwInfo(#[source] SysError),
39 #[error("failed to invalidate HWPT: {0}")]
40 IommuHwptInvalidate(#[source] SysError),
41 #[error("failed to allocate vEVENTQ: {0}")]
42 IommuVeventqAlloc(#[source] SysError),
43 #[error("failed to make the vEVENTQ fd non-blocking: {0}")]
44 VeventqNonBlocking(#[source] SysError),
45 #[error("failed to allocate HW queue: {0}")]
46 IommuHwQueueAlloc(#[source] SysError),
47 #[error("hardware queues are not available on this vIOMMU")]
48 HwQueueUnsupported,
49 #[error("unsupported vIOMMU type: {0}")]
50 UnsupportedViommuType(iommu_viommu_type),
51 #[error("unsupported vEVENTQ type: {0}")]
52 UnsupportedVeventqType(iommu_veventq_type),
53 #[error("unsupported IOMMU: {0}")]
54 UnsupportedIommu(iommu_hw_info_type),
55 #[error("the data does not match the backing IOMMU: {0:?}")]
56 IommuTypeMismatch(IommuKind),
57 #[error("S1 HWPT already allocated with for the given vDevice: {0}")]
58 S1HwptAlreadyAllocated(u32),
59 #[error("failed to attach the device to a page table: {0}")]
60 AttachHwpt(#[source] io::Error),
61}
62
63pub type Result<T> = std::result::Result<T, IommufdError>;