Constraining the problem makes the solution easier to think about. * src/util/iohelper.c (runIO): Make read support easy. --- Could be squashed into 6/8. src/util/iohelper.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index 82f62e1..f091d13 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -107,6 +107,13 @@ runIO(const char *path, int fd, int oflags, unsigned long long length) fdinname = path; fdout = STDOUT_FILENO; fdoutname = "stdout"; + /* To make the implementation simpler, we give up on any + * attempt to use O_DIRECT in a non-trivial manner. */ + if (direct && ((end = lseek(fd, 0, SEEK_CUR)) != 0 || length)) { + virReportSystemError(end < 0 ? errno : EINVAL, "%s", + _("O_DIRECT read needs entire seekable file")); + goto cleanup; + } break; case O_WRONLY: fdin = STDIN_FILENO; @@ -117,7 +124,7 @@ runIO(const char *path, int fd, int oflags, unsigned long long length) * attempt to use O_DIRECT in a non-trivial manner. */ if (direct && (end = lseek(fd, 0, SEEK_END)) != 0) { virReportSystemError(end < 0 ? errno : EINVAL, "%s", - _("O_DIRECT needs empty seekable file")); + _("O_DIRECT write needs empty seekable file")); goto cleanup; } break; -- 1.7.4.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list