From nobody Wed Nov 5 18:43:36 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 1535985619606297.43546101918196; Mon, 3 Sep 2018 07:40:19 -0700 (PDT) Received: from localhost ([::1]:45408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwq1a-0001Qy-L1 for importer@patchew.org; Mon, 03 Sep 2018 10:40:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwpwh-0004G5-SP for qemu-devel@nongnu.org; Mon, 03 Sep 2018 10:35:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwpwc-0000Xy-IL for qemu-devel@nongnu.org; Mon, 03 Sep 2018 10:35:15 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:38254) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwpwc-0000OQ-0P; Mon, 03 Sep 2018 10:35:10 -0400 Received: from 91-158-71-53.elisa-laajakaista.fi ([91.158.71.53] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fwpvz-0007gd-OL; Mon, 03 Sep 2018 16:34:31 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fwpvk-0002yy-4X; Mon, 03 Sep 2018 17:34:16 +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=MBlzY5x3xQw3A+ySANGywR8KEiDun6TX6P+ZbkNvCss=; b=hnYr+cim4laSlbWjpCGWrZaxaJJ5R/nMtfmAMWhVetJNdFwHbPMaznIClvdMnFZeK3bxzCnTiYGLAao/oDKsRQtNM1xz3hpqNzcwO9yqi/qSSe80gwn0B+KrdhRwNC07fHtf+2ndKyqYaoa0rhcpEwIbfpMlSMSDCXvsB8B8d/lXbydYAhDx8FuVPmzMJ+7OiwZPAIt30YGFrxcWy6FNUdC1NuKINb5N7kBmZO1M8d79sisfeYRnZOng+YuBOMOcR06g6HgIfSOfsBRirI+chga426kijOS4hGUjZaN1TZz6/9NfKXdrawT6dKoiCjm5edI4QCWd9DNLCqNPHFQ49Q==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Mon, 3 Sep 2018 17:34:03 +0300 Message-Id: <4e52d3696c178d172a00f9e774c97286709e8c00.1535983918.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 05/10] block: Allow child references on reopen 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" In the previous patches we removed all child references from bs->{options,explicit_options} because keeping them is useless and wrong. Because of this, any attempt to reopen a BlockDriverState using a child reference as one of its options would result in a failure, because bdrv_reopen_prepare() would detect that there's a new option (the child reference) that wasn't present in bs->options. But passing child references on reopen can be useful. It's a way to specify a BDS's child without having to pass recursively all of the child's options, and if the reference points to a different BDS then this can allow us to replace the child. However, replacing the child is something that needs to be implemented case by case and only when it makes sense. For now, this patch allows passing a child reference as long as it points to the current child of the BlockDriverState. It's also important to remember that, as a consequence of the previous patches, this child reference will be removed from bs->{options,explicit_options} after the reopening has been completed. Signed-off-by: Alberto Garcia Reviewed-by: Max Reitz --- block.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/block.c b/block.c index aaa4cf6897..5223d16f1b 100644 --- a/block.c +++ b/block.c @@ -3241,6 +3241,24 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_stat= e, BlockReopenQueue *queue, QObject *new =3D entry->value; QObject *old =3D qdict_get(reopen_state->bs->options, entry->k= ey); =20 + /* Allow child references (child_name=3Dnode_name) as long as = they + * point to the current child (i.e. everything stays the same)= . */ + if (qobject_type(new) =3D=3D QTYPE_QSTRING) { + BdrvChild *child; + QLIST_FOREACH(child, &reopen_state->bs->children, next) { + if (!strcmp(child->name, entry->key)) { + break; + } + } + + if (child) { + const char *str =3D qobject_get_try_str(new); + if (!strcmp(child->bs->node_name, str)) { + continue; /* Found child with this name, skip opti= on */ + } + } + } + /* * TODO: When using -drive to specify blockdev options, all va= lues * will be strings; however, when using -blockdev, blockdev-ad= d or --=20 2.11.0