From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768834330; cv=none; d=zohomail.com; s=zohoarc; b=n+aksZNe/ze5bmhMVzl1/URH/bfJVwN9zp3QAABDXBYIMDz3V+a5jsjsTlw5DAUQxSLzJtstrkqbaVUOCSWIoYIwuT/XL0sX/KHCKDD5HiiYSY8v6RQpYlMXSEeX6FmVMRx1zLxTSc/A/Cp3F4FTh2dfRAVu4C4I+MB+6PZo9Nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768834330; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZTfsOYvuW02Gvdwrikehww7Vid/6TTUP0sVCFxipduA=; b=jcYLVVnpHPNSbIsgCGe+dNnLOqwvYg2QmqAeeZj8iLqAIircVWbUq0YGRxsuHbAXSnd1orxCsR2M0SCQDaqktP0oaW1yLXVFdOKQrXGdqv/DRDka1SJBxvXSBwgze6ybp9Gz42dw2C2TtiqNfURLNbncgiUNZiAvLtHyf1t8s9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768834329435624.0437570076106; Mon, 19 Jan 2026 06:52:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhqa2-0008Kp-LV; Mon, 19 Jan 2026 09:50:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZk-00089r-Tc; Mon, 19 Jan 2026 09:49:53 -0500 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZi-0008Mo-D5; Mon, 19 Jan 2026 09:49:52 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5a81:0:640:624e:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id DA44A807FB; Mon, 19 Jan 2026 17:49:44 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:934::1:38]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id gnaGbV0CCKo0-3kHkd0Pn; Mon, 19 Jan 2026 17:49:44 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768834184; bh=ZTfsOYvuW02Gvdwrikehww7Vid/6TTUP0sVCFxipduA=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=J/SLVu0SZLGvhrOdNz2P7yQdz6ylMXRptPP5N27F3UhLcMQK6DkAYoXgd0SDY1SYc h6Ac3kDdCrJtFGql/m9SWsbPVr77h4EbN2Tq47IarS9/nwujpDSbpE8JuVGiJwrj0g dhrRvZVyAzzgdJ1mK1JbhQ2KbCVUI6o8j1tDSlyg= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru Subject: [PATCH v10 1/8] block-backend: blk_root(): drop const specifier on return type Date: Mon, 19 Jan 2026 17:49:34 +0300 Message-ID: <20260119144941.87936-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768834333412154100 Content-Type: text/plain; charset="utf-8" We'll need get non-const child pointer for graph modifications in further commits. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/block-backend.c | 2 +- include/system/block-backend-global-state.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 9944657120..d4b48ac3b0 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2834,7 +2834,7 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_= in, int64_t off_in, bytes, read_flags, write_flags); } =20 -const BdrvChild *blk_root(BlockBackend *blk) +BdrvChild *blk_root(BlockBackend *blk) { GLOBAL_STATE_CODE(); return blk->root; diff --git a/include/system/block-backend-global-state.h b/include/system/b= lock-backend-global-state.h index c3849640df..a438f21dff 100644 --- a/include/system/block-backend-global-state.h +++ b/include/system/block-backend-global-state.h @@ -117,7 +117,7 @@ void blk_set_force_allow_inactivate(BlockBackend *blk); bool blk_register_buf(BlockBackend *blk, void *host, size_t size, Error **= errp); void blk_unregister_buf(BlockBackend *blk, void *host, size_t size); =20 -const BdrvChild *blk_root(BlockBackend *blk); +BdrvChild *blk_root(BlockBackend *blk); =20 int blk_make_empty(BlockBackend *blk, Error **errp); =20 --=20 2.52.0 From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768834233; cv=none; d=zohomail.com; s=zohoarc; b=cMqBCAnAiS0ZB8g8yJpyhy6tXYpoojpT8/X9sv2vPWucjQ4c0YHUfgDGT2kRdwVf+DhuHTTWNsXSGwBgQ/q1vnaD84oaGnvyLJfqJqpbuEd2GlAHDfTpW6FGVTQu4BurI+FrvGLoTSRIW6rY6Vn5HeoIAidTvgcD/YdLQVrZPUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768834233; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lXRrptFlJe5HYpQfYVtYh/snqUvBJmv+mKkgz5B5lJ0=; b=VZIyUEh1JvKhjmt4fDpGiIapLmvhONhSailIXQYbobTKSeaA3pC4uzLobMR1xFTuvBpgn8UaaSOr0256LUEPMfjsyVdJuDMmsvteRoxG/UI6F+sTN5ctNvC5ENMbnFkYx235seXB+oY3qM9kUZUXDUY8Q1+qFBWsFjjBzJLABos= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768834232391388.38532523938557; Mon, 19 Jan 2026 06:50:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhqZx-0008GN-6a; Mon, 19 Jan 2026 09:50:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZm-0008Cj-LQ; Mon, 19 Jan 2026 09:49:57 -0500 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZi-0008NI-F0; Mon, 19 Jan 2026 09:49:54 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5a81:0:640:624e:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 09354C015A; Mon, 19 Jan 2026 17:49:46 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:934::1:38]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id gnaGbV0CCKo0-rU9v1UQW; Mon, 19 Jan 2026 17:49:45 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768834185; bh=lXRrptFlJe5HYpQfYVtYh/snqUvBJmv+mKkgz5B5lJ0=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=bgne+6IKMT1TLPu+XL3yyTUC5ac3xG7KlqSLDtErkDuvioxCBiX19jRksLlhddMsO cAekfRvEN7UQI9e0xHLbdAdxZcMPVe7cIt/vyl11lc808BBXI434YXIEqM1oQenqTk cTchKVQQhCHxa5PuIRjQ5jrPOi+1lIcVlN1icbXM= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru Subject: [PATCH v10 2/8] block/export: add blk_by_export_id() Date: Mon, 19 Jan 2026 17:49:35 +0300 Message-ID: <20260119144941.87936-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768834238839154100 Content-Type: text/plain; charset="utf-8" We need it for further blockdev-replace functionality. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/export/export.c | 15 +++++++++++++++ include/system/block-backend-global-state.h | 1 + 2 files changed, 16 insertions(+) diff --git a/block/export/export.c b/block/export/export.c index f3bbf11070..d11beb900f 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -370,3 +370,18 @@ BlockExportInfoList *qmp_query_block_exports(Error **e= rrp) =20 return head; } + +BlockBackend *blk_by_export_id(const char *id, Error **errp) +{ + BlockExport *exp; + + exp =3D blk_exp_find(id); + if (exp =3D=3D NULL) { + error_setg(errp, "Export '%s' not found", id); + return NULL; + } + + assert(exp->blk); + + return exp->blk; +} diff --git a/include/system/block-backend-global-state.h b/include/system/b= lock-backend-global-state.h index a438f21dff..f23b9f1518 100644 --- a/include/system/block-backend-global-state.h +++ b/include/system/block-backend-global-state.h @@ -72,6 +72,7 @@ void blk_detach_dev(BlockBackend *blk, DeviceState *dev); DeviceState *blk_get_attached_dev(BlockBackend *blk); BlockBackend *blk_by_dev(void *dev); BlockBackend *blk_by_qdev_id(const char *id, Error **errp); +BlockBackend *blk_by_export_id(const char *id, Error **errp); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaq= ue); =20 int blk_make_zero(BlockBackend *blk, BdrvRequestFlags flags); --=20 2.52.0 From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768834335; cv=none; d=zohomail.com; s=zohoarc; b=Np0+A0TA7sRAFZV1BXco6D03ohQ1ZMAnAV1uA4NDxH4wQGSKdpqtH+L/mtZ50KfgJ6Lv6x0W/X2m/PYD7cATeHKLOOXq/hrrxicLvJcp/Tk8olvxAZco3rimXrKtVkaIpCA8uZFHnjhNL/XMTk+YtSuMoY8CDZGmZnqh64085nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768834335; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ltRcaqsFk9h/Orn1pinLuc7naJ9gQSmnjhdHrEohM+8=; b=GS7zfAzQTzVf3FCGO45v6G3xvdpK5F6R/xDtBMPFCiGiQpEq6GeMS6EPOdp9Nu2EG1aNIDf0Du0E1P2zTtkbKbjaCWD7ObQh/Se2xGyMnJMf8xrLaKaNaUiKWPv5Ww1UqhVbjZbPdCBWX8r2/IyBIl3DBR10OaQfzjs5Wt7rgI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768834335134509.75261328075396; Mon, 19 Jan 2026 06:52:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhqa8-0008P5-QD; Mon, 19 Jan 2026 09:50:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZl-00089t-8W; Mon, 19 Jan 2026 09:49:56 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZi-0008NU-DA; Mon, 19 Jan 2026 09:49:53 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5a81:0:640:624e:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id BAE788079C; Mon, 19 Jan 2026 17:49:46 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:934::1:38]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id gnaGbV0CCKo0-la3gfru8; Mon, 19 Jan 2026 17:49:46 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768834186; bh=ltRcaqsFk9h/Orn1pinLuc7naJ9gQSmnjhdHrEohM+8=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=TpRyjDEPIutqLbDapwdq62yVivK4M3yz+T9YUBJj1g8FdZqL9uYby6rQ+xnk8PFpz hzSOY/NUnclPhQlcKe6WUzlOOVWQEUlnbGGTq5qgrXaMYgW+6CJ2fqEF1oIgKxRvmd Y6SU17axKmxJuf4qkF3NQ3dK1y/t7uabBxsqwWTA= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru Subject: [PATCH v10 3/8] block: make bdrv_find_child() function public Date: Mon, 19 Jan 2026 17:49:36 +0300 Message-ID: <20260119144941.87936-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768834337886158500 Content-Type: text/plain; charset="utf-8" To be reused soon for blockdev-replace functionality. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 13 +++++++++++++ blockdev.c | 14 -------------- include/block/block_int-io.h | 2 ++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index 48a17f393c..b13d06f709 100644 --- a/block.c +++ b/block.c @@ -8288,6 +8288,19 @@ int bdrv_make_empty(BdrvChild *c, Error **errp) return 0; } =20 +BdrvChild *bdrv_find_child(BlockDriverState *parent_bs, const char *child_= name) +{ + BdrvChild *child; + + QLIST_FOREACH(child, &parent_bs->children, next) { + if (strcmp(child->name, child_name) =3D=3D 0) { + return child; + } + } + + return NULL; +} + /* * Return the child that @bs acts as an overlay for, and from which data m= ay be * copied in COW or COR operations. Usually this is the backing file. diff --git a/blockdev.c b/blockdev.c index 6e86c6262f..2540f991b3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3569,20 +3569,6 @@ unlock: } } =20 -static BdrvChild * GRAPH_RDLOCK -bdrv_find_child(BlockDriverState *parent_bs, const char *child_name) -{ - BdrvChild *child; - - QLIST_FOREACH(child, &parent_bs->children, next) { - if (strcmp(child->name, child_name) =3D=3D 0) { - return child; - } - } - - return NULL; -} - void qmp_x_blockdev_change(const char *parent, const char *child, const char *node, Error **errp) { diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index ed8b5657d6..8ff3bc6d87 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -130,6 +130,8 @@ bdrv_co_refresh_total_sectors(BlockDriverState *bs, int= 64_t hint); int co_wrapper_mixed_bdrv_rdlock bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint); =20 +BdrvChild * GRAPH_RDLOCK +bdrv_find_child(BlockDriverState *parent_bs, const char *child_name); BdrvChild * GRAPH_RDLOCK bdrv_cow_child(BlockDriverState *bs); BdrvChild * GRAPH_RDLOCK bdrv_filter_child(BlockDriverState *bs); BdrvChild * GRAPH_RDLOCK bdrv_filter_or_cow_child(BlockDriverState *bs); --=20 2.52.0 From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768834234; cv=none; d=zohomail.com; s=zohoarc; b=PMvlvichmsUHovx0s7zWYw0L1X/aYyCwXREFcucF5toSZg8cSBju4JrMu24WwOoDOCsqeQoLQIsVtiHsoAMi9Eqew2gc+fqKXEZuqYU4PDgugunkN2jwKKlJI0zOZge+FWJLrTMGr25BRKv8X8F6ccrttp4uoPfyCsinQA1rCIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768834234; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UqhAnPu8xVLK6fTiBiY6reBxiK4bUaCAZpJJSu0dE9w=; b=RiPwld/wIJs1y4DbcWbl4Wr26OuIfOaK7uem4ckRh++34zHMlVuPK1BvET9hTJV5yZ6g2m8yRtrPaGgE5MOkWRMSXu+NmES42fJCYvJi0jbuTKbpymMSpHKHvGrD26nQCG4ckWQsAc3gBkjeRBEAzZheOSXa+F4txXCqqtg4T/8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768834232796913.0504410944875; Mon, 19 Jan 2026 06:50:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhqaB-0008Qe-3p; Mon, 19 Jan 2026 09:50:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZo-0008D2-Ui; Mon, 19 Jan 2026 09:49:58 -0500 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZj-0008NV-5Z; Mon, 19 Jan 2026 09:49:55 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5a81:0:640:624e:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 9AF638079B; Mon, 19 Jan 2026 17:49:47 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:934::1:38]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id gnaGbV0CCKo0-z2hOBkpJ; Mon, 19 Jan 2026 17:49:46 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768834186; bh=UqhAnPu8xVLK6fTiBiY6reBxiK4bUaCAZpJJSu0dE9w=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=FRe1xP5kNeRPBGg/kF4lCvw45lQX/qlkm+TKw8k6/QWyGxTohmH3gMtdRn8oirsLn GEbXh4ABHrNvMkRpWPpO+DyLeXFxE19R+fUXzdrmt5fLoe7Ni6V5xfE2g7Wg/9dyno uaRS0wHrp9a0pfP3Wla+FpNIUL0FTTAXso3NCnng= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru Subject: [PATCH v10 4/8] qapi: add blockdev-replace command Date: Mon, 19 Jan 2026 17:49:37 +0300 Message-ID: <20260119144941.87936-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768834243838158500 Content-Type: text/plain; charset="utf-8" Add a command that can replace bs in following BdrvChild structures: - qdev blk root child - block-export blk root child - any child of BlockDriverState selected by child-name Signed-off-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 68 ++++++++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 24 +++++++++++++++ stubs/blk-by-qdev-id.c | 13 ++++++++ stubs/meson.build | 1 + 4 files changed, 106 insertions(+) create mode 100644 stubs/blk-by-qdev-id.c diff --git a/blockdev.c b/blockdev.c index 2540f991b3..3082a5763c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3681,6 +3681,74 @@ out: bdrv_drain_all_end(); } =20 +void qmp_blockdev_replace(const char *parent, const char *child, + const char *new_child, Error **errp) +{ + BdrvChild *child_to_replace =3D NULL; + BlockDriverState *new_child_bs; + Error *dev_err =3D NULL, *exp_err =3D NULL; + BlockDriverState *parent_bs =3D bdrv_find_node(parent); + BlockBackend *dev_blk =3D blk_by_qdev_id(parent, &dev_err); + BlockBackend *exp_blk =3D blk_by_export_id(parent, &exp_err); + unsigned found =3D !!parent_bs + !!dev_blk + !!exp_blk; + + if (found =3D=3D 0) { + error_setg(errp, "Neither device, nor export, nor block-node exist" + " with name '%s'. block-node: not found," + " device block-backend: %s, export block-backend: %s", + parent, error_get_pretty(dev_err), + error_get_pretty(exp_err)); + } + error_free(dev_err); + error_free(exp_err); + + if (found =3D=3D 0) { + return; + } + + if (found > 1) { + error_setg(errp, "Parent name '%s' is ambigous: block-node %s," + " device block-backend %s, export block-backend %s", + parent, parent_bs ? "found" : "not found", + dev_blk ? "found" : "not found", + exp_blk ? "found" : "not found"); + return; + } + + if (parent_bs) { + child_to_replace =3D bdrv_find_child(parent_bs, child); + if (!child_to_replace) { + error_setg(errp, "Block driver node '%s' doesn't have child " + "named '%s'", parent, child); + return; + } + } else { + BlockBackend *blk =3D dev_blk ?: exp_blk; + + if (strcmp(child, "root")) { + error_setg(errp, "Devices and exports may have only 'root' chi= ld"); + } + + child_to_replace =3D blk_root(blk); + if (!child_to_replace) { + error_setg(errp, "%s '%s' is empty, nothing to replace", + dev_blk ? "Device" : "Export", parent); + return; + } + } + + assert(child_to_replace); + assert(child_to_replace->bs); + + new_child_bs =3D bdrv_find_node(new_child); + if (!new_child_bs) { + error_setg(errp, "Node '%s' not found", new_child); + return; + } + + bdrv_replace_child_bs(child_to_replace, new_child_bs, errp); +} + QemuOptsList qemu_common_drive_opts =3D { .name =3D "drive", .head =3D QTAILQ_HEAD_INITIALIZER(qemu_common_drive_opts.head), diff --git a/qapi/block-core.json b/qapi/block-core.json index b82af74256..9cc7c3d140 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -6334,3 +6334,27 @@ ## { 'struct': 'DummyBlockCoreForceArrays', 'data': { 'unused-block-graph-info': ['BlockGraphInfo'] } } + +## +# @blockdev-replace: +# +# Replace a block-node associated with device (@parent should be +# QOM path, and @child should be "root") or with block-export (@parent +# should be export name, and @child should be "root") or any child +# of block-node (@parent should be node-name, and @child should be any +# if its children names) with @new-child block-node. +# +# @parent: QOM path or block-export or node-name, which @child should +# be repalced. If several matching parents exist, the command +# will fail +# +# @child: child to replace. Must be "root" when parent is QOM path or +# block-export +# +# @new-child: node-name of the block-node, which should become a +# replacement for @child's current block-node +# +# Since 11.0 +## +{ 'command': 'blockdev-replace', + 'data': { 'parent': 'str', 'child': 'str', 'new-child': 'str' } } diff --git a/stubs/blk-by-qdev-id.c b/stubs/blk-by-qdev-id.c new file mode 100644 index 0000000000..66ead77f4d --- /dev/null +++ b/stubs/blk-by-qdev-id.c @@ -0,0 +1,13 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "system/block-backend.h" + +BlockBackend *blk_by_qdev_id(const char *id, Error **errp) +{ + /* + * We expect this when blockdev-change is called with parent-type=3Dqd= ev, + * but qdev-monitor is not linked in. So no blk_ API is not available. + */ + error_setg(errp, "Parameter 'parent-type' does not accept value 'qdev'= "); + return NULL; +} diff --git a/stubs/meson.build b/stubs/meson.build index d3b551f4de..93a52d273e 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -15,6 +15,7 @@ if have_block stub_ss.add(files('bdrv-next-monitor-owned.c')) stub_ss.add(files('blk-commit-all.c')) stub_ss.add(files('blk-exp-close-all.c')) + stub_ss.add(files('blk-by-qdev-id.c')) stub_ss.add(files('blockdev-close-all-bdrv-states.c')) stub_ss.add(files('change-state-handler.c')) stub_ss.add(files('get-vm-name.c')) --=20 2.52.0 From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768834284; cv=none; d=zohomail.com; s=zohoarc; b=Wifrqr9x+FIHx19gg9zkb76ej4u25Ib19teFLDxV37M0Ve4kI//gITG56ahmEI0dliP0Dd//bSwv6kfBelcHLfGotUFcrPWmsrLVS5wT7Q471mMt4VQv4JBHPKYkvW5oo9fjGM3aHyImwyxCs9JstjOSoAcAG2wQDngTA9DUSAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768834284; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tWlEr4VB+A84CJ6NriO4igIgJBFZIudrt/R/OVGsGNI=; b=FtlIqrVPTw2i1L5M3udGcS8Hw3obfpmtW5ktBPdPuUm1/ADF8snUjDPsfoQ4wJwW7DbZyCGrfzoXDzCALRDpfb926YML80YaX/ryEc+ITforRJgRn3UKAbldYMbAReMR8tJSGOG8uTWBNxs2wB85GITafrLR9jzGxpuKZCIdsX8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768834283821260.0116973856368; Mon, 19 Jan 2026 06:51:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhqa9-0008PC-Cs; Mon, 19 Jan 2026 09:50:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZm-0008Aq-6h; Mon, 19 Jan 2026 09:49:56 -0500 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZi-0008Na-Ej; Mon, 19 Jan 2026 09:49:53 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5a81:0:640:624e:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 583188075C; Mon, 19 Jan 2026 17:49:48 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:934::1:38]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id gnaGbV0CCKo0-jRPRKwp5; Mon, 19 Jan 2026 17:49:47 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768834187; bh=tWlEr4VB+A84CJ6NriO4igIgJBFZIudrt/R/OVGsGNI=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Rr1K0dD/8mvhE+kVZZtrdzx7bLaB6hKNRwQJRfUVsNOeMU7AhNr5OF2pDTvQetQ3Y e+i3QFbRRjBILCnda5HXJ5fpQFGW7jMKYNmSj0kiCb/GSYnfJy3qAgfVEgWK49QpVB P8Tb+ohavvPpJ5WoE6VqyGUsg6hJ8nDOtkBtcFgs= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru Subject: [PATCH v10 5/8] block: bdrv_get_xdbg_block_graph(): report export ids Date: Mon, 19 Jan 2026 17:49:38 +0300 Message-ID: <20260119144941.87936-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768834285356158500 Content-Type: text/plain; charset="utf-8" Currently for block exports we report empty blk names. That's not good. Let's try to find corresponding block export and report its id. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 4 ++++ block/export/export.c | 13 +++++++++++++ include/block/export.h | 1 + stubs/blk-exp-find-by-blk.c | 9 +++++++++ stubs/meson.build | 1 + 5 files changed, 28 insertions(+) create mode 100644 stubs/blk-exp-find-by-blk.c diff --git a/block.c b/block.c index b13d06f709..8254d57212 100644 --- a/block.c +++ b/block.c @@ -6354,7 +6354,11 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **er= rp) for (blk =3D blk_all_next(NULL); blk; blk =3D blk_all_next(blk)) { char *allocated_name =3D NULL; const char *name =3D blk_name(blk); + BlockExport *exp =3D blk_exp_find_by_blk(blk); =20 + if (!*name && exp) { + name =3D exp->id; + } if (!*name) { name =3D allocated_name =3D blk_get_attached_dev_id(blk); } diff --git a/block/export/export.c b/block/export/export.c index d11beb900f..9169b43e13 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -60,6 +60,19 @@ BlockExport *blk_exp_find(const char *id) return NULL; } =20 +BlockExport *blk_exp_find_by_blk(BlockBackend *blk) +{ + BlockExport *exp; + + QLIST_FOREACH(exp, &block_exports, next) { + if (exp->blk =3D=3D blk) { + return exp; + } + } + + return NULL; +} + static const BlockExportDriver *blk_exp_find_driver(BlockExportType type) { int i; diff --git a/include/block/export.h b/include/block/export.h index 4bd9531d4d..2d3a0b4a28 100644 --- a/include/block/export.h +++ b/include/block/export.h @@ -85,6 +85,7 @@ struct BlockExport { =20 BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp); BlockExport *blk_exp_find(const char *id); +BlockExport *blk_exp_find_by_blk(BlockBackend *blk); void blk_exp_ref(BlockExport *exp); void blk_exp_unref(BlockExport *exp); void blk_exp_request_shutdown(BlockExport *exp); diff --git a/stubs/blk-exp-find-by-blk.c b/stubs/blk-exp-find-by-blk.c new file mode 100644 index 0000000000..20f7ff1bdd --- /dev/null +++ b/stubs/blk-exp-find-by-blk.c @@ -0,0 +1,9 @@ +#include "qemu/osdep.h" +#include "system/block-backend.h" +#include "block/export.h" + +BlockExport *blk_exp_find_by_blk(BlockBackend *blk) +{ + return NULL; +} + diff --git a/stubs/meson.build b/stubs/meson.build index 93a52d273e..d530a637d9 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -16,6 +16,7 @@ if have_block stub_ss.add(files('blk-commit-all.c')) stub_ss.add(files('blk-exp-close-all.c')) stub_ss.add(files('blk-by-qdev-id.c')) + stub_ss.add(files('blk-exp-find-by-blk.c')) stub_ss.add(files('blockdev-close-all-bdrv-states.c')) stub_ss.add(files('change-state-handler.c')) stub_ss.add(files('get-vm-name.c')) --=20 2.52.0 From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768834235; cv=none; d=zohomail.com; s=zohoarc; b=MQCtZtlp+26/pO3C/19nmPelzx5IOSpsNQbazuEbvX3R6jRayxLrTexxrnO582CphO9yviGYJCexNMSmTayRC6cyqeEcsLC/n0xWx5lNAmslcHkHuNlaSWC7WX/PxIqbjA6C5v7TRnhcT6n8HpK/2GsJ4g93ZkGjpwF4yBE9Lxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768834235; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=k8HQhsmMIL31NlPqKNV8IB2vML1614dgEzgG38+hPMQ=; b=D0H8Ywcy1n9gAEgxbK/x9k+76kTjEd4kjyGASMWSzdvpwBTUdF7oJuCHHZfbCoVLg8iLhAONmPBdorJeoMcuP5lsrZkIOQw8f4I59+5ryKamcLk71QuHspeYPe7Wgbakt/7oDi+TI4PDrs+aUWJlWMp7H20jL5vOnTcBfXcWvbo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768834235492794.0681315550412; Mon, 19 Jan 2026 06:50:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhqa9-0008Pz-T0; Mon, 19 Jan 2026 09:50:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZm-0008Ci-L2; Mon, 19 Jan 2026 09:49:56 -0500 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZi-0008Nd-T8; Mon, 19 Jan 2026 09:49:54 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5a81:0:640:624e:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 190A880865; Mon, 19 Jan 2026 17:49:49 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:934::1:38]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id gnaGbV0CCKo0-nKJwXnB6; Mon, 19 Jan 2026 17:49:48 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768834188; bh=k8HQhsmMIL31NlPqKNV8IB2vML1614dgEzgG38+hPMQ=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=D1Btn0jKd2dlodPL8R34Jc98ihNdsiVCMvuo+bBkejC7KhFto3pKqdHg55s05tmi1 0pwjZv3s1kk9yYk6axA9Kl5S2UVcbd48+0noy7xVadD/qGR4xf71MI0hJX07oj3FOi 8X4QqpJ97omCMCqJK/AjszgjyD4BysFwEMzLGth0= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru Subject: [PATCH v10 6/8] iotests.py: introduce VM.assert_edges_list() method Date: Mon, 19 Jan 2026 17:49:39 +0300 Message-ID: <20260119144941.87936-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768834239013154100 Content-Type: text/plain; charset="utf-8" Add an alternative method to check block graph, to be used in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 05274772ce..d6f4e890da 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1126,6 +1126,23 @@ def check_bitmap_status(self, node_name, bitmap_name= , fields): =20 return fields.items() <=3D ret.items() =20 + def get_block_graph(self): + """ + Returns block graph in form of edges list, where each edge is a tu= ple: + (parent_node_name, child_name, child_node_name) + """ + graph =3D self.qmp('x-debug-query-block-graph')['return'] + + nodes =3D {n['id']: n['name'] for n in graph['nodes']} + # Check that all names are unique: + assert len(set(nodes.values())) =3D=3D len(nodes) + + return [(nodes[e['parent']], e['name'], nodes[e['child']]) + for e in graph['edges']] + + def assert_edges_list(self, edges): + assert sorted(edges) =3D=3D sorted(self.get_block_graph()) + def assert_block_path(self, root, path, expected_node, graph=3DNone): """ Check whether the node under the given path in the block graph --=20 2.52.0 From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768834273; cv=none; d=zohomail.com; s=zohoarc; b=WHMz7PvQiTolAODw7+kRsegN4g32huQkyScVaRY++2YUIcxlq9U8SxKQwhdQ5QEcU7Um03hr6oSTX8QU8qYxlt9gHl8EbO3GE8C7mK2NYON4tPzeDkPGBdROPbSz3cnjck2WL1/QqfRuXf+s+5+BRBCn5suiofOc3mTAdrmQmOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768834273; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RO/wOYcRCwTBkuY0dTwRudi/MmxKTmNkQmhSEgfxUww=; b=IsFdDvAldgMzWAahBBjEJ+vtjVeBOw0CWFvUXfPZbgekf4M0d4HVW0MrdT4m2wssmbyChwi8F4VACi0dnhHiShwFJR1Q6yczBr6tlIy2iEqmsNE8zols462aaQP5UYTzAV0TZXGiYp6GL7iV3DMWjkz7E2Xx4QUfW2vDTXnOMdE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176883427375985.66956302206256; Mon, 19 Jan 2026 06:51:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhqa9-0008PT-GL; Mon, 19 Jan 2026 09:50:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZo-0008D3-UX; Mon, 19 Jan 2026 09:49:58 -0500 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZj-0008Nw-I2; Mon, 19 Jan 2026 09:49:55 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5a81:0:640:624e:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id EF2E28086B; Mon, 19 Jan 2026 17:49:49 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:934::1:38]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id gnaGbV0CCKo0-Xa41qkHW; Mon, 19 Jan 2026 17:49:49 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768834189; bh=RO/wOYcRCwTBkuY0dTwRudi/MmxKTmNkQmhSEgfxUww=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=yBvWEEg/Lfih+NGPOQm7av1V+wjrGOJrJnNBMIaj1MHgnreOOFHMjlmYNiuaq78S1 3yBBD8FoH8Ml/UhhVi86urBa7dlE49GDeoJLX46Tgc2VhX6dA7CjxoR+i8pDx/eRDg ZLUnWleZ+7JeVGV2N4sviuKANHR8sTMznLBziH3Q= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru Subject: [PATCH v10 7/8] iotests: add filter-insertion Date: Mon, 19 Jan 2026 17:49:40 +0300 Message-ID: <20260119144941.87936-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768834275864158500 Content-Type: text/plain; charset="utf-8" Demonstrate new blockdev-replace API for filter insertion and removal. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/filter-insertion | 222 ++++++++++++++++++ tests/qemu-iotests/tests/filter-insertion.out | 5 + 2 files changed, 227 insertions(+) create mode 100755 tests/qemu-iotests/tests/filter-insertion create mode 100644 tests/qemu-iotests/tests/filter-insertion.out diff --git a/tests/qemu-iotests/tests/filter-insertion b/tests/qemu-iotests= /tests/filter-insertion new file mode 100755 index 0000000000..23e114f959 --- /dev/null +++ b/tests/qemu-iotests/tests/filter-insertion @@ -0,0 +1,222 @@ +#!/usr/bin/env python3 +# +# Tests for inserting and removing filters in a block graph. +# +# Copyright (c) 2022 Virtuozzo International GmbH. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os + +import iotests +from iotests import qemu_img_create, try_remove + + +disk =3D os.path.join(iotests.test_dir, 'disk') +sock =3D os.path.join(iotests.sock_dir, 'sock') +size =3D 1024 * 1024 + + +class TestFilterInsertion(iotests.QMPTestCase): + def setUp(self): + qemu_img_create('-f', iotests.imgfmt, disk, str(size)) + + self.vm =3D iotests.VM() + self.vm.launch() + + self.vm.cmd('blockdev-add', { + 'node-name': 'disk0', + 'driver': 'qcow2', + 'file': { + 'node-name': 'file0', + 'driver': 'file', + 'filename': disk + } + }) + + def tearDown(self): + self.vm.shutdown() + os.remove(disk) + try_remove(sock) + + def test_simple_insertion(self): + vm =3D self.vm + + vm.cmd('blockdev-add', { + 'node-name': 'filter', + 'driver': 'blkdebug', + 'image': 'file0' + }) + + vm.cmd('blockdev-replace', { + 'parent': 'disk0', + 'child': 'file', + 'new-child': 'filter' + }) + + # Filter inserted: + # disk0 -file-> filter -file-> file0 + vm.assert_edges_list([ + ('disk0', 'file', 'filter'), + ('filter', 'image', 'file0') + ]) + + vm.cmd('blockdev-replace', { + 'parent': 'disk0', + 'child': 'file', + 'new-child': 'file0' + }) + + # Filter replaced, but still exists: + # dik0 -file-> file0 <-file- filter + vm.assert_edges_list([ + ('disk0', 'file', 'file0'), + ('filter', 'image', 'file0') + ]) + + vm.cmd('blockdev-del', node_name=3D'filter') + + # Filter removed + # dik0 -file-> file0 + vm.assert_edges_list([ + ('disk0', 'file', 'file0') + ]) + + def test_insert_under_qdev(self): + vm =3D self.vm + + vm.cmd('device_add', driver=3D'virtio-scsi') + vm.cmd('device_add', id=3D'sda', driver=3D'scsi-hd', + drive=3D'disk0') + + vm.cmd('blockdev-add', { + 'node-name': 'filter', + 'driver': 'compress', + 'file': 'disk0' + }) + + vm.cmd('blockdev-replace', { + 'parent': 'sda', + 'child': 'root', + 'new-child': 'filter' + }) + + # Filter inserted: + # sda -root-> filter -file-> disk0 -file-> file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('sda', 'root', 'filter'), + ('filter', 'file', 'disk0'), + ('disk0', 'file', 'file0'), + ]) + + vm.cmd('blockdev-replace', { + 'parent': 'sda', + 'child': 'root', + 'new-child': 'disk0' + }) + vm.cmd('blockdev-del', node_name=3D'filter') + + # Filter removed: + # sda -root-> disk0 -file-> file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('sda', 'root', 'disk0'), + ('disk0', 'file', 'file0'), + ]) + + def test_insert_under_nbd_export(self): + vm =3D self.vm + + vm.cmd('nbd-server-start', + addr=3D{'type': 'unix', 'data': {'path': sock}}) + vm.cmd('block-export-add', id=3D'exp1', type=3D'nbd', + node_name=3D'disk0', name=3D'exp1') + vm.cmd('block-export-add', id=3D'exp2', type=3D'nbd', + node_name=3D'disk0', name=3D'exp2') + vm.cmd('object-add', qom_type=3D'throttle-group', + id=3D'tg', limits=3D{'iops-read': 1}) + + vm.cmd('blockdev-add', { + 'node-name': 'filter', + 'driver': 'throttle', + 'throttle-group': 'tg', + 'file': 'disk0' + }) + + vm.cmd('blockdev-replace', { + 'parent': 'exp1', + 'child': 'root', + 'new-child': 'filter' + }) + + # Only exp1 is throttled, exp2 is not: + # exp1 -root-> filter + # | + # |file + # v + # exp2 -file-> disk0 -file> file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('exp1', 'root', 'filter'), + ('filter', 'file', 'disk0'), + ('disk0', 'file', 'file0'), + ('exp2', 'root', 'disk0') + ]) + + vm.cmd('blockdev-replace', { + 'parent': 'exp2', + 'child': 'root', + 'new-child': 'filter' + }) + + # Both throttled: + # exp1 -root-> filter <-file- exp2 + # | + # |file + # v + # disk0 -file> file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('exp1', 'root', 'filter'), + ('filter', 'file', 'disk0'), + ('disk0', 'file', 'file0'), + ('exp2', 'root', 'filter') + ]) + + # Check, that filter is in use and can't be removed + result =3D vm.qmp('blockdev-del', node_name=3D'filter') + self.assert_qmp(result, 'error/desc', 'Node filter is in use') + + vm.cmd('blockdev-replace', { + 'parent': 'exp1', + 'child': 'root', + 'new-child': 'disk0' + }) + + vm.cmd('blockdev-replace', { + 'parent': 'exp2', + 'child': 'root', + 'new-child': 'disk0' + }) + vm.cmd('blockdev-del', node_name=3D'filter') + + # Filter removed: + # exp1 -root-> disk0 <-file- exp2 + # | + # |file + # v + # file0 + vm.assert_edges_list([ + # parent_node_name, child_name, child_node_name + ('exp1', 'root', 'disk0'), + ('disk0', 'file', 'file0'), + ('exp2', 'root', 'disk0') + ]) + + +if __name__ =3D=3D '__main__': + iotests.main( + supported_fmts=3D['qcow2'], + supported_protocols=3D['file'] + ) diff --git a/tests/qemu-iotests/tests/filter-insertion.out b/tests/qemu-iot= ests/tests/filter-insertion.out new file mode 100644 index 0000000000..8d7e996700 --- /dev/null +++ b/tests/qemu-iotests/tests/filter-insertion.out @@ -0,0 +1,5 @@ +... +---------------------------------------------------------------------- +Ran 3 tests + +OK --=20 2.52.0 From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1768834320; cv=none; d=zohomail.com; s=zohoarc; b=NEndpUKY4jYLV3Pg+u2p4NGMEX63qL6PWzygqSI4c09ll1hVF9Tr/raXOjXny11lbfEtC2MMvZgGMsC6UzIdn2dF9Zvrit6J5rv4mx/iOCHGcHgRBftaRQ1V/xY0wENdNbMPirq0QIs6fyqy/lhIqaZbIHbRhOxXqCQ5tWX+mpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768834320; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gj6BWqpIIeyPn+JIEMMDww7yxiIxHS9HjNX3kbpOKHw=; b=jItUhMxzzYo1txMbHVrlteKQtR/se+WnHW0JHnkxP8H1OtGF2S+hohhTmH5AbQSjmF4mjJ5I8DGw6WRmxEn2UuAkf8C+0z6Tkb/3PUHSgpjTpJXjqPhvOW91aHGbBpyis2a6SD3Eci7DYAfitE+TE798M53Y2Wfok1Td6qJbm3E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1768834319909180.24101237714774; Mon, 19 Jan 2026 06:51:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhqa4-0008M8-AV; Mon, 19 Jan 2026 09:50:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZo-0008D1-UC; Mon, 19 Jan 2026 09:49:58 -0500 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vhqZk-0008OP-D3; Mon, 19 Jan 2026 09:49:55 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5a81:0:640:624e:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id D1D6AC015D; Mon, 19 Jan 2026 17:49:50 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:934::1:38]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id gnaGbV0CCKo0-Tme69IbB; Mon, 19 Jan 2026 17:49:50 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1768834190; bh=gj6BWqpIIeyPn+JIEMMDww7yxiIxHS9HjNX3kbpOKHw=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=nWF1xIWot31eWzfxR17nutGbWUMT1Axl+7wQ6U5KUgC0/VOLhxPZpaM+lcdVmv6eV z6jeFO8g01rSY4uT3W3IxxU5HE21aM+bvBgngsPnuMThkwlJw2R5tleUKqV+WgEVIp 7kxXE0qUG2qjzXVrMti3Dd3Tgg4POKBIZKMdOsR4= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru Subject: [PATCH v10 8/8] deprecate names duplication between qdev, block-node and block-export Date: Mon, 19 Jan 2026 17:49:41 +0300 Message-ID: <20260119144941.87936-9-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1768834323948158500 Content-Type: text/plain; charset="utf-8" Now we have blockdev-replace QMP command, which depend on a possibility to select any block parent (block node, block export, or qdev) by one unique name. The command fails, if name is ambiguous (i.e., match several parents of different types). In future we want to rid of this ambiguity. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 12 ++++++++++++ block/export/export.c | 13 +++++++++++++ docs/about/deprecated.rst | 10 ++++++++++ include/block/block-global-state.h | 1 + include/system/block-backend-global-state.h | 2 ++ stubs/blk-by-qdev-id.c | 5 +++++ stubs/blk-exp-find-by-blk.c | 4 ++++ system/qdev-monitor.c | 16 ++++++++++++++++ 8 files changed, 63 insertions(+) diff --git a/block.c b/block.c index 8254d57212..5eae8b8623 100644 --- a/block.c +++ b/block.c @@ -1649,6 +1649,9 @@ static void bdrv_assign_node_name(BlockDriverState *b= s, goto out; } =20 + warn_device_exists(node_name); + warn_block_export_exists(node_name); + /* copy node name into the bs and insert it into the graph list */ pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); @@ -6233,6 +6236,15 @@ BlockDriverState *bdrv_find_node(const char *node_na= me) return NULL; } =20 +void warn_block_node_exists(const char *node_name) +{ + if (bdrv_find_node(node_name)) { + warn_report("block node already exist with name '%s'. " + "Ambigous identifiers are deprecated. " + "In future that would be an error.", node_name); + } +} + /* Put this QMP function here so it can access the static graph_bdrv_state= s. */ BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, Error **errp) diff --git a/block/export/export.c b/block/export/export.c index 9169b43e13..e65d1bec8e 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -23,6 +23,7 @@ #include "qapi/qapi-commands-block-export.h" #include "qapi/qapi-events-block-export.h" #include "qemu/id.h" +#include "qemu/error-report.h" #ifdef CONFIG_VHOST_USER_BLK_SERVER #include "vhost-user-blk-server.h" #endif @@ -108,6 +109,9 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Er= ror **errp) return NULL; } =20 + warn_device_exists(export->id); + warn_block_node_exists(export->id); + drv =3D blk_exp_find_driver(export->type); if (!drv) { error_setg(errp, "No driver found for the requested export type"); @@ -384,6 +388,15 @@ BlockExportInfoList *qmp_query_block_exports(Error **e= rrp) return head; } =20 +void warn_block_export_exists(const char *id) +{ + if (blk_exp_find(id)) { + warn_report("block-export already exist with name '%s'. " + "Ambigous identifiers are deprecated. " + "In future that would be an error.", id); + } +} + BlockBackend *blk_by_export_id(const char *id, Error **errp) { BlockExport *exp; diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 88efa3aa80..18bb1eeafc 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -551,3 +551,13 @@ command documentation for details on the ``fdset`` usa= ge. =20 The ``zero-blocks`` capability was part of the block migration which doesn't exist anymore since it was removed in QEMU v9.1. + +Identifiers +----------- + +Possibility to intersect qdev ids/paths, block node names, and block +export names namespaces is deprecated. In future that would be +abandoned and all block exports, block nodes and devices will have +unique names. Now, reusing the name for another type of object (for +example, creating block-node with node-name equal to existing qdev +id) produce a warning. diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index ed89999f0f..ea50478fc4 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -207,6 +207,7 @@ void bdrv_aio_cancel(BlockAIOCB *acb); int bdrv_has_zero_init_1(BlockDriverState *bs); int coroutine_mixed_fn GRAPH_RDLOCK bdrv_has_zero_init(BlockDriverState *b= s); BlockDriverState *bdrv_find_node(const char *node_name); +void warn_block_node_exists(const char *node_name); BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, Error **errp); XDbgBlockGraph * GRAPH_RDLOCK bdrv_get_xdbg_block_graph(Error **errp); BlockDriverState *bdrv_lookup_bs(const char *device, diff --git a/include/system/block-backend-global-state.h b/include/system/b= lock-backend-global-state.h index f23b9f1518..69e6aee618 100644 --- a/include/system/block-backend-global-state.h +++ b/include/system/block-backend-global-state.h @@ -73,6 +73,8 @@ DeviceState *blk_get_attached_dev(BlockBackend *blk); BlockBackend *blk_by_dev(void *dev); BlockBackend *blk_by_qdev_id(const char *id, Error **errp); BlockBackend *blk_by_export_id(const char *id, Error **errp); +void warn_block_export_exists(const char *id); +void warn_device_exists(const char *id); void blk_set_dev_ops(BlockBackend *blk, const BlockDevOps *ops, void *opaq= ue); =20 int blk_make_zero(BlockBackend *blk, BdrvRequestFlags flags); diff --git a/stubs/blk-by-qdev-id.c b/stubs/blk-by-qdev-id.c index 66ead77f4d..c83a2dde0d 100644 --- a/stubs/blk-by-qdev-id.c +++ b/stubs/blk-by-qdev-id.c @@ -11,3 +11,8 @@ BlockBackend *blk_by_qdev_id(const char *id, Error **errp) error_setg(errp, "Parameter 'parent-type' does not accept value 'qdev'= "); return NULL; } + +void warn_device_exists(const char *id) +{ + /* do nothing */ +} diff --git a/stubs/blk-exp-find-by-blk.c b/stubs/blk-exp-find-by-blk.c index 20f7ff1bdd..a98c4572fc 100644 --- a/stubs/blk-exp-find-by-blk.c +++ b/stubs/blk-exp-find-by-blk.c @@ -7,3 +7,7 @@ BlockExport *blk_exp_find_by_blk(BlockBackend *blk) return NULL; } =20 +void warn_block_export_exists(const char *id) +{ + /* do nothing */ +} diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index be18902bb2..67b9da952d 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -605,6 +605,8 @@ const char *qdev_set_id(DeviceState *dev, char *id, Err= or **errp) OBJECT(dev), NULL); if (prop) { dev->id =3D id; + warn_block_export_exists(id); + warn_block_node_exists(id); } else { error_setg(errp, "Duplicate device ID '%s'", id); g_free(id); @@ -903,6 +905,20 @@ static DeviceState *find_device_state(const char *id, = bool use_generic_error, return dev; } =20 +void warn_device_exists(const char *id) +{ + Object *obj =3D object_resolve_path_at(qdev_get_peripheral(), id); + + if (obj) { + DeviceState *dev =3D (DeviceState *)object_dynamic_cast(obj, TYPE_= DEVICE); + + warn_report("%s '%s' already exist. " + "Ambigous identifiers are deprecated. " + "In future that would be an error.", + dev ? "Device" : "Object", id); + } +} + void qdev_unplug(DeviceState *dev, Error **errp) { HotplugHandler *hotplug_ctrl; --=20 2.52.0 From nobody Mon Feb 2 05:57:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1769097739302112.05077098013373; Thu, 22 Jan 2026 08:02:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 004CB43F10; Thu, 22 Jan 2026 11:02:16 -0500 (EST) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id F27DF43F51; Thu, 22 Jan 2026 11:01:29 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 20DDF41AA9; Thu, 22 Jan 2026 11:01:26 -0500 (EST) Received: from forwardcorp1b.mail.yandex.net (forwardcorp1b.mail.yandex.net [178.154.239.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 68EDF43E21 for ; Thu, 22 Jan 2026 11:01:24 -0500 (EST) Received: from mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:5c05:0:640:ff67:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 79B66808D9; Thu, 22 Jan 2026 19:01:17 +0300 (MSK) Received: from vsementsov-lin (unknown [2a02:6bf:8080:d28::1:34]) by mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id F1fhdk2BPuQ0-JcHXz3a4; Thu, 22 Jan 2026 19:01:16 +0300 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1769097676; bh=EqZTO2opfswjr10U++lMVydcx+uDmaCEDlgZuqsfjsc=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=OMhQBmznbnHf0ZLy+g5d+DNcdZ8CNraH6412+zL1j8KvGU/w1fhRrJFzEgSdWtlsq cSpRfHpDwbzPfFCXS0DEKvySyaQwq6xO0PYn1PpqWlub7nOf3b0O+zEle0HUBq3jd8 OaXV+mgL47Pid2ClHkQQKiopH9AJ6Gu/2ekoiSQo= Authentication-Results: mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH v11 8/8] deprecate names duplication between qdev, block-node and block-export Date: Thu, 22 Jan 2026 19:01:13 +0300 Message-ID: <20260122160113.1147745-1-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260119144941.87936-1-vsementsov@yandex-team.ru> References: <20260119144941.87936-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KUQAEKCSJDXFIQBMGZNNKPC4Q3LGFNO2 X-Message-ID-Hash: KUQAEKCSJDXFIQBMGZNNKPC4Q3LGFNO2 X-MailFrom: vsementsov@yandex-team.ru X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: qemu-block@nongnu.org, eduardo@habkost.net, pbonzini@redhat.com, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1769097742666154100 Content-Type: text/plain; charset="utf-8" Now we have blockdev-replace QMP command, which depend on a possibility to select any block parent (block node, block export, or qdev) by one unique name. The command fails, if name is ambiguous (i.e., match several parents of different types). In future we want to rid of this ambiguity. Signed-off-by: Vladimir Sementsov-Ogievskiy --- v11: rework separate warn_s into one common function check_existing_parent_id(). block.c | 6 ++++++ block/export/export.c | 6 ++++++ blockdev.c | 21 +++++++++++++++++++++ docs/about/deprecated.rst | 10 ++++++++++ include/block/block-global-state.h | 2 ++ stubs/check-existing-parent-id.c | 6 ++++++ stubs/meson.build | 1 + system/qdev-monitor.c | 20 ++++++++++++++++++++ 8 files changed, 72 insertions(+) create mode 100644 stubs/check-existing-parent-id.c diff --git a/block.c b/block.c index 8254d57212..69674ad4ed 100644 --- a/block.c +++ b/block.c @@ -1618,6 +1618,7 @@ static void bdrv_assign_node_name(BlockDriverState *b= s, { char *gen_node_name =3D NULL; GLOBAL_STATE_CODE(); + Error *local_err; =20 if (!node_name) { node_name =3D gen_node_name =3D id_generate(ID_BLOCK); @@ -1649,6 +1650,11 @@ static void bdrv_assign_node_name(BlockDriverState *= bs, goto out; } =20 + if (!check_existing_parent_id(node_name, &local_err)) { + error_report_err(local_err); + local_err =3D NULL; + } + /* copy node name into the bs and insert it into the graph list */ pstrcpy(bs->node_name, sizeof(bs->node_name), node_name); QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list); diff --git a/block/export/export.c b/block/export/export.c index 9169b43e13..174c86b4d2 100644 --- a/block/export/export.c +++ b/block/export/export.c @@ -96,6 +96,7 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Erro= r **errp) AioContext *ctx; uint64_t perm; int ret; + Error *local_err =3D NULL; =20 GLOBAL_STATE_CODE(); =20 @@ -108,6 +109,11 @@ BlockExport *blk_exp_add(BlockExportOptions *export, E= rror **errp) return NULL; } =20 + if (!check_existing_parent_id(export->id, &local_err)) { + error_report_err(local_err); + local_err =3D NULL; + } + drv =3D blk_exp_find_driver(export->type); if (!drv) { error_setg(errp, "No driver found for the requested export type"); diff --git a/blockdev.c b/blockdev.c index 3082a5763c..643b2132c9 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3681,6 +3681,27 @@ out: bdrv_drain_all_end(); } =20 + +bool check_existing_parent_id(const char *id, Error **errp) +{ + if (bdrv_find_node(id)) { + error_setg(errp, "block node with id '%s' already exist", id); + return false; + } + + if (blk_by_qdev_id(id, NULL)) { + error_setg(errp, "block device with id '%s' already exist", id); + return false; + } + + if (blk_by_export_id(id, NULL)) { + error_setg(errp, "block export with id '%s' already exist", id); + return false; + } + + return true; +} + void qmp_blockdev_replace(const char *parent, const char *child, const char *new_child, Error **errp) { diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 88efa3aa80..18bb1eeafc 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -551,3 +551,13 @@ command documentation for details on the ``fdset`` usa= ge. =20 The ``zero-blocks`` capability was part of the block migration which doesn't exist anymore since it was removed in QEMU v9.1. + +Identifiers +----------- + +Possibility to intersect qdev ids/paths, block node names, and block +export names namespaces is deprecated. In future that would be +abandoned and all block exports, block nodes and devices will have +unique names. Now, reusing the name for another type of object (for +example, creating block-node with node-name equal to existing qdev +id) produce a warning. diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index ed89999f0f..5014324241 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -318,4 +318,6 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *ho= st, size_t size); =20 void bdrv_cancel_in_flight(BlockDriverState *bs); =20 +bool check_existing_parent_id(const char *id, Error **errp); + #endif /* BLOCK_GLOBAL_STATE_H */ diff --git a/stubs/check-existing-parent-id.c b/stubs/check-existing-parent= -id.c new file mode 100644 index 0000000000..ef5ea3f26d --- /dev/null +++ b/stubs/check-existing-parent-id.c @@ -0,0 +1,6 @@ +#include "qemu/osdep.h" +#include "block/block-global-state.h" + +bool check_existing_parent_id(const char *id, Error **errp) { + return true; +} diff --git a/stubs/meson.build b/stubs/meson.build index 30536ec8fa..3bd8649bd1 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -16,6 +16,7 @@ if have_block stub_ss.add(files('blk-commit-all.c')) stub_ss.add(files('blk-exp-close-all.c')) stub_ss.add(files('blk-by-qdev-id.c')) + stub_ss.add(files('check-existing-parent-id.c')) stub_ss.add(files('blk-exp-find-by-blk.c')) stub_ss.add(files('blockdev-close-all-bdrv-states.c')) stub_ss.add(files('change-state-handler.c')) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index be18902bb2..ca14135191 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -593,6 +593,7 @@ static BusState *qbus_find(const char *path, Error **er= rp) const char *qdev_set_id(DeviceState *dev, char *id, Error **errp) { ObjectProperty *prop; + Error *local_err =3D NULL; =20 assert(!dev->id && !dev->realized); =20 @@ -601,6 +602,18 @@ const char *qdev_set_id(DeviceState *dev, char *id, Er= ror **errp) * has no parent */ if (id) { + g_autofree char *fullpath =3D g_strdup_printf("/peripheral/%s", id= ); + + if (!check_existing_parent_id(id, &local_err)) { + error_report_err(local_err); + local_err =3D NULL; + } + + if (!check_existing_parent_id(fullpath, &local_err)) { + error_report_err(local_err); + local_err =3D NULL; + } + prop =3D object_property_try_add_child(qdev_get_peripheral(), id, OBJECT(dev), NULL); if (prop) { @@ -613,6 +626,13 @@ const char *qdev_set_id(DeviceState *dev, char *id, Er= ror **errp) } else { static int anon_count; gchar *name =3D g_strdup_printf("device[%d]", anon_count++); + g_autofree char *fullpath =3D g_strdup_printf("/peripheral-anon/%s= ", id); + + if (!check_existing_parent_id(fullpath, &local_err)) { + error_report_err(local_err); + local_err =3D NULL; + } + prop =3D object_property_add_child(qdev_get_peripheral_anon(), nam= e, OBJECT(dev)); g_free(name); --=20 2.52.0