The runIO function is after all initialization (e.g. argument parsing, file opening, ...) is done. It is the heart of the iohelper. Unfortunately, approach implemented in next patches is not easy to be combined with O_DIRECT. Therefore, rename runIO to runIOBasic and create new runIO, which for now just wraps over runIOBasic. But in not so distant future it will decide which IO loop is going to be called. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/iohelper/iohelper.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/iohelper/iohelper.c b/src/iohelper/iohelper.c index 00f31e7..02fc2ef 100644 --- a/src/iohelper/iohelper.c +++ b/src/iohelper/iohelper.c @@ -73,7 +73,7 @@ prepare(const char *path, int oflags, int mode, } static int -runIO(const char *path, int fd, int oflags, unsigned long long length) +runIOBasic(const char *path, int fd, int oflags, unsigned long long length) { void *base = NULL; /* Location to be freed */ char *buf = NULL; /* Aligned location within base */ @@ -199,6 +199,23 @@ runIO(const char *path, int fd, int oflags, unsigned long long length) return ret; } + +static int +runIO(const char *path, int fd, int oflags, + unsigned long long length, bool sparse) +{ + bool direct = O_DIRECT && ((oflags & O_DIRECT) != 0); + + /* Right now, our implementation do not support O_DIRECT and sparse. */ + if (direct && sparse) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("O_DIRECT and sparse streams is not supported at once")); + return -1; + } + + return runIOBasic(path, fd, oflags, length); +} + static const char *program_name; ATTRIBUTE_NORETURN static void @@ -225,6 +242,7 @@ main(int argc, char **argv) unsigned int delete = 0; int fd = -1; int lengthIndex = 0; + bool sparse = false; program_name = argv[0]; @@ -293,7 +311,7 @@ main(int argc, char **argv) exit(EXIT_FAILURE); } - if (fd < 0 || runIO(path, fd, oflags, length) < 0) + if (fd < 0 || runIO(path, fd, oflags, length, sparse) < 0) goto error; if (delete) -- 2.8.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list