From b222c47b53e0b28dad48427275ecb5dfaf25d4cc Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Mon, 5 Nov 2012 15:42:53 +0100 Subject: [PATCH] iohelper: Don't report errors on special FDs Some FDs may not implement fdatasync() functionality, e.g. pipes. In that case EINVAL or EROFS is returned. We don't want to fail then nor report any error. Reported-by: Christophe Fergeau (cherry picked from commit 46325e51310344872597453ba5d621afa88d44c1) --- src/util/iohelper.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index 860e14a98f..a9c8b4cefa 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, e.g. pipes */ + virReportSystemError(errno, _("unable to fsync %s"), fdoutname); + goto cleanup; + } } ret = 0;