From nobody Mon Feb 9 09:29:12 2026 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 1528991686708404.0701264213975; Thu, 14 Jun 2018 08:54:46 -0700 (PDT) Received: from localhost ([::1]:41426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTUa8-0004ZM-RC for importer@patchew.org; Thu, 14 Jun 2018 11:54:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTUVN-0000jF-1r for qemu-devel@nongnu.org; Thu, 14 Jun 2018 11:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTUVI-0003nU-79 for qemu-devel@nongnu.org; Thu, 14 Jun 2018 11:49:44 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:37196) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTUVH-0003k1-FL; Thu, 14 Jun 2018 11:49:40 -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 1fTUVF-0004dw-Mz; Thu, 14 Jun 2018 17:49:37 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fTUUv-0008Nf-8t; Thu, 14 Jun 2018 18:49:17 +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=fTwdCsJCQcJ9cgnir8tXbvd4eyeykX+0bFKzQ0Yf1fI=; b=TO9i7aZEUh8yHYlHNpbXKpmWMuL+ybD5/hGLrDlc1/g8bMIGp075o4rg89xk7G1cvxF1LrbND8bnV0KytQgMdBRUTVnXAi2t/fuHijp5vs39wkr+zlr3Wdpcstb5GnW/WBAK7bvUDoPXaD2Bjt/z1dzeFr8/oGBXaZP1J7EORZk0PeSklYN2JUdp6BWeOdLQy1CEnU5w/ZOQDpBzpDTYn/i6EP5KE2YEo3tXFkFOJkx8qWC1iKmYDBZOSxo9NUZ0nwHhASAepCglbi4GROq6oaFColfhp1IRZQTu5vRw9VTeDMpqDjjtRB43mfq2H6DvwJ8+//Z5TyBGR3/MLAOgcA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2018 18:49:02 +0300 Message-Id: <4a1c8fb9816de2115d08284c36d7a718b5e48de6.1528991017.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] [RFC PATCH 05/10] block: Add 'keep_old_opts' parameter to bdrv_reopen_queue() 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, Markus Armbruster , 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" The bdrv_reopen_queue() function is used to create a queue with the BDSs that are going to be reopened and their new options. Once the queue is ready bdrv_reopen_multiple() is called to perform the operation. The original options from each one of the BDSs are kept, with the new options passed to bdrv_reopen_queue() applied on top of them. For "x-blockdev-reopen" we want a function that behaves much like "blockdev-add". We want to ignore the previous set of options so that only the ones actually specified by the user are applied, with the rest having their default values. We can achieve this by adding a new parameter to bdrv_reopen_queue() that specifies whether the old set of options is kept or discarded when building the reopen queue. All current callers will set that parameter to true, but x-blockdev-reopen will set it to false. Signed-off-by: Alberto Garcia --- block.c | 34 +++++++++++++++++++--------------- block/replication.c | 4 ++-- include/block/block.h | 3 ++- qemu-io-cmds.c | 2 +- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/block.c b/block.c index a741300fae..0b9268a48d 100644 --- a/block.c +++ b/block.c @@ -2850,7 +2850,8 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, int flags, const BdrvChildRole *role, QDict *parent_options, - int parent_flags) + int parent_flags, + bool keep_old_opts) { assert(bs !=3D NULL); =20 @@ -2899,13 +2900,13 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bl= ockReopenQueue *bs_queue, } =20 /* 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); - } else { - old_options =3D qdict_clone_shallow(bs->explicit_options); + if (bs_entry || keep_old_opts) { + old_options =3D qdict_clone_shallow(bs_entry ? + bs_entry->state.explicit_options= : + bs->explicit_options); + bdrv_join_options(bs, options, old_options); + qobject_unref(old_options); } - bdrv_join_options(bs, options, old_options); - qobject_unref(old_options); =20 explicit_options =3D qdict_clone_shallow(options); =20 @@ -2923,10 +2924,12 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bl= ockReopenQueue *bs_queue, qobject_unref(options_copy); } =20 - /* Old values are used for options that aren't set yet */ - old_options =3D qdict_clone_shallow(bs->options); - bdrv_join_options(bs, options, old_options); - qobject_unref(old_options); + if (keep_old_opts) { + /* Old values are used for options that aren't set yet */ + old_options =3D qdict_clone_shallow(bs->options); + bdrv_join_options(bs, options, old_options); + qobject_unref(old_options); + } =20 /* bdrv_open_inherit() sets and clears some additional flags internall= y */ flags &=3D ~BDRV_O_PROTOCOL; @@ -2967,7 +2970,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, g_free(child_key_dot); =20 bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, 0, - child->role, options, flags); + child->role, options, flags, keep_old_opts= ); } =20 return bs_queue; @@ -2975,10 +2978,11 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bl= ockReopenQueue *bs_queue, =20 BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, - QDict *options, int flags) + QDict *options, int flags, + bool keep_old_opts) { return bdrv_reopen_queue_child(bs_queue, bs, options, flags, - NULL, NULL, 0); + NULL, NULL, 0, keep_old_opts); } =20 /* @@ -3049,7 +3053,7 @@ int bdrv_reopen(BlockDriverState *bs, int bdrv_flags,= Error **errp) =20 bdrv_subtree_drained_begin(bs); =20 - queue =3D bdrv_reopen_queue(NULL, bs, NULL, bdrv_flags); + queue =3D bdrv_reopen_queue(NULL, bs, NULL, bdrv_flags, true); ret =3D bdrv_reopen_multiple(bdrv_get_aio_context(bs), queue, &local_e= rr); if (local_err !=3D NULL) { error_propagate(errp, local_err); diff --git a/block/replication.c b/block/replication.c index 826db7b304..af984c29dd 100644 --- a/block/replication.c +++ b/block/replication.c @@ -401,12 +401,12 @@ static void reopen_backing_file(BlockDriverState *bs,= bool writable, =20 if (orig_hidden_flags !=3D new_hidden_flags) { reopen_queue =3D bdrv_reopen_queue(reopen_queue, s->hidden_disk->b= s, NULL, - new_hidden_flags); + new_hidden_flags, true); } =20 if (!(orig_secondary_flags & BDRV_O_RDWR)) { reopen_queue =3D bdrv_reopen_queue(reopen_queue, s->secondary_disk= ->bs, - NULL, new_secondary_flags); + NULL, new_secondary_flags, true); } =20 if (reopen_queue) { diff --git a/include/block/block.h b/include/block/block.h index 9306c986ef..c8654dde65 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -267,7 +267,8 @@ BlockDriverState *bdrv_new_open_driver(BlockDriver *drv= , const char *node_name, int flags, Error **errp); BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, BlockDriverState *bs, - QDict *options, int flags); + QDict *options, int flags, + bool keep_old_opts); int bdrv_reopen_multiple(AioContext *ctx, BlockReopenQueue *bs_queue, Erro= r **errp); int bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp); int bdrv_reopen_prepare(BDRVReopenState *reopen_state, diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 5bf5f28178..4742358b1a 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -2050,7 +2050,7 @@ static int reopen_f(BlockBackend *blk, int argc, char= **argv) qemu_opts_reset(&reopen_opts); =20 bdrv_subtree_drained_begin(bs); - brq =3D bdrv_reopen_queue(NULL, bs, opts, flags); + brq =3D bdrv_reopen_queue(NULL, bs, opts, flags, true); bdrv_reopen_multiple(bdrv_get_aio_context(bs), brq, &local_err); bdrv_subtree_drained_end(bs); =20 --=20 2.11.0