DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jonas Pfefferle <jpf@zurich.ibm.com>
To: dev@dpdk.org
Cc: anatoly.burakov@intel.com, Jonas Pfefferle <jpf@zurich.ibm.com>
Subject: [dpdk-dev] [PATCH v2] vfio: noiommu check error handling
Date: Tue, 31 Oct 2017 16:59:46 +0100	[thread overview]
Message-ID: <1509465586-7436-1-git-send-email-jpf@zurich.ibm.com> (raw)

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 | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index 5bbcdf9..80afdb3 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -843,20 +843,33 @@ 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;
 	fd = open(VFIO_NOIOMMU_MODE, O_RDONLY);
-	if (fd < 0)
-		return -1;
+	if (fd < 0) {
+		if (errno != ENOENT) {
+			RTE_LOG(ERR, EAL, "  cannot open vfio noiommu file %i (%s)\n",
+					errno, strerror(errno));
+			return -1;
+		}
+		/*
+		 * else the file does not exists
+		 * i.e. noiommu is not enabled
+		 */
+		return 0;
+	}
 
 	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

             reply	other threads:[~2017-10-31 15:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 15:59 Jonas Pfefferle [this message]
2017-11-06 20:25 ` Thomas Monjalon
2017-11-07  9:05   ` Jonas Pfefferle1
2017-11-07  9:40     ` Thomas Monjalon
2017-11-07  9:50       ` Jonas Pfefferle1
2018-01-11 23:45         ` Thomas Monjalon
2018-01-13 12:15           ` Burakov, Anatoly
2018-01-13 22:49             ` Thomas Monjalon
2018-01-15 12:22               ` Jonas Pfefferle
2018-01-15 16:11                 ` Thomas Monjalon
2018-01-16 16:08                   ` Jonas Pfefferle
2018-01-16 17:01                     ` Maxime Coquelin
2018-01-17  8:48                       ` Jonas Pfefferle
2018-01-17  8:55                         ` Maxime Coquelin
2018-01-17 10:34                           ` Jonas Pfefferle
2018-01-16 10:07                 ` Burakov, Anatoly
2018-01-16 16:09                   ` Jonas Pfefferle
2018-01-13 12:05 ` Burakov, Anatoly
2018-01-19 17:37 ` Maxime Coquelin
2018-01-20 14:48   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1509465586-7436-1-git-send-email-jpf@zurich.ibm.com \
    --to=jpf@zurich.ibm.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).