[libvirt] [PATCH] iohelper: Don't report errors on special FDs

Michal Privoznik mprivozn at redhat.com
Mon Nov 5 14:54:51 UTC 2012


Some FDs may not implement fdatasync() functionality, e.g.
pipes or stdout. In that case EINVAL or EROFS is returned.
We don't want to fail then nor report any error.

Reported-by: Christophe Fergeau <cfergeau at redhat.com>
---

I know that those two 'if-s' can be joined together but it just looks weird to me.

 src/util/iohelper.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index 860e14a..b8c91aa 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -181,8 +181,11 @@ runIO(const char *path, int fd, int oflags, unsigned long long length)
 
     /* Ensure all data is written */
     if (fdatasync(fdout) < 0) {
-        virReportSystemError(errno, _("unable to fsync %s"), fdoutname);
-        goto cleanup;
+        if (errno != EINVAL && errno != EROFS) {
+            /* fdatasync() may fail on some special FDs like stdout or pipes */
+            virReportSystemError(errno, _("unable to fsync %s"), fdoutname);
+            goto cleanup;
+        }
     }
 
     ret = 0;
-- 
1.7.8.6




More information about the libvir-list mailing list