From nobody Mon Feb 2 07:31:48 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