Enable VfioError::IommuDmaMap and VfioError::IommuDmaUnmap to take SysError when it returns.
Add VfioError::GetHostAddress error to handle failure of get_host_address method.
Add VfioError::InvalidDmaUnmapSize error for unmap size check.
When dma_map.size == 0x2000, it will be set to 0x1000 in test method unmap_dma so that VfioError::InvalidDmaUnmapSize error can be covered with unit tests.
@liuw @sboeuf
Please review again for I have done some changes:
I delete the InvalidVirtualAddress error because it is only used in test function previously. Instead, I use IommuDmaMap(SysError::last()) to be consistent with the real implementation.
I also add a test function, test_vfio_map_guest_memory, to cover the errors I add and to test the methods, vfio_map_guest_memory and vfio_unmap_guest_memory.
Improving the error that is reported through IommuDmaMap and IommuDmaUnmap by propagating the system error retrieved through SysError.
Also introducing new types of VfioError to provide more appropriate errors to the caller.
Signed-off-by: xuejun-xj jiyunxue@linux.alibaba.com Signed-off-by: jingshan jingshan@linux.alibaba.com
Summary of the PR
This PR enables VfioError::IommuDmaMap/IommuDmaUnmap to take SysError after calling the ioctls.
Issue: #12