Received: from eggs.gnu.org ([2001:4830:134:3::10]:47331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgFzh-0001TC-M5 for qemu-devel@nongnu.org; Mon, 20 Oct 2014 12:39:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgFzc-0001fD-2L for qemu-devel@nongnu.org; Mon, 20 Oct 2014 12:39:41 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:24956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgFzb-0001eN-UZ for qemu-devel@nongnu.org; Mon, 20 Oct 2014 12:39:36 -0400 From: Roger Pau Monne Date: Mon, 20 Oct 2014 18:39:27 +0200 Message-ID: <1413823167-26619-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH] block: char devices on FreeBSD are not behind a pager List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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é Cc: Kevin Wolf Cc: Stefan Hajnoczi --- 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)