From nobody Thu Nov 6 08:24:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539781975136286.3180504680489; Wed, 17 Oct 2018 06:12:55 -0700 (PDT) Received: from localhost ([::1]:36613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCld2-0008PY-Ro for importer@patchew.org; Wed, 17 Oct 2018 09:12:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gClPe-0005cb-GJ for qemu-devel@nongnu.org; Wed, 17 Oct 2018 08:58:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gClPd-0007pW-1e for qemu-devel@nongnu.org; Wed, 17 Oct 2018 08:58:58 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:34324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gClPb-00050u-Af; Wed, 17 Oct 2018 08:58:56 -0400 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gClOg-0000lc-GN; Wed, 17 Oct 2018 14:57:58 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gClOM-0005lB-KJ; Wed, 17 Oct 2018 15:57:38 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=wcp2s16wL8S9kjrJRlkXgo7DAE9dsk3DUsM6QAuiNvo=; b=gIByc1a3Wp4o0Bxc1W5fcpYXz6UDgMXZ+0x/vLRTzvOJf/qJdMqJn1KCoUG6hdCXn4emWJpLghD0HLYrSg55ZXz0XyyaRpSNKe/t4up8H5uFqJ+KpUAN3LgxDdUvVS92CTJG6LO6dMZ9ApXRKhbIsC+2KQ+wAKx5dws1BrqUpVDIwK0Lc6n3aZHadyjQy/gxZ9qV5Vyan7CcJOGoPRD4xN0lMF4Zsq0sdjsbm7mwOUhvmAvzy6X1EQHrN92MCpCu1bLtrLRh7i0YHpl2ZIDu70bRkmKW5ua0QFO4dWBdDmsS03yi0OB8peRQ1bMc85MrLubgk3obGTzqoz1lDZ151A==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 17 Oct 2018 15:57:30 +0300 Message-Id: <8bbea9f80f6bc15005f18a4065e86eda1b17dd5d.1539780785.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v2 14/14] block: Stop passing flags to bdrv_reopen_queue_child() 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that all callers are passing the new options using the QDict we no longer need the 'flags' parameter. This patch makes the following changes: 1) The update_options_from_flags() call is no longer necessary so it can be removed. 2) The update_flags_from_options() call is now used in all cases, and is moved down a few lines so it happens after the options QDict contains the final set of values. 3) The flags parameter is removed. Now the flags are initialized using the current value (for the top-level node) or the parent flags (after inherit_options()). In both cases the initial values are updated to reflect the new options in the QDict. This happens in bdrv_reopen_queue_child() (as explained above) and in bdrv_reopen_prepare(). Signed-off-by: Alberto Garcia --- block.c | 62 ++++++++++++++++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/block.c b/block.c index 194200908d..810b4083fe 100644 --- a/block.c +++ b/block.c @@ -2876,7 +2876,6 @@ BlockDriverState *bdrv_open(const char *filename, con= st char *reference, static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queu= e, BlockDriverState *bs, QDict *options, - int flags, const BdrvChildRole *role, QDict *parent_options, int parent_flags) @@ -2885,7 +2884,10 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Blo= ckReopenQueue *bs_queue, =20 BlockReopenQueueEntry *bs_entry; BdrvChild *child; - QDict *old_options, *explicit_options; + QDict *old_options, *explicit_options, *options_copy; + int flags; + QemuOpts *opts; + Error *local_err =3D NULL; =20 /* Make sure that the caller remembered to use a drained section. This= is * important to avoid graph changes between the recursive queuing here= and @@ -2911,22 +2913,11 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bl= ockReopenQueue *bs_queue, /* * Precedence of options: * 1. Explicitly passed in options (highest) - * 2. Set in flags (only for top level) - * 3. Retained from explicitly set options of bs - * 4. Inherited from parent node - * 5. Retained from effective options of bs + * 2. Retained from explicitly set options of bs + * 3. Inherited from parent node + * 4. Retained from effective options of bs */ =20 - if (!parent_options) { - /* - * Any setting represented by flags is always updated. If the - * corresponding QDict option is set, it takes precedence. Otherwi= se - * the flag is translated into a QDict option. The old setting of = bs is - * not considered. - */ - update_options_from_flags(options, flags); - } - /* Old explicitly set values (don't overwrite by inherited value) */ if (bs_entry) { old_options =3D qdict_clone_shallow(bs_entry->state.explicit_optio= ns); @@ -2940,23 +2931,10 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bl= ockReopenQueue *bs_queue, =20 /* Inherit from parent node */ if (parent_options) { - QemuOpts *opts; - QDict *options_copy; - Error *local_err =3D NULL; - assert(!flags); + flags =3D 0; role->inherit_options(&flags, options, parent_flags, parent_option= s); - options_copy =3D qdict_clone_shallow(options); - opts =3D qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abor= t); - qemu_opts_absorb_qdict(opts, options_copy, &local_err); - /* Don't call update_flags_from_options() if the options are wrong. - * bdrv_reopen_prepare() will later return an error. */ - if (!local_err) { - update_flags_from_options(&flags, opts); - } else { - error_free(local_err); - } - qemu_opts_del(opts); - qobject_unref(options_copy); + } else { + flags =3D bdrv_get_flags(bs); } =20 /* Old values are used for options that aren't set yet */ @@ -2964,6 +2942,20 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Blo= ckReopenQueue *bs_queue, bdrv_join_options(bs, options, old_options); qobject_unref(old_options); =20 + /* We have the final set of options so let's update the flags */ + options_copy =3D qdict_clone_shallow(options); + opts =3D qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort); + qemu_opts_absorb_qdict(opts, options_copy, &local_err); + /* Don't call update_flags_from_options() if the options are wrong. + * bdrv_reopen_prepare() will later return an error. */ + if (!local_err) { + update_flags_from_options(&flags, opts); + } else { + error_free(local_err); + } + qemu_opts_del(opts); + qobject_unref(options_copy); + /* bdrv_open_inherit() sets and clears some additional flags internall= y */ flags &=3D ~BDRV_O_PROTOCOL; if (flags & BDRV_O_RDWR) { @@ -3003,7 +2995,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, qdict_extract_subqdict(options, &new_child_options, child_key_dot); g_free(child_key_dot); =20 - bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, 0, + bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, child->role, options, flags); } =20 @@ -3014,9 +3006,7 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue = *bs_queue, BlockDriverState *bs, QDict *options) { - int flags =3D bdrv_get_flags(bs); - return bdrv_reopen_queue_child(bs_queue, bs, options, flags, - NULL, NULL, 0); + return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, NULL, 0); } =20 /* --=20 2.11.0