[libvirt] [PATCH] iohelper: Don't try to fdatasync(stdout)

After upgrading to libvirt 1.0.0, I've started getting warnings from libvirt: (gnome-boxes:5965): Libvirt.GObject-CRITICAL **: cannot finish stream: internal error libvirt_iohelper: unable to fsync stdout: Invalid argument On further investigation, in iohelper.c:runIO(), fdatasync can get called on STDOUT_FILENO, which indeed returns EINVAL when this happens. After making sure that fdout is not STDOUT_FILENO, this warning goes away. --- src/util/iohelper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index 860e14a..f8a8ee3 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -180,9 +180,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 (fdout != STDOUT_FILENO) { + if (fdatasync(fdout) < 0) { + virReportSystemError(errno, _("unable to fsync %s"), fdoutname); + goto cleanup; + } } ret = 0; -- 1.7.12.1

On 11/05/2012 06:21 AM, Christophe Fergeau wrote:
After upgrading to libvirt 1.0.0, I've started getting warnings from libvirt: (gnome-boxes:5965): Libvirt.GObject-CRITICAL **: cannot finish stream: internal error libvirt_iohelper: unable to fsync stdout: Invalid argument
On further investigation, in iohelper.c:runIO(), fdatasync can get called on STDOUT_FILENO, which indeed returns EINVAL when this happens. After making sure that fdout is not STDOUT_FILENO, this warning goes away. --- src/util/iohelper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
NACK. It is not because we are calling fdatasync(1), but because fd 1 happens to be something that is not syncable (perhaps a pipe). We need to figure out the real condition on when fd 1 is syncable, and skip the error in the case where it is a pipe or some other non-syncable fd, and not based on some magic exemption of just fd 1 without even knowing why we are failing. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Christophe Fergeau
-
Eric Blake