From patchwork Wed Jan 25 16:42:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 9537465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6CDE26042C for ; Wed, 25 Jan 2017 16:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CB1E2818E for ; Wed, 25 Jan 2017 16:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EF66281B7; Wed, 25 Jan 2017 16:46:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3E4652818E for ; Wed, 25 Jan 2017 16:45:59 +0000 (UTC) Received: from localhost ([::1]:32893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWQhq-00051J-CA for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 Jan 2017 11:45:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWQf0-0002xz-DW for qemu-devel@nongnu.org; Wed, 25 Jan 2017 11:43:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWQex-0002xY-Ac for qemu-devel@nongnu.org; Wed, 25 Jan 2017 11:43:02 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:41197 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cWQew-0002xO-O4 for qemu-devel@nongnu.org; Wed, 25 Jan 2017 11:42:59 -0500 Received: from iris.sw.ru (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id v0PGgqXE032235; Wed, 25 Jan 2017 19:42:53 +0300 (MSK) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Date: Wed, 25 Jan 2017 19:42:52 +0300 Message-Id: <1485362572-7246-1-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 1/1] block: add missed BDRV_O_NOCACHE when block device is opened without file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , "Denis V. Lunev" , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Technically there is a problem when the guest DVD is created by libvirt with AIO mode 'native' on Linux. Current QEMU is unable to start the domain configured as follows: The problem comes from the combination of 'cache' and 'io' options. 'io' option is common option and it is removed from block driver specific options. 'cache' originally is not. The patch makes 'cache' option common. This works fine as long as cdrom media insertion later on. Signed-off-by: Denis V. Lunev CC: Kevin Wolf CC: Max Reitz --- blockdev.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) May be this has already discussed, but still. AIO=native for CDROM without media seems important case. diff --git a/blockdev.c b/blockdev.c index 245e1e1..004dcde 100644 --- a/blockdev.c +++ b/blockdev.c @@ -374,6 +374,13 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, return; } } + + if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_NO_FLUSH, false)) { + *bdrv_flags |= BDRV_O_NO_FLUSH; + } + if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_DIRECT, false)) { + *bdrv_flags |= BDRV_O_NOCACHE; + } } /* disk I/O throttling */ @@ -569,11 +576,8 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, /* bdrv_open() defaults to the values in bdrv_flags (for compatibility * with other callers) rather than what we want as the real defaults. * Apply the defaults here instead. */ - qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_DIRECT, "off"); - qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off"); qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? "on" : "off"); - assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0); if (runstate_check(RUN_STATE_INMIGRATE)) { bdrv_flags |= BDRV_O_INACTIVE; @@ -3996,6 +4000,14 @@ QemuOptsList qemu_common_drive_opts = { .type = QEMU_OPT_STRING, .help = "write error action", },{ + .name = BDRV_OPT_CACHE_DIRECT, + .type = QEMU_OPT_BOOL, + .help = "Bypass software writeback cache on the host", + }, { + .name = BDRV_OPT_CACHE_NO_FLUSH, + .type = QEMU_OPT_BOOL, + .help = "Ignore flush requests", + }, { .name = BDRV_OPT_READ_ONLY, .type = QEMU_OPT_BOOL, .help = "open drive file as read-only",