On Thu, May 23, 2024 at 04:55:18PM +0200, Stefano Garzarella wrote:
These defines are also useful for vhost-user-blk when it is compiled
in some POSIX systems that do not define them, so let's move them to
“qemu/osdep.h”.
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
include/qemu/osdep.h | 14 ++++++++++++++
block/file-posix.c | 14 --------------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index f61edcfdc2..e165b5cb1b 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -325,6 +325,20 @@ void QEMU_ERROR("code path is reachable")
#define ESHUTDOWN 4099
#endif
+/* OS X does not have O_DSYNC */
+#ifndef O_DSYNC
+#ifdef O_SYNC
+#define O_DSYNC O_SYNC
+#elif defined(O_FSYNC)
+#define O_DSYNC O_FSYNC
+#endif
+#endif
+
+/* Approximate O_DIRECT with O_DSYNC if O_DIRECT isn't available */
+#ifndef O_DIRECT
+#define O_DIRECT O_DSYNC
+#endif
Please don't do this - we can't be confident that all code in
QEMU will be OK with O_DIRECT being simulated in this way.
I'm not convinced that the O_DSYNC simulation is a good idea
to do tree-wide either.