From patchwork Mon Mar 7 13:42:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 592951 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 E79F41401DE for ; Tue, 8 Mar 2016 00:42:54 +1100 (AEDT) Received: from localhost ([::1]:55902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acvQz-00078O-3X for incoming@patchwork.ozlabs.org; Mon, 07 Mar 2016 08:42:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acvQc-0006Z7-B5 for qemu-devel@nongnu.org; Mon, 07 Mar 2016 08:42:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1acvQY-0004kY-H6 for qemu-devel@nongnu.org; Mon, 07 Mar 2016 08:42:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acvQT-0004ju-Qe; Mon, 07 Mar 2016 08:42:21 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 6E4E7C00F1D0; Mon, 7 Mar 2016 13:42:21 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-78.ams2.redhat.com [10.36.116.78]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u27DgJ75003876; Mon, 7 Mar 2016 08:42:20 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 7 Mar 2016 14:42:16 +0100 Message-Id: <1457358136-22346-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Subject: [Qemu-devel] [PATCH] block: Fix cache mode defaults in bds_tree_init() 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 Without setting explicit defaults in the options, blockdev-add without an ID ended up defaulting to writethrough. It should be writeback as documented. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- blockdev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/blockdev.c b/blockdev.c index eecd78d..1824cae 100644 --- a/blockdev.c +++ b/blockdev.c @@ -675,6 +675,13 @@ static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp) goto fail; } + /* 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_WB, "on"); + qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_DIRECT, "off"); + qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off"); + if (runstate_check(RUN_STATE_INMIGRATE)) { bdrv_flags |= BDRV_O_INACTIVE; }