qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: char devices on FreeBSD are not behind a pager
@ 2014-10-20 16:39 Roger Pau Monne
  2014-10-20 17:22 ` Kevin Wolf
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Pau Monne @ 2014-10-20 16:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, Roger Pau Monne

Acknowledge this and forcefully set BDRV_O_NOCACHE and O_DIRECT in order to
force QEMU to use aligned buffers.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/raw-posix.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 86ce4f2..63841dd 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -472,6 +472,18 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
         }
 #endif
     }
+#ifdef __FreeBSD__
+    if (S_ISCHR(st.st_mode)) {
+        /*
+         * The file is a char device (disk), which on FreeBSD isn't behind
+         * a pager, so set BDRV_O_NOCACHE unconditionally. This is needed
+         * so Qemu makes sure all IO operations on the device are aligned
+         * to sector size, or else FreeBSD will reject them with EINVAL.
+         */
+        bs->open_flags |= BDRV_O_NOCACHE;
+        s->open_flags |= O_DIRECT;
+    }
+#endif
 
 #ifdef CONFIG_XFS
     if (platform_test_xfs_fd(s->fd)) {
-- 
1.9.3 (Apple Git-50)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-21  9:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-20 16:39 [Qemu-devel] [PATCH] block: char devices on FreeBSD are not behind a pager Roger Pau Monne
2014-10-20 17:22 ` Kevin Wolf
2014-10-21  8:14   ` Roger Pau Monné
2014-10-21  9:36     ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).