* [dpdk-dev] [PATCH] vfio: noiommu check error handling
@ 2017-10-31 15:37 Jonas Pfefferle
0 siblings, 0 replies; only message in thread
From: Jonas Pfefferle @ 2017-10-31 15:37 UTC (permalink / raw)
To: dev; +Cc: anatoly.burakov, Jonas Pfefferle
Check and report errors on open/read in noiommu check.
Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>
---
lib/librte_eal/linuxapp/eal/eal_vfio.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index 5bbcdf9..8f9d043 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -843,20 +843,34 @@ vfio_noiommu_dma_map(int __rte_unused vfio_container_fd)
int
vfio_noiommu_is_enabled(void)
{
- int fd, ret, cnt __rte_unused;
+ int fd;
+ ssize_t cnt;
char c;
- ret = -1;
+ if (access(VFIO_NOIOMMU_MODE, R_OK) == -1) {
+ /*
+ * file does not exist assume noiommu mode
+ * is not available i.e. not enabled
+ */
+ return 0;
+ }
+
fd = open(VFIO_NOIOMMU_MODE, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ RTE_LOG(ERR, EAL, " cannot open vfio noiommu file %i (%s)\n",
+ errno, strerror(errno));
return -1;
+ }
cnt = read(fd, &c, 1);
- if (c == 'Y')
- ret = 1;
-
close(fd);
- return ret;
+ if (cnt != 1) {
+ RTE_LOG(ERR, EAL, " unable to read from vfio noiommu "
+ "file %i (%s)\n", errno, strerror(errno));
+ return -1;
+ }
+
+ return c == 'Y';
}
#endif
--
2.7.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-10-31 15:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 15:37 [dpdk-dev] [PATCH] vfio: noiommu check error handling Jonas Pfefferle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).