From nobody Tue Nov 4 10:49:35 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 1530272643158429.49089920288645; Fri, 29 Jun 2018 04:44:03 -0700 (PDT) Received: from localhost ([::1]:41373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYroo-0006Ii-D6 for importer@patchew.org; Fri, 29 Jun 2018 07:44:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrjC-0001rp-67 for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYriz-0005HR-HF for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:14 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:41379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYriz-0004Tf-3K; Fri, 29 Jun 2018 07:38:01 -0400 Received: from 88-114-101-78.elisa-laajakaista.fi ([88.114.101.78] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fYriP-0006P0-Bo; Fri, 29 Jun 2018 13:37:25 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fYriA-0008Ka-NE; Fri, 29 Jun 2018 14:37:10 +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=n2AOkzT1cgPSDRyqA/71NhbWcv65omn459N+4vTZMoA=; b=HyYqqFvbTvAVoCuyo3C/6qK7h5qjPXYHZSGFZ4tGmiECgc87mNOiylIpFlq9khGgFpY3aACjwV+4/sxuf+WbMauVCC01E7jjaU0NGF0krPWvAM1L67MTmtovc7RxO0lwf3DzI6/nbeppnQsXEmjiOmKO5+Dj12mZSL+BuYUVCbeH4E40v+umjfyt/x9+V3ozKv+y+L6FJRpAE9qYkzz1pkNdHpwTvuRR/0v52Fg8+RM5Rhz2oTN276evcAxuxfHK5ZkQ8LZWdP8AFgW+7nJd2+Xmc8HzeyHYX1WMcDBPbJpX0Jn7qFRukjCHAwxPul03PwcGs5HRifFZwZHPNAMSZA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 14:36:59 +0300 Message-Id: <6d4bbe2a722855e10655f9f5ee1dbf4e94f62e59.1530270904.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 1/5] qdict: Make qdict_extract_subqdict() accept dst = NULL 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" This function extracts all options from a QDict starting with a certain prefix and puts them in a new QDict. We'll have a couple of cases where we simply want to discard those options instead of copying them, and that's what this patch does. Signed-off-by: Alberto Garcia --- qobject/block-qdict.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c index 36129e7379..ef443cb8d5 100644 --- a/qobject/block-qdict.c +++ b/qobject/block-qdict.c @@ -158,20 +158,25 @@ void qdict_flatten(QDict *qdict) qdict_flatten_qdict(qdict, qdict, NULL); } =20 -/* extract all the src QDict entries starting by start into dst */ +/* extract all the src QDict entries starting by start into dst. + * If dst is NULL then the entries are simply removed from src. */ void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start) =20 { const QDictEntry *entry, *next; const char *p; =20 - *dst =3D qdict_new(); + if (dst) { + *dst =3D qdict_new(); + } entry =3D qdict_first(src); =20 while (entry !=3D NULL) { next =3D qdict_next(src, entry); if (strstart(entry->key, start, &p)) { - qdict_put_obj(*dst, p, qobject_ref(entry->value)); + if (dst) { + qdict_put_obj(*dst, p, qobject_ref(entry->value)); + } qdict_del(src, entry->key); } entry =3D next; --=20 2.11.0 From nobody Tue Nov 4 10:49:35 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 1530272988259907.1594586174833; Fri, 29 Jun 2018 04:49:48 -0700 (PDT) Received: from localhost ([::1]:41403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYruN-0002eG-EO for importer@patchew.org; Fri, 29 Jun 2018 07:49:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrjC-0001rn-39 for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYriz-0005HK-HF for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:14 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:41367) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYriz-0004S5-3M; Fri, 29 Jun 2018 07:38:01 -0400 Received: from 88-114-101-78.elisa-laajakaista.fi ([88.114.101.78] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fYriN-0006Oc-Qg; Fri, 29 Jun 2018 13:37:23 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fYriA-0008Kc-OV; Fri, 29 Jun 2018 14:37:10 +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=0IyCVGbYMU2GySxOG0dMh7VqSurr7zCORbVPBKr/k4A=; b=GsVvzW6sAauVUOn132BTuzss/IAqF6HpTq6Qp0Ith7CB5UtH+a7aApmpChT0cNbDVLN03j6C1Hky3C4snmltYUFMFmpjG+ylKkgQMM3d17tWf9msoW+Uxi+OG9GE0AEpOCIbPql8bRHDvqOi0XDyjfQYqi4bPqsVrUxhDxonHPGT5y6waiR0j50pJ1QGEGaiMJbn30pQRwOSFIY5f/pKTBklPbFxXQ11ft4f2yITfo2JJiQg5zm+iSj1CoWEUYA0Hd+YAkE1lxx5uv87hgDfKzV6jPDOP5nOwENaZEY3zHwmqq6JkDbrzlP3DdDxB+Xjc3IFOaOOAr164Ku7zTjGqQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 14:37:00 +0300 Message-Id: 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 2/5] block: Remove children options from bs->{options, explicit_options} 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" When bdrv_open_inherit() opens a BlockDriverState the options QDict can contain options for some of its children, passed in the form of child-name.option=3Dvalue So while each child is opened with that subset of options, those same options remain stored in the parent BDS, leaving (at least) two copies of each one of them ("child-name.option=3Dvalue" in the parent and "option=3Dvalue" in the child). Having the children options stored in the parent is unnecessary and it can easily lead to an inconsistent state: $ qemu-img create -f qcow2 hd0.qcow2 10M $ qemu-img create -f qcow2 -b hd0.qcow2 hd1.qcow2 $ qemu-img create -f qcow2 -b hd1.qcow2 hd2.qcow2 $ $QEMU -drive file=3Dhd2.qcow2,node-name=3Dhd2,backing.node-name=3Dhd1 This opens a chain of images hd0 <- hd1 <- hd2. Now let's remove hd1 using block_stream: (qemu) block_stream hd2 0 hd0.qcow2 After this hd2 contains backing.node-name=3Dhd1, which is no longer correct because hd1 doesn't exist anymore. This patch removes all children options from the parent dictionaries at the end of bdrv_open_inherit() and bdrv_reopen_queue_child(). Signed-off-by: Alberto Garcia --- block.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/block.c b/block.c index 1b8147c1b3..5aaed424b9 100644 --- a/block.c +++ b/block.c @@ -2594,6 +2594,7 @@ static BlockDriverState *bdrv_open_inherit(const char= *filename, BlockBackend *file =3D NULL; BlockDriverState *bs; BlockDriver *drv =3D NULL; + BdrvChild *child; const char *drvname; const char *backing; Error *local_err =3D NULL; @@ -2777,6 +2778,15 @@ static BlockDriverState *bdrv_open_inherit(const cha= r *filename, } } =20 + /* Remove all children options from bs->options and bs->explicit_optio= ns */ + QLIST_FOREACH(child, &bs->children, next) { + char *child_key_dot; + child_key_dot =3D g_strdup_printf("%s.", child->name); + qdict_extract_subqdict(bs->explicit_options, NULL, child_key_dot); + qdict_extract_subqdict(bs->options, NULL, child_key_dot); + g_free(child_key_dot); + } + bdrv_refresh_filename(bs); =20 /* Check if any unknown options were used */ @@ -2986,6 +2996,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(Bloc= kReopenQueue *bs_queue, } =20 child_key_dot =3D g_strdup_printf("%s.", child->name); + qdict_extract_subqdict(explicit_options, NULL, child_key_dot); qdict_extract_subqdict(options, &new_child_options, child_key_dot); g_free(child_key_dot); =20 --=20 2.11.0 From nobody Tue Nov 4 10:49:35 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 1530272886641314.4084867518295; Fri, 29 Jun 2018 04:48:06 -0700 (PDT) Received: from localhost ([::1]:41393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrsj-0001Bt-SY for importer@patchew.org; Fri, 29 Jun 2018 07:48:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrjB-0001rV-L1 for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYriz-0005H9-HU for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:13 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:41375) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYriz-0004Td-3L; Fri, 29 Jun 2018 07:38:01 -0400 Received: from 88-114-101-78.elisa-laajakaista.fi ([88.114.101.78] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fYriP-0006Oy-BR; Fri, 29 Jun 2018 13:37:25 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fYriA-0008Ke-Pi; Fri, 29 Jun 2018 14:37:10 +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=VA/ds4n4neF9fJEbqQKvQN5fNNIWKTWttKWrPXVHeoo=; b=IGm71QPa8ALvF01ZcPUqhk3cEVuY6WPaI4SRScHES1Zk7ppEBkV1cFZRZlFZuQw8bVSgNq+MMwd/YHLGfkyC/9bzkSm86wUYnQWmWEnHpl4iQnqYt9OC+EqiqcOUPLhbYG2rTe3iajlyQmh5W31m/WnR+4n8vur0ITijbNZc69qXxuiXl+L5E893vth+93uNzXqpSbGgdIzr4x7CFrvo/MQUIdDjyDsFmGBrpP/smFBuJJK7jTnGEdMmYDes8+M3pJgJ6cVEPQrZhIoMTAvaU+aAwdKj3YwEoayuAOIi6S0FwIUTwy45sMuObJdt7HVOdjHO1wWcI+A66/imKaPa+g==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 14:37:01 +0300 Message-Id: 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 3/5] block: Simplify bdrv_reopen_abort() 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" If a bdrv_reopen_multiple() call fails, then the explicit_options QDict has to be deleted for every entry in the reopen queue. This must happen regardless of whether that entry's bdrv_reopen_prepare() call succeeded or not. This patch simplifies the cleanup code a bit. Signed-off-by: Alberto Garcia --- block.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 5aaed424b9..48e8f4814c 100644 --- a/block.c +++ b/block.c @@ -3060,9 +3060,10 @@ int bdrv_reopen_multiple(AioContext *ctx, BlockReope= nQueue *bs_queue, Error **er =20 cleanup: QSIMPLEQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) { - if (ret && bs_entry->prepared) { - bdrv_reopen_abort(&bs_entry->state); - } else if (ret) { + if (ret) { + if (bs_entry->prepared) { + bdrv_reopen_abort(&bs_entry->state); + } qobject_unref(bs_entry->state.explicit_options); } qobject_unref(bs_entry->state.options); @@ -3351,8 +3352,6 @@ void bdrv_reopen_abort(BDRVReopenState *reopen_state) drv->bdrv_reopen_abort(reopen_state); } =20 - qobject_unref(reopen_state->explicit_options); - bdrv_abort_perm_update(reopen_state->bs); } =20 --=20 2.11.0 From nobody Tue Nov 4 10:49:35 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 15302727147151023.3683311632626; Fri, 29 Jun 2018 04:45:14 -0700 (PDT) Received: from localhost ([::1]:41378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrpt-0007MO-B4 for importer@patchew.org; Fri, 29 Jun 2018 07:45:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrjE-0001sT-68 for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYriz-0005HS-He for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:16 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:41378) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYriz-0004Tg-3N; Fri, 29 Jun 2018 07:38:01 -0400 Received: from 88-114-101-78.elisa-laajakaista.fi ([88.114.101.78] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fYriP-0006Oz-BV; Fri, 29 Jun 2018 13:37:25 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fYriA-0008Kg-R3; Fri, 29 Jun 2018 14:37:10 +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=QxL5LWzrie8mVYyKbhrlEw3MTsS+tXADdGh8zePZEAs=; b=B9oF/BGp63YkcKZV1jo2tnhHck+hQn0VpRFlFe70lCCQkOo5ewhjvSQ+JQDYiNLovbDhsPutOilTbSlQIrqnA5/wc1yUxfARi6dORA47AvH2JVeZ4Xgb8LOvz1Okf4Fbj1JYdku7neLvi9Xrw/XJWhwW6UhBlb+ySDO6VQYgpf+dm9VG6g7vGM/cALZxknXF9iIa5vJg9MstJCj6WrhpDSxTKoMJ5bB5G/cAKgBpZVVWWkuV8nqaAULgcEXe3dpWd+VPLMOMi2vzcpWOmtk6xvFPd7HXTU8jgMGlJKPicQKyLCCAeOkBIus/M3uwm4Tx5e0zED9r9QjKN3656SavyQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 14:37:02 +0300 Message-Id: <7115bcf1fb0c856f96690225eed964f95fdc0cca.1530270904.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 4/5] block: Update bs->options if bdrv_reopen() succeeds 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" If bdrv_reopen() succeeds then bs->explicit_options is updated with the new values, but bs->options never changes. Here's an example: { "execute": "blockdev-add", "arguments": { "driver": "qcow2", "node-name": "hd0", "overlap-check": "all", "file": { "driver": "file", "filename": "hd0.qcow2" } } } After this, both bs->options and bs->explicit_options contain "overlap-check": "all". Now let's change that using qemu-io's reopen command: (qemu) qemu-io hd0 "reopen -o overlap-check=3Dnone" After this, bs->explicit_options contains the new value but bs->options still keeps the old one. This patch updates bs->options after a BDS has been successfully reopened. Signed-off-by: Alberto Garcia --- block.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 48e8f4814c..58c8e8e677 100644 --- a/block.c +++ b/block.c @@ -3065,8 +3065,8 @@ cleanup: bdrv_reopen_abort(&bs_entry->state); } qobject_unref(bs_entry->state.explicit_options); + qobject_unref(bs_entry->state.options); } - qobject_unref(bs_entry->state.options); g_free(bs_entry); } g_free(bs_queue); @@ -3166,6 +3166,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state= , BlockReopenQueue *queue, Error *local_err =3D NULL; BlockDriver *drv; QemuOpts *opts; + QDict *orig_reopen_opts; const char *value; bool read_only; =20 @@ -3173,6 +3174,11 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, assert(reopen_state->bs->drv !=3D NULL); drv =3D reopen_state->bs->drv; =20 + /* This function and each driver's bdrv_reopen_prepare() remove + * entries from reopen_state->options as they are processed, so + * we need to make a copy of the original QDict. */ + orig_reopen_opts =3D qdict_clone_shallow(reopen_state->options); + /* Process generic block layer options */ opts =3D qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, reopen_state->options, &local_err); @@ -3279,8 +3285,13 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, =20 ret =3D 0; =20 + /* Restore the original reopen_state->options QDict */ + qobject_unref(reopen_state->options); + reopen_state->options =3D qobject_ref(orig_reopen_opts); + error: qemu_opts_del(opts); + qobject_unref(orig_reopen_opts); return ret; } =20 @@ -3310,8 +3321,10 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_stat= e) =20 /* set BDS specific flags now */ qobject_unref(bs->explicit_options); + qobject_unref(bs->options); =20 bs->explicit_options =3D reopen_state->explicit_options; + bs->options =3D reopen_state->options; bs->open_flags =3D reopen_state->flags; bs->read_only =3D !(reopen_state->flags & BDRV_O_RDWR); =20 --=20 2.11.0 From nobody Tue Nov 4 10:49:35 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 1530272414857579.3409131406988; Fri, 29 Jun 2018 04:40:14 -0700 (PDT) Received: from localhost ([::1]:41335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrl8-0003QQ-4b for importer@patchew.org; Fri, 29 Jun 2018 07:40:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrjC-0001rm-2V for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYriz-0005HF-Fj for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:14 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:41366) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYriz-0004S4-3H; Fri, 29 Jun 2018 07:38:01 -0400 Received: from 88-114-101-78.elisa-laajakaista.fi ([88.114.101.78] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fYriN-0006Od-QP; Fri, 29 Jun 2018 13:37:23 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fYriA-0008Ki-SH; Fri, 29 Jun 2018 14:37:10 +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=88NXl434YMlTmh+OyWsW/u9JPGvXSHWrTzlQsh/RkKw=; b=XSxTWVu5eVOWhmxqPMLpJPAAg5l6wEiPzQyDMoSrocTwuNIY3XFZeHk/QZWV83RuHQ1lyKEodfPHENkHGPhL9PNyRFhPWfGjUQR2uOUf6ILX3Z5X9e+5ch7yMSlwA2p5DPhYcQNQRVNO20fJmcBNOYGjELCYqCTZSvso+yV6ITB+qMm0ZEEwwrSllasUUL++uvXOueSUN8We2fLe8aQgzDd/iDmlEfbxikbwpwVrR7gO0ZPBCtL5opRMxE+v/qz36mS1oU2lY9uKruJxlRZ4/U/j8jnpnHqolw0PSK3DBin8kIHcvbVQ/gH4DH+MneZLy4rugBxNAOFNFVApwXSq8g==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 14:37:03 +0300 Message-Id: <0ac388e86dec1afbff4b5e4e6ade1f1fb7b2d7ff.1530270904.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 5/5] block: Simplify append_open_options() 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" This function returns a BDS's driver-specific options, excluding also those from its children. Since we have just removed all children options from bs->options there's no need to do this last step. We allow references to children, though ("backing": "node0"), so those we still have to remove. Signed-off-by: Alberto Garcia --- block.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 58c8e8e677..9b91b01849 100644 --- a/block.c +++ b/block.c @@ -5210,16 +5210,13 @@ static bool append_open_options(QDict *d, BlockDriv= erState *bs) QemuOptDesc *desc; BdrvChild *child; bool found_any =3D false; - const char *p; =20 for (entry =3D qdict_first(bs->options); entry; entry =3D qdict_next(bs->options, entry)) { - /* Exclude options for children */ + /* Exclude node-name references to children */ QLIST_FOREACH(child, &bs->children, next) { - if (strstart(qdict_entry_key(entry), child->name, &p) - && (!*p || *p =3D=3D '.')) - { + if (!strcmp(entry->key, child->name)) { break; } } --=20 2.11.0