From patchwork Mon Oct 20 16:39:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 401201 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2022E140097 for ; Tue, 21 Oct 2014 03:40:09 +1100 (AEDT) Received: from localhost ([::1]:45901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgG02-0001oC-Ge for incoming@patchwork.ozlabs.org; Mon, 20 Oct 2014 12:40:02 -0400 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 X-IronPort-AV: E=Sophos;i="5.04,757,1406592000"; d="scan'208";a="184231342" From: Roger Pau Monne To: Date: Mon, 20 Oct 2014 18:39:27 +0200 Message-ID: <1413823167-26619-1-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.9.3 (Apple Git-50) MIME-Version: 1.0 X-DLP: MIA1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: Kevin Wolf , Stefan Hajnoczi , Roger Pau Monne Subject: [Qemu-devel] [PATCH] block: char devices on FreeBSD are not behind a pager X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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)) {