From patchwork Thu Sep 15 14:53:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 9334009 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 884C0601C2 for ; Thu, 15 Sep 2016 15:10:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BEC92985B for ; Thu, 15 Sep 2016 15:10:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70649298FE; Thu, 15 Sep 2016 15:10:30 +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 C668B2985B for ; Thu, 15 Sep 2016 15:10:29 +0000 (UTC) Received: from localhost ([::1]:35375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkYJ2-0003ms-H1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 15 Sep 2016 11:10:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkY30-0006eZ-DE for qemu-devel@nongnu.org; Thu, 15 Sep 2016 10:53:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkY2v-0003SI-AC for qemu-devel@nongnu.org; Thu, 15 Sep 2016 10:53:53 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:61950 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkY2v-0003Q9-28; Thu, 15 Sep 2016 10:53:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2A+AwBotdpX/5tjdVtcHAEBBAEBCgEBgzoBAQEBAR6BU40zlXMBAQEBAQEFAYESAY9Zgi6CD4IDhh4CgVs4FAECAQEBAQEBAV4nhGICBCdSED8SPBsZiE4BwXIxhWmCSYdahRAFjyGKR49ZgW6IGIVfSIY0iV0eNoIugjxthwEBAQE X-IPAS-Result: A2A+AwBotdpX/5tjdVtcHAEBBAEBCgEBgzoBAQEBAR6BU40zlXMBAQEBAQEFAYESAY9Zgi6CD4IDhh4CgVs4FAECAQEBAQEBAV4nhGICBCdSED8SPBsZiE4BwXIxhWmCSYdahRAFjyGKR49ZgW6IGIVfSIY0iV0eNoIugjxthwEBAQE X-IronPort-AV: E=Sophos;i="5.30,339,1470693600"; d="scan'208";a="189830353" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 15 Sep 2016 16:53:24 +0200 Received: from a88-114-146-42.elisa-laajakaista.fi ([88.114.146.42] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim) id 1bkY2V-0007dM-Lg; Thu, 15 Sep 2016 16:53:23 +0200 Received: from berto by perseus.local with local (Exim 4.87) (envelope-from ) id 1bkY2I-00009Z-5l; Thu, 15 Sep 2016 17:53:10 +0300 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 15 Sep 2016 17:53:01 +0300 Message-Id: <8175bc5b794fe3c56e8b5a60e90a53a4011b65a4.1473950317.git.berto@igalia.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Subject: [Qemu-devel] [PATCH v2 3/7] block: Update bs->open_flags earlier in bdrv_open_common() 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 , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We're only doing this immediately before opening the image, but bs->open_flags is used earlier in the function. At the moment this is not causing problems because none of the checked flags are modified by update_flags_from_options(), but this will change when we introduce the "read-only" option. This patch calls update_flags_from_options() at the beginning of the function, immediately after creating the QemuOpts. Signed-off-by: Alberto Garcia Reviewed-by: Kevin Wolf --- block.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 7cae841..f56d703 100644 --- a/block.c +++ b/block.c @@ -913,6 +913,8 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, goto fail_opts; } + update_flags_from_options(&bs->open_flags, opts); + driver_name = qemu_opt_get(opts, "driver"); drv = bdrv_find_format(driver_name); assert(drv != NULL); @@ -974,9 +976,6 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild *file, bs->drv = drv; bs->opaque = g_malloc0(drv->instance_size); - /* Apply cache mode options */ - update_flags_from_options(&bs->open_flags, opts); - /* Open the image, either directly or using a protocol */ open_flags = bdrv_open_flags(bs, bs->open_flags); if (drv->bdrv_file_open) {