From nobody Sun Jul 26 13:26:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781625407; cv=none; d=zohomail.com; s=zohoarc; b=jHlVvhHw6DGW/3t6YfNmzCQOqvs6shdLJeTTcLMhSVZw2qMWRWgRxsNQ8BRQwDvS/BQKIB1oAxXT+U/kZiMOMXS0Hjcthh8n1JUoQvRNownTpuz4WGfTaZN7y76NpXnMI18YIHtXL3ZcxIg5tgNM2iF7iJA9vof2K7F10Ilw1+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781625407; h=Content-Type: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=k27/eUmDM815VUaa7ufhF5v1wTbU/Zq3allr9yBd0J8=; b=He+S6ZoUCMqze9gxKf1nty3hFAoKsWEOwae8EdWnGBhPDQ50w7e/61x+zsLUT93rvtcodVCGGWS4pauEc+Fef2NYiHvOo6zHS7BaN1cHQSg+0QMueMgLKqB2STMoBmq1IzVYmXObO2VxCsdo/o9GEpxFcutWmXKspf7WLs0xQQU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781625407757296.9292548855956; Tue, 16 Jun 2026 08:56:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wZW9B-00027G-Rr; Tue, 16 Jun 2026 11:56:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9A-00026Y-5l for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW98-0003mU-JQ for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:15 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-x2ua3dkXOAWShivtgQ12Jw-1; Tue, 16 Jun 2026 11:56:10 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32FD518005BD; Tue, 16 Jun 2026 15:56:08 +0000 (UTC) Received: from berrange.com (unknown [10.44.49.111]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B014E195419F; Tue, 16 Jun 2026 15:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781625373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k27/eUmDM815VUaa7ufhF5v1wTbU/Zq3allr9yBd0J8=; b=EjQQMtV/2rcQI+sV8jhwwvVx4TUG4cAJraa92WmjdaCfnX5S78xU6p8x96Ojt64Pn6jsNl xlxfIkBJRPsAO6yJ1AprpulkOV7wiOQc/xXBKeQ78Em3mbCCEqvAnfeDtmZ8fNat4OKNcu 3gEXcQYTj0KgHb7U89o+wO20z8p2+TQ= X-MC-Unique: x2ua3dkXOAWShivtgQ12Jw-1 X-Mimecast-MFC-AGG-ID: x2ua3dkXOAWShivtgQ12Jw_1781625369 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Peter Xu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" , Akihiko Odaki , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Aurelien Jarno , Fabiano Rosas , Paolo Bonzini , BALATON Zoltan , Mark Cave-Ayland , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [RFC 1/7] meson: add --enable-deprecations configure flag Date: Tue, 16 Jun 2026 16:55:48 +0100 Message-ID: <20260616155554.264412-2-berrange@redhat.com> In-Reply-To: <20260616155554.264412-1-berrange@redhat.com> References: <20260616155554.264412-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1781625410429158500 A challenge with QEMU is that internal APIs get obsoleted but chasing down use of old APIs is not as simple as it should be. Introduce a --enable-deprecations configure flag which expands the macro "QEMU_DEPRECATIONS" into "G_GNUC_DEPRECATED". This will trigger a compiler warning for any use of the deprecated APIs. It would generally be a good idea to disable -Werror when turning on deprecations otherwise the build will quickly abort. XXX: possibly add -Wno-error=3Ddeprecated-declarations, so we have show deprecations by default despite -Werror being on by default. This would trigger very many warnings but might be worth it if we want to strongly nudge maintainers to convert existing code. Our historical approach of "hope" has never worked to eliminate old code patterns. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qemu/osdep.h | 19 +++++++++++++++++++ meson.build | 1 + meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 4 files changed, 25 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 2f0e61ad6b..99b8f9cbb7 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -447,6 +447,25 @@ void QEMU_ERROR("code path is reachable") ((void)0)) #endif =20 +/* + * Tag an internal APIs which should no longer be used + * to emit a warning during build if --enable-deprecations + * is used with configure. Use of -Werror will trigger + * immediate build failure if this is used. + */ +#ifdef CONFIG_DEPRECATIONS +# define QEMU_DEPRECATED G_GNUC_DEPRECATED +# define QEMU_DEPRECATIONS_OFF \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +# define QEMU_DEPRECATIONS_ON \ + _Pragma("GCC diagnostic pop") +#else +# define QEMU_DEPRECATED +# define QEMU_DEPRECATIONS_OFF +# define QEMU_DEPRECATIONS_ON +#endif + /* * Minimum function that returns zero only if both values are zero. * Intended for use with unsigned values only. diff --git a/meson.build b/meson.build index 19e123423b..9e863aa897 100644 --- a/meson.build +++ b/meson.build @@ -2567,6 +2567,7 @@ config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_= option('debug_stack_usage') config_host_data.set('CONFIG_DEBUG_TCG', get_option('debug_tcg')) config_host_data.set('CONFIG_DEBUG_REMAP', get_option('debug_remap')) config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug')) +config_host_data.set('CONFIG_DEPRECATIONS', get_option('deprecations')) config_host_data.set('CONFIG_REPLICATION', get_option('replication').allow= ed()) config_host_data.set('CONFIG_FSFREEZE', qga_fsfreeze) config_host_data.set('CONFIG_FSTRIM', qga_fstrim) diff --git a/meson_options.txt b/meson_options.txt index a07cb47d35..8f5924422d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -367,6 +367,8 @@ option('qom_cast_debug', type: 'boolean', value: true, description: 'cast debugging support') option('slirp_smbd', type : 'feature', value : 'auto', description: 'use smbd (at path --smbd=3D*) in slirp networking') +option('deprecations', type: 'boolean', value: true, + description: 'enable internal API deprecation warnings') =20 option('qemu_ga_manufacturer', type: 'string', value: 'QEMU', description: '"manufacturer" name for qemu-ga registry entries') diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index c003985047..fb57f0610d 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -13,6 +13,7 @@ meson_options_help() { printf "%s\n" ' --datadir=3DVALUE Data file directory [share]' printf "%s\n" ' --disable-coroutine-pool coroutine freelist (better per= formance)' printf "%s\n" ' --disable-debug-info Enable debug symbols and other= information' + printf "%s\n" ' --disable-deprecations enable internal API deprecatio= n warnings' printf "%s\n" ' --disable-hexagon-idef-parser' printf "%s\n" ' use idef-parser to automatical= ly generate TCG' printf "%s\n" ' code for the Hexagon frontend' @@ -306,6 +307,8 @@ _meson_option_parse() { --disable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=3Dfalse ;; --enable-debug-tcg) printf "%s" -Ddebug_tcg=3Dtrue ;; --disable-debug-tcg) printf "%s" -Ddebug_tcg=3Dfalse ;; + --enable-deprecations) printf "%s" -Ddeprecations=3Dtrue ;; + --disable-deprecations) printf "%s" -Ddeprecations=3Dfalse ;; --enable-dmg) printf "%s" -Ddmg=3Denabled ;; --disable-dmg) printf "%s" -Ddmg=3Ddisabled ;; --docdir=3D*) quote_sh "-Ddocdir=3D$2" ;; --=20 2.54.0 From nobody Sun Jul 26 13:26:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781625419; cv=none; d=zohomail.com; s=zohoarc; b=FMvYuQ1jt/TI9Z68mYE9XFwbbTKI1pT9gLdpc0nogamNsiDsNpyYeXqqpRdMCNlnQ6SjQYwz1azL27DLd+gteCBAtStPzi1nOfZBSwfmz8Sx+Ku68CH6rQIBIYfoigAnRvscGirRpN3GAyWfmpHNXNamF5C34+keeMaG3yidqR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781625419; h=Content-Type: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=TTqi9MQR7wiJYeoYzsF+QEaiQ0Xxlem9KZFK9Xjbd84=; b=Qh80D4rtw1uNZuiFLyxIHlHRZHSev382H62WLZzDje6vJCs7jr32enEcYu0J9xmoylTQUVkUSlgMlHa3CkRTq1mZ5PDOTG+AXwfDERt+NHeQGoTY+ZQviarx2fTf5irtNwYE25UsHmzS0QTCoDbSdQUE0W0abCaOx0ptdrqSj6Q= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781625419034245.04767272991432; Tue, 16 Jun 2026 08:56:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wZW9J-00027t-A7; Tue, 16 Jun 2026 11:56:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9I-00027l-3t for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9G-0003o8-B8 for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:23 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-uVb3ePQKNpevU-_hWYl0SQ-1; Tue, 16 Jun 2026 11:56:18 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F01B91800841; Tue, 16 Jun 2026 15:56:14 +0000 (UTC) Received: from berrange.com (unknown [10.44.49.111]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B88A2195411C; Tue, 16 Jun 2026 15:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781625381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TTqi9MQR7wiJYeoYzsF+QEaiQ0Xxlem9KZFK9Xjbd84=; b=W4qYUbo5m9mnkEhllDPxTShDbaKUBWzvkatmiHVMVDCHHPzazsvuEwyOmggeZuKNUe7xbp ZKpq3lY/Wh2Lr35emGAngtPg77VQyjnwIUl4JtnnVqJy3Hz1lSQjiz11yfBmHczCJdbOYh e+NBBzXxucsSh3paSFvRIcM8bTk2X8k= X-MC-Unique: uVb3ePQKNpevU-_hWYl0SQ-1 X-Mimecast-MFC-AGG-ID: uVb3ePQKNpevU-_hWYl0SQ_1781625376 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Peter Xu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" , Akihiko Odaki , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Aurelien Jarno , Fabiano Rosas , Paolo Bonzini , BALATON Zoltan , Mark Cave-Ayland , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [RFC 2/7] qom: deprecated embedding object structs within other objects Date: Tue, 16 Jun 2026 16:55:49 +0100 Message-ID: <20260616155554.264412-3-berrange@redhat.com> In-Reply-To: <20260616155554.264412-1-berrange@redhat.com> References: <20260616155554.264412-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1781625421435158500 The QOM APIs currently allow objects to be either allocated directly on the heap, or statically embedded inside the struct of another object. For the latter QOM has logic to avoid calling 'free' on the object when finalizers complete, however, this is not sufficient to make the practice safe. Users of QOM expect that if they call "object_ref" to acquire their own reference, then object will never be freed as long as they hold it. This expectation is broken when an instance is embedded, as the "owner" object's may be finalized, which frees the memory that is storing the embedded QOM instance, even if its ref-count is still live. Worse still is that a user of a QOM object cannot easily tell if the instance they're using is embedded or directly heap allocated. Mark the APIs for embedding objects as deprecated as the first step towards removal of this flawed design concept. All objects must now be directly heap allocated going forward, and existing usage must be incrementally converted. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 28 ++++++++++++++++++++++++---- qom/object.c | 6 ++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 11f55613fc..dd708b1136 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -854,8 +854,13 @@ bool object_set_props_from_keyval(Object *obj, const Q= Dict *qdict, * This function will initialize an object. The memory for the object sho= uld * have already been allocated. The returned object has a reference count= of 1, * and will be finalized when the last reference is dropped. + * + * Use of this function is now deprecated. All objects must be + * allocated using the object_new() family of functions and not + * statically embedded in a larger struct. */ -void object_initialize(void *obj, size_t size, const char *typename); +void object_initialize(void *obj, size_t size, const char *typename) + QEMU_DEPRECATED; =20 /** * object_initialize_child_with_props: @@ -873,6 +878,10 @@ void object_initialize(void *obj, size_t size, const c= har *typename); * has a reference count of 1 (for the "child<...>" property from the pare= nt), * so the object will be finalized automatically when the parent gets remo= ved. * + * Use of this function is now deprecated. All objects must be + * allocated using the object_new() family of functions and not + * statically embedded in a larger struct. + * * The variadic parameters are a list of pairs of (propname, propvalue) * strings. The propname of %NULL indicates the end of the property list. * If the object implements the user creatable interface, the object will @@ -883,7 +892,8 @@ void object_initialize(void *obj, size_t size, const ch= ar *typename); bool object_initialize_child_with_props(Object *parentobj, const char *propname, void *childobj, size_t size, const char *type, - Error **errp, ...) G_GNUC_NULL_TERMINATED; + Error **errp, ...) G_GNUC_NULL_TERMINATED + QEMU_DEPRECATED; =20 /** * object_initialize_child_with_propsv: @@ -897,12 +907,17 @@ bool object_initialize_child_with_props(Object *paren= tobj, * * See object_initialize_child() for documentation. * + * Use of this function is now deprecated. All objects must be + * allocated using the object_new() family of functions and not + * statically embedded in a larger struct. + * * Returns: %true on success, %false on failure. */ bool object_initialize_child_with_propsv(Object *parentobj, const char *propname, void *childobj, size_t size, const char *typ= e, - Error **errp, va_list vargs); + Error **errp, va_list vargs) + QEMU_DEPRECATED; =20 /** * object_initialize_child: @@ -917,13 +932,18 @@ bool object_initialize_child_with_propsv(Object *pare= ntobj, * object_initialize_child_with_props(parent, propname, * child, sizeof(*child), type, * &error_abort, NULL) + * + * Use of this function is now deprecated. All objects must be + * allocated using the object_new() family of functions and not + * statically embedded in a larger struct. */ #define object_initialize_child(parent, propname, child, type) \ object_initialize_child_internal((parent), (propname), \ (child), sizeof(*(child)), (type)) void object_initialize_child_internal(Object *parent, const char *propname, void *child, size_t size, - const char *type); + const char *type) + QEMU_DEPRECATED; =20 /** * object_dynamic_cast: diff --git a/qom/object.c b/qom/object.c index 0ac201de4c..33b2801ee4 100644 --- a/qom/object.c +++ b/qom/object.c @@ -522,9 +522,11 @@ bool object_initialize_child_with_props(Object *parent= obj, bool ok; =20 va_start(vargs, errp); +QEMU_DEPRECATIONS_OFF; ok =3D object_initialize_child_with_propsv(parentobj, propname, childobj, size, type, errp, vargs); +QEMU_DEPRECATIONS_ON; va_end(vargs); return ok; } @@ -539,7 +541,9 @@ bool object_initialize_child_with_propsv(Object *parent= obj, Object *obj; UserCreatable *uc; =20 +QEMU_DEPRECATIONS_OFF; object_initialize(childobj, size, type); +QEMU_DEPRECATIONS_ON; obj =3D OBJECT(childobj); =20 if (!object_set_propv(obj, vargs, errp)) { @@ -576,8 +580,10 @@ void object_initialize_child_internal(Object *parent, void *child, size_t size, const char *type) { +QEMU_DEPRECATIONS_OFF; object_initialize_child_with_props(parent, propname, child, size, type, &error_abort, NULL); +QEMU_DEPRECATIONS_ON; } =20 static inline bool object_property_is_child(ObjectProperty *prop) --=20 2.54.0 From nobody Sun Jul 26 13:26:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781625406; cv=none; d=zohomail.com; s=zohoarc; b=KVfvZptME+ioTfYbqDtKQ2APHu5ayKgJUy5cJNSRidtv6o7bOTzbjnBO3KZ5xqWa81dkIJSY2BIWqyyVsBHzjpvyzbjGz82Kk0Cx3cLermENaZTwSvfC5tFIR3XNGUM3NUTHOg4sFrJ1FtzDIVhOsUp0XqOPL+hClWrvGLh8rxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781625406; h=Content-Type: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=bo7jn8LqtJ2JkPL2e0g5qPHWAc2w+sVwMteBw+aQUSA=; b=UNrsVNLMYIjh4c3Z3vJQiuWb0RS8kywqQ3uLi5UMnseIzIk81jVNaAoH7Wd9T+U3QjmTSprwastq/46C2yFtMiL5YE6l6KZjqL2hb7KA3t4CJJiVRIgPFLcd5UI/mu1e+2V6WWyQ2BL27qrX6V//EIS+jsUOXp9uRWv5BRLkdFM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781625406398795.9956369454046; Tue, 16 Jun 2026 08:56:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wZW9P-0002B2-MH; Tue, 16 Jun 2026 11:56:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9N-00028F-Ia for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9L-0003oo-4O for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:29 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-ugmAhsAQN9mgaEJU8abeSQ-1; Tue, 16 Jun 2026 11:56:22 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 104B518004A9; Tue, 16 Jun 2026 15:56:21 +0000 (UTC) Received: from berrange.com (unknown [10.44.49.111]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7191D195419E; Tue, 16 Jun 2026 15:56:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781625386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bo7jn8LqtJ2JkPL2e0g5qPHWAc2w+sVwMteBw+aQUSA=; b=hjtRNStJRLruv4Ubk8nv84uc54J3LwvCI1g8eggbw8XGllTaZeP597HpuBUydBbOVV8R06 ZBnTC6haOzY/pWX6NHV68XVao9ifZc/JfHhpDQOCQcuAWFRZfzn3Wf5t/0+ucfYDCLWgpw 4YHwa0pjG62pkKeFhrNrMKjjaJUF1EI= X-MC-Unique: ugmAhsAQN9mgaEJU8abeSQ-1 X-Mimecast-MFC-AGG-ID: ugmAhsAQN9mgaEJU8abeSQ_1781625381 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Peter Xu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" , Akihiko Odaki , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Aurelien Jarno , Fabiano Rosas , Paolo Bonzini , BALATON Zoltan , Mark Cave-Ayland , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [RFC 3/7] qom: deprecate use of instance properties Date: Tue, 16 Jun 2026 16:55:50 +0100 Message-ID: <20260616155554.264412-4-berrange@redhat.com> In-Reply-To: <20260616155554.264412-1-berrange@redhat.com> References: <20260616155554.264412-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1781625410477158500 The concept of class properties was introduced over 10 years ago. While there is significant use of class properties, there is a long way to go before any conversion is complete and new uses are often introduced as it is not obvious that class properties are preferred. The downsides of instances properties are: * Increased memory usage as the property info is duplicated across every instance. * Introspection side effects, since instances need to be created to be introspected and this can have unexpected side effects if code is not expecting these throwaway instances to be around. * Non-introspectable designs, if properties are conditionally registered against instances, those props may not be visible when a dummy instances is created for introspection. This deprecates the use of instance properties for all regular scalar properties. ie strings, integers, enums, etc. It does not deprecate instance properties used for setting up the QOM composition tree child relationships, nor the link or alias properties. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/qom/object.h | 70 +++++++++++++++++++++++++++++++++++++------- qom/object.c | 28 ++++++++++++++++++ 2 files changed, 88 insertions(+), 10 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index dd708b1136..e9ce15d595 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1175,6 +1175,10 @@ void object_unref(void *obj); * @opaque: an opaque pointer to pass to the callbacks for the property * @errp: pointer to error object * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add() + * function and not registered against instances. + * * Returns: The #ObjectProperty; this can be used to set the @resolve * callback for child and link properties. */ @@ -1183,7 +1187,8 @@ ObjectProperty *object_property_try_add(Object *obj, = const char *name, ObjectPropertyAccessor *get, ObjectPropertyAccessor *set, ObjectPropertyRelease *release, - void *opaque, Error **errp); + void *opaque, Error **errp) + QEMU_DEPRECATED; =20 /** * object_property_add: @@ -1206,13 +1211,18 @@ ObjectProperty *object_property_try_add(Object *obj= , const char *name, * meant to allow a property to free its opaque upon object * destruction. This may be NULL. * @opaque: an opaque pointer to pass to the callbacks for the property + * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add() + * function and not registered against instances. */ ObjectProperty *object_property_add(Object *obj, const char *name, const char *type, ObjectPropertyAccessor *get, ObjectPropertyAccessor *set, ObjectPropertyRelease *release, - void *opaque); + void *opaque) + QEMU_DEPRECATED; =20 void object_property_del(Object *obj, const char *name); =20 @@ -1873,11 +1883,16 @@ Object *object_resolve_and_typecheck(const char *pa= th, const char *name, * Add a string property using getters/setters. This function will add a * property of type 'string'. * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add_str() + * function and not registered against instances. + * * Returns: The newly added property on success, or %NULL on failure. */ ObjectProperty *object_property_add_str(Object *obj, const char *name, char *(*get)(Object *, Error **), - void (*set)(Object *, const char *, Error **)= ); + void (*set)(Object *, const char *, Error **)) + QEMU_DEPRECATED; =20 ObjectProperty *object_class_property_add_str(ObjectClass *klass, const char *name, @@ -1895,11 +1910,16 @@ ObjectProperty *object_class_property_add_str(Objec= tClass *klass, * Add a bool property using getters/setters. This function will add a * property of type 'bool'. * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add_bool() + * function and not registered against instances. + * * Returns: The newly added property on success, or %NULL on failure. */ ObjectProperty *object_property_add_bool(Object *obj, const char *name, bool (*get)(Object *, Error **), - void (*set)(Object *, bool, Error **)); + void (*set)(Object *, bool, Error **)) + QEMU_DEPRECATED; =20 ObjectProperty *object_class_property_add_bool(ObjectClass *klass, const char *name, @@ -1918,13 +1938,18 @@ ObjectProperty *object_class_property_add_bool(Obje= ctClass *klass, * Add an enum property using getters/setters. This function will add a * property of type '@typename'. * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add_enum() + * function and not registered against instances. + * * Returns: The newly added property on success, or %NULL on failure. */ ObjectProperty *object_property_add_enum(Object *obj, const char *name, const char *typename, const QEnumLookup *lookup, int (*get)(Object *, Error **), - void (*set)(Object *, int, Error **)); + void (*set)(Object *, int, Error **)) + QEMU_DEPRECATED; =20 ObjectProperty *object_class_property_add_enum(ObjectClass *klass, const char *name, @@ -1942,10 +1967,15 @@ ObjectProperty *object_class_property_add_enum(Obje= ctClass *klass, * Add a read-only struct tm valued property using a getter function. * This function will add a property of type 'struct tm'. * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add_tm() + * function and not registered against instances. + * * Returns: The newly added property on success, or %NULL on failure. */ ObjectProperty *object_property_add_tm(Object *obj, const char *name, - void (*get)(Object *, struct tm *, Error **)); + void (*get)(Object *, struct tm *, Error **)) + QEMU_DEPRECATED; =20 ObjectProperty *object_class_property_add_tm(ObjectClass *klass, const char *name, @@ -1970,11 +2000,16 @@ typedef enum { * Add an integer property in memory. This function will add a * property of type 'uint8'. * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add_uint8= _ptr() + * function and not registered against instances. + * * Returns: The newly added property on success, or %NULL on failure. */ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *nam= e, const uint8_t *v, - ObjectPropertyFlags flags); + ObjectPropertyFlags flags) + QEMU_DEPRECATED; =20 ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name, @@ -1991,11 +2026,16 @@ ObjectProperty *object_class_property_add_uint8_ptr= (ObjectClass *klass, * Add an integer property in memory. This function will add a * property of type 'uint16'. * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add_uint1= 6_ptr() + * function and not registered against instances. + * * Returns: The newly added property on success, or %NULL on failure. */ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *na= me, const uint16_t *v, - ObjectPropertyFlags flags); + ObjectPropertyFlags flags) + QEMU_DEPRECATED; =20 ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name, @@ -2012,11 +2052,16 @@ ObjectProperty *object_class_property_add_uint16_pt= r(ObjectClass *klass, * Add an integer property in memory. This function will add a * property of type 'uint32'. * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add_uint3= 2_ptr() + * function and not registered against instances. + * * Returns: The newly added property on success, or %NULL on failure. */ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *na= me, const uint32_t *v, - ObjectPropertyFlags flags); + ObjectPropertyFlags flags) + QEMU_DEPRECATED; =20 ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name, @@ -2033,11 +2078,16 @@ ObjectProperty *object_class_property_add_uint32_pt= r(ObjectClass *klass, * Add an integer property in memory. This function will add a * property of type 'uint64'. * + * Use of this function is now deprecated. All properties must be + * registered against the class, using the object_class_property_add_uint6= 4_ptr() + * function and not registered against instances. + * * Returns: The newly added property on success, or %NULL on failure. */ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *na= me, const uint64_t *v, - ObjectPropertyFlags flags); + ObjectPropertyFlags flags) + QEMU_DEPRECATED; =20 ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name, diff --git a/qom/object.c b/qom/object.c index 33b2801ee4..415d5c5291 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1362,8 +1362,10 @@ object_property_try_add(Object *obj, const char *nam= e, const char *type, for (i =3D 0; i < INT16_MAX; ++i) { char *full_name =3D g_strdup_printf("%s[%d]", name_no_array, i= ); =20 + QEMU_DEPRECATIONS_OFF; ret =3D object_property_try_add(obj, full_name, type, get, set, release, opaque, NULL); + QEMU_DEPRECATIONS_ON; g_free(full_name); if (ret) { break; @@ -1403,8 +1405,10 @@ object_property_add(Object *obj, const char *name, c= onst char *type, ObjectPropertyRelease *release, void *opaque) { + QEMU_DEPRECATIONS_OFF; return object_property_try_add(obj, name, type, get, set, release, opaque, &error_abort); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -1951,9 +1955,11 @@ object_property_try_add_child(Object *obj, const cha= r *name, =20 type =3D g_strdup_printf("child<%s>", object_get_typename(child)); =20 + QEMU_DEPRECATIONS_OFF; op =3D object_property_try_add(obj, name, type, object_get_child_prope= rty, NULL, object_finalize_child_property, child, errp); + QEMU_DEPRECATIONS_ON; if (!op) { return NULL; } @@ -1967,7 +1973,9 @@ ObjectProperty * object_property_add_child(Object *obj, const char *name, Object *child) { + QEMU_DEPRECATIONS_OFF; return object_property_try_add_child(obj, name, child, &error_abort); + QEMU_DEPRECATIONS_ON; } =20 void object_property_allow_set_link(const Object *obj, const char *name, @@ -2145,11 +2153,13 @@ object_add_link_prop(Object *obj, const char *name, =20 full_type =3D g_strdup_printf("link<%s>", type); =20 + QEMU_DEPRECATIONS_OFF; op =3D object_property_add(obj, name, full_type, object_get_link_property, check ? object_set_link_property : NULL, object_release_link_property, prop); + QEMU_DEPRECATIONS_ON; op->resolve =3D object_resolve_link_property; return op; } @@ -2442,11 +2452,13 @@ object_property_add_str(Object *obj, const char *na= me, prop->get =3D get; prop->set =3D set; =20 + QEMU_DEPRECATIONS_OFF; return object_property_add(obj, name, "string", get ? property_get_str : NULL, set ? property_set_str : NULL, property_release_data, prop); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -2512,11 +2524,13 @@ object_property_add_bool(Object *obj, const char *n= ame, prop->get =3D get; prop->set =3D set; =20 + QEMU_DEPRECATIONS_OFF; return object_property_add(obj, name, "bool", get ? property_get_bool : NULL, set ? property_set_bool : NULL, property_release_data, prop); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -2577,11 +2591,13 @@ object_property_add_enum(Object *obj, const char *n= ame, prop->get =3D get; prop->set =3D set; =20 + QEMU_DEPRECATIONS_OFF; return object_property_add(obj, name, typename, get ? property_get_enum : NULL, set ? property_set_enum : NULL, property_release_data, prop); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -2655,10 +2671,12 @@ object_property_add_tm(Object *obj, const char *nam= e, =20 prop->get =3D get; =20 + QEMU_DEPRECATIONS_OFF; return object_property_add(obj, name, "struct tm", get ? property_get_tm : NULL, NULL, property_release_data, prop); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -2775,8 +2793,10 @@ object_property_add_uint8_ptr(Object *obj, const cha= r *name, setter =3D property_set_uint8_ptr; } =20 + QEMU_DEPRECATIONS_OFF; return object_property_add(obj, name, "uint8", getter, setter, NULL, (void *)v); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -2815,8 +2835,10 @@ object_property_add_uint16_ptr(Object *obj, const ch= ar *name, setter =3D property_set_uint16_ptr; } =20 + QEMU_DEPRECATIONS_OFF; return object_property_add(obj, name, "uint16", getter, setter, NULL, (void *)v); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -2855,8 +2877,10 @@ object_property_add_uint32_ptr(Object *obj, const ch= ar *name, setter =3D property_set_uint32_ptr; } =20 + QEMU_DEPRECATIONS_OFF; return object_property_add(obj, name, "uint32", getter, setter, NULL, (void *)v); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -2895,8 +2919,10 @@ object_property_add_uint64_ptr(Object *obj, const ch= ar *name, setter =3D property_set_uint64_ptr; } =20 + QEMU_DEPRECATIONS_OFF; return object_property_add(obj, name, "uint64", getter, setter, NULL, (void *)v); + QEMU_DEPRECATIONS_ON; } =20 ObjectProperty * @@ -2983,11 +3009,13 @@ object_property_add_alias(Object *obj, const char *= name, prop->target_obj =3D target_obj; prop->target_name =3D g_strdup(target_name); =20 + QEMU_DEPRECATIONS_OFF; op =3D object_property_add(obj, name, prop_type, property_get_alias, property_set_alias, property_release_alias, prop); + QEMU_DEPRECATIONS_ON; op->resolve =3D property_resolve_alias; if (target_prop->defval) { op->defval =3D qobject_ref(target_prop->defval); --=20 2.54.0 From nobody Sun Jul 26 13:26:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781625467; cv=none; d=zohomail.com; s=zohoarc; b=Ee0XV2CC1aIq0l8zRCKcqa65i07D6bOBLEXVybx9QyIprgqbuwLZYliP6k3HiW4theB//O4n3Wl9IatYKJ2EMcmAJ67Nm5/o1/Nc+amdivadUVsyIF8iAKn7k3YWmkwo9VOB9RZIzPtSXZe4SN9aOm6zPCjLXSjbRP6MdebnAPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781625467; h=Content-Type: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=cLJZ6XcA8ayCW7/0LWEa3/BF3pKTaWaZXznPUjSJF8Q=; b=YSZ0tRfkt16ff1b49MIF+2bU/kdenfBGNJDAgZ7Y9qtJYFcRyOgsYW+fL4gNr1D2rCPxUejAFjiihBOzZP9Br+VHwWtzz2n5oftvsv/NiP7mtopkzTT/JmYeayj7YRJzPMBP8Vnzz7vhKZVbaPFPrYfAWb+0SMaTldHnGezhcrU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781625467206467.0530947130512; Tue, 16 Jun 2026 08:57:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wZW9W-0002CQ-7l; Tue, 16 Jun 2026 11:56:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9U-0002Bs-Dd for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9S-0003p3-B6 for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:36 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-HCfVa5-sOaavKt4vJcGtVA-1; Tue, 16 Jun 2026 11:56:29 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BE2C71800A7E; Tue, 16 Jun 2026 15:56:26 +0000 (UTC) Received: from berrange.com (unknown [10.44.49.111]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1057195419E; Tue, 16 Jun 2026 15:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781625393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cLJZ6XcA8ayCW7/0LWEa3/BF3pKTaWaZXznPUjSJF8Q=; b=K6NFh5b/5w9/m+50fip+XdX9bIpkJNeibmVIcC0LY2qCbl6hJTMbpk5VkO65Oa7Sv82Dgo 8y6KiPB+p60PCloeC2cmUOOKq4TAequG8eB8b/UhGon/7TMYHbJ06GTt4KJTwmdiQGQ+bE zwRCFF/Q/Nu3SndttirgQPk8QruRtlg= X-MC-Unique: HCfVa5-sOaavKt4vJcGtVA-1 X-Mimecast-MFC-AGG-ID: HCfVa5-sOaavKt4vJcGtVA_1781625387 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Peter Xu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" , Akihiko Odaki , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Aurelien Jarno , Fabiano Rosas , Paolo Bonzini , BALATON Zoltan , Mark Cave-Ayland , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [RFC 4/7] system: add memory_region_new / memory_region_new_io Date: Tue, 16 Jun 2026 16:55:51 +0100 Message-ID: <20260616155554.264412-5-berrange@redhat.com> In-Reply-To: <20260616155554.264412-1-berrange@redhat.com> References: <20260616155554.264412-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1781625467976158500 Prepare for the move to dynamically allocated memory regions by introducing memory_region_new and memory_region_new_io functions which call through to object_new instead of object_initialize. TBD: add "new" variants for all the other memory_region_init variants. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/system/memory.h | 76 ++++++++++++++++++++++++++++++------ system/memory.c | 85 ++++++++++++++++++++++++++++++++++------- 2 files changed, 136 insertions(+), 25 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index 1417132f6d..b4c5a185c0 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1300,19 +1300,44 @@ static inline bool memory_region_section_intersect_= range(MemoryRegionSection *s, =20 /** * memory_region_init: Initialize a memory region - * - * The region typically acts as a container for other memory regions. Use - * memory_region_add_subregion() to add subregions. - * * @mr: the #MemoryRegion to be initialized * @owner: the object that tracks the region's reference count * @name: used for debugging; not visible to the user or ABI * @size: size of the region; any subregions beyond this size will be clip= ped + * + * The region typically acts as a container for other memory regions. Use + * memory_region_add_subregion() to add subregions. + * + * Use of this function is now deprecated. All memory regions must be + * allocated using the memory_region_new() family of functions and not + * statically embedded in a larger struct. */ void memory_region_init(MemoryRegion *mr, Object *owner, const char *name, - uint64_t size); + uint64_t size) + QEMU_DEPRECATED; + + +/** + * memory_region_new: Allocate a memory region. + * @owner: the object that owns the memory region in the composition tree + * @name: used for debugging; not visible to the user or ABI + * @size: size of the region; any subregions beyond this size will be clip= ped + * + * The region typically acts as a container for other memory regions. Use + * memory_region_add_subregion() to add subregions. + * + * The returned memory region will have a single reference, which is + * held by the @owner object in the QOM composition tree. Thus in the + * absence of any further references being acquired, the memory region + * will be freed when @owner is freed + * + * Returns: the newly allocated memory region + */ +MemoryRegion *memory_region_new(Object *owner, + const char *name, + uint64_t size); =20 /** * memory_region_ref: Add 1 to a memory region's reference count @@ -1344,11 +1369,7 @@ void memory_region_ref(MemoryRegion *mr); void memory_region_unref(MemoryRegion *mr); =20 /** - * memory_region_init_io: Initialize an I/O memory region. - * - * Accesses into the region will cause the callbacks in @ops to be called. - * if @size is nonzero, subregions will be clipped to @size. - * + * memory_region_init_io: Initialize an I/O memory region * @mr: the #MemoryRegion to be initialized. * @owner: the object that tracks the region's reference count * @ops: a structure containing read and write callbacks to be used when @@ -1356,13 +1377,46 @@ void memory_region_unref(MemoryRegion *mr); * @opaque: passed to the read and write callbacks of the @ops structure. * @name: used for debugging; not visible to the user or ABI * @size: size of the region. + * + * Accesses into the region will cause the callbacks in @ops to be called. + * if @size is nonzero, subregions will be clipped to @size. + * + * Use of this function is now deprecated. All memory regions must be + * allocated using the memory_region_new() family of functions and not + * statically embedded in a larger struct. */ void memory_region_init_io(MemoryRegion *mr, Object *owner, const MemoryRegionOps *ops, void *opaque, const char *name, - uint64_t size); + uint64_t size) + QEMU_DEPRECATED; + +/** + * memory_region_new_io: Allocates an I/O memory region + * @owner: the object that tracks the region's reference count + * @ops: a structure containing read and write callbacks to be used when + * I/O is performed on the region. + * @opaque: passed to the read and write callbacks of the @ops structure. + * @name: used for debugging; not visible to the user or ABI + * @size: size of the region. + * + * Accesses into the region will cause the callbacks in @ops to be called. + * if @size is nonzero, subregions will be clipped to @size. + * + * The returned memory region will have a single reference, which is + * held by the @owner object in the QOM composition tree. Thus in the + * absence of any further references being acquired, the memory region + * will be freed when @owner is freed + * + * Returns: the newly allocated memory region + */ +MemoryRegion *memory_region_new_io(Object *owner, + const MemoryRegionOps *ops, + void *opaque, + const char *name, + uint64_t size); =20 /** * memory_region_init_ram_flags_nomigrate: Initialize RAM memory region. diff --git a/system/memory.c b/system/memory.c index 739ba11da6..e8a539e37e 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1214,6 +1214,18 @@ static char *memory_region_escape_name(const char *n= ame) return escaped; } =20 +static char *memory_region_make_child(Object **owner, + const char *name) +{ + g_autofree char *escaped_name =3D memory_region_escape_name(name); + + if (!*owner) { + *owner =3D machine_get_container("unattached"); + } + + return g_strdup_printf("%s[*]", escaped_name); +} + static void memory_region_do_init(MemoryRegion *mr, Object *owner, const char *name, @@ -1227,20 +1239,6 @@ static void memory_region_do_init(MemoryRegion *mr, mr->owner =3D owner; mr->dev =3D (DeviceState *) object_dynamic_cast(mr->owner, TYPE_DEVICE= ); mr->ram_block =3D NULL; - - if (name) { - char *escaped_name =3D memory_region_escape_name(name); - char *name_array =3D g_strdup_printf("%s[*]", escaped_name); - - if (!owner) { - owner =3D machine_get_container("unattached"); - } - - object_property_add_child(owner, name_array, OBJECT(mr)); - object_unref(OBJECT(mr)); - g_free(name_array); - g_free(escaped_name); - } } =20 void memory_region_init(MemoryRegion *mr, @@ -1250,6 +1248,31 @@ void memory_region_init(MemoryRegion *mr, { object_initialize(mr, sizeof(*mr), TYPE_MEMORY_REGION); memory_region_do_init(mr, owner, name, size); + if (name) { + g_autofree char *childname =3D memory_region_make_child(&owner, na= me); + object_property_add_child(owner, childname, OBJECT(mr)); + object_unref(OBJECT(mr)); + } +} + +MemoryRegion *memory_region_new(Object *owner, + const char *name, + uint64_t size) +{ + /* + * error_abort is safe, because 'childname' includes a wildcard + * for dynamically assigning a unique name. Thus adding the child + * property cannot fail + */ + MemoryRegion *mr =3D MEMORY_REGION(object_new(TYPE_MEMORY_REGION)); + memory_region_do_init(mr, owner, name, size); + if (name) { + g_autofree char *childname =3D memory_region_make_child(&owner, na= me); + object_property_add_child(owner, childname, OBJECT(mr)); + object_unref(OBJECT(mr)); + + } + return mr; } =20 static void memory_region_get_container(Object *obj, Visitor *v, @@ -1574,10 +1597,22 @@ void memory_region_init_io(MemoryRegion *mr, Object= *owner, const char *name, uint64_t size) { g_assert(!ops || !(ops->impl.unaligned && !ops->valid.unaligned)); + QEMU_DEPRECATIONS_OFF; memory_region_init(mr, owner, name, size); + QEMU_DEPRECATIONS_ON; memory_region_set_ops(mr, ops, opaque); } =20 +MemoryRegion *memory_region_new_io(Object *owner, + const MemoryRegionOps *ops, void *opaqu= e, + const char *name, uint64_t size) +{ + g_assert(!ops || !(ops->impl.unaligned && !ops->valid.unaligned)); + MemoryRegion *mr =3D memory_region_new(owner, name, size); + memory_region_set_ops(mr, ops, opaque); + return mr; +} + static bool memory_region_set_ram_block(MemoryRegion *mr, RAMBlock *rb) { mr->terminates =3D true; @@ -1597,7 +1632,9 @@ bool memory_region_init_ram_flags_nomigrate(MemoryReg= ion *mr, Object *owner, { RAMBlock *rb; =20 + QEMU_DEPRECATIONS_OFF; memory_region_init(mr, owner, name, size); + QEMU_DEPRECATIONS_ON; mr->ram =3D true; rb =3D qemu_ram_alloc(size, ram_flags, mr, errp); return memory_region_set_ram_block(mr, rb); @@ -1615,7 +1652,9 @@ bool memory_region_init_resizeable_ram(MemoryRegion *= mr, { RAMBlock *rb; =20 + QEMU_DEPRECATIONS_OFF; memory_region_init(mr, owner, name, size); + QEMU_DEPRECATIONS_ON; mr->ram =3D true; rb =3D qemu_ram_alloc_resizeable(size, max_size, resized, mr, errp); return memory_region_set_ram_block(mr, rb); @@ -1630,7 +1669,9 @@ bool memory_region_init_ram_from_file(MemoryRegion *m= r, Object *owner, { RAMBlock *rb; =20 + QEMU_DEPRECATIONS_OFF; memory_region_init(mr, owner, name, size); + QEMU_DEPRECATIONS_ON; mr->ram =3D true; mr->readonly =3D !!(ram_flags & RAM_READONLY); mr->align =3D align; @@ -1645,7 +1686,9 @@ bool memory_region_init_ram_from_fd(MemoryRegion *mr,= Object *owner, { RAMBlock *rb; =20 + QEMU_DEPRECATIONS_OFF; memory_region_init(mr, owner, name, size); + QEMU_DEPRECATIONS_ON; mr->ram =3D true; mr->readonly =3D !!(ram_flags & RAM_READONLY); rb =3D qemu_ram_alloc_from_fd(size, size, NULL, mr, ram_flags, fd, off= set, @@ -1667,7 +1710,9 @@ void memory_region_init_ram_ptr(MemoryRegion *mr, Obj= ect *owner, const char *name, uint64_t size, void *ptr) { + QEMU_DEPRECATIONS_OFF; memory_region_init(mr, owner, name, size); + QEMU_DEPRECATIONS_ON; mr->ram =3D true; memory_region_set_ram_ptr(mr, size, ptr); } @@ -1676,7 +1721,9 @@ void memory_region_init_ram_device_ptr(MemoryRegion *= mr, Object *owner, const char *name, uint64_t size, void *ptr) { + QEMU_DEPRECATIONS_OFF; memory_region_init_io(mr, owner, &ram_device_mem_ops, mr, name, size); + QEMU_DEPRECATIONS_ON; mr->ram =3D true; mr->ram_device =3D true; memory_region_set_ram_ptr(mr, size, ptr); @@ -1686,7 +1733,9 @@ void memory_region_init_alias(MemoryRegion *mr, Objec= t *owner, const char *name, MemoryRegion *orig, hwaddr offset, uint64_t size) { + QEMU_DEPRECATIONS_OFF; memory_region_init(mr, owner, name, size); + QEMU_DEPRECATIONS_ON; mr->alias =3D orig; mr->alias_offset =3D offset; } @@ -1704,6 +1753,12 @@ void memory_region_init_iommu(void *_iommu_mr, object_initialize(_iommu_mr, instance_size, mrtypename); mr =3D MEMORY_REGION(_iommu_mr); memory_region_do_init(mr, owner, name, size); + if (name) { + g_autofree char *childname =3D memory_region_make_child(&owner, na= me); + object_property_add_child(owner, childname, OBJECT(mr)); + object_unref(OBJECT(mr)); + } + iommu_mr =3D IOMMU_MEMORY_REGION(mr); mr->terminates =3D true; /* then re-forwards */ QLIST_INIT(&iommu_mr->iommu_notify); @@ -3703,7 +3758,9 @@ bool memory_region_init_rom_device(MemoryRegion *mr, = Object *owner, RAMBlock *rb; =20 assert(ops); + QEMU_DEPRECATIONS_OFF; memory_region_init_io(mr, owner, ops, opaque, name, size); + QEMU_DEPRECATIONS_ON; rb =3D qemu_ram_alloc(size, 0, mr, errp); if (memory_region_set_ram_block(mr, rb)) { mr->rom_device =3D true; --=20 2.54.0 From nobody Sun Jul 26 13:26:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781625478; cv=none; d=zohomail.com; s=zohoarc; b=g8P29WLLGafBKFHrLZ67cp7OJ4NRRxgDFrxp+lPxkO6hMTAFqrHlFvnd1kavD7RME5J//CT26Gp56u50QlIU7lBrKTURYqAHCU7LSMPxDeMJlQP5AUAGoPbXNAUF5veAf7dUoBiuy+lF2lXRAYXjTlIl4A5/R23LDhqZ6zR22HI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781625478; h=Content-Type: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=uuqZ60xVWcRIwM3ffZ1a2664p6ZIoKfbkaE0NcmmH0c=; b=kb1wPIhzfmfnCnBtyeEHmyRDNCNLgteFwAICYWaserCi9fLbWLX5tOQ40iFFY2YA13YAtDr3lQY0oyINEilf8XLOBuGZITelwyMNjKMJhHK7EFbMVLdBUA46K4eigey+RKAcJZDZZP/xbPQMtDNU7KD5xLeARGFC3OXjfNkf+7g= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781625478773452.6890532759571; Tue, 16 Jun 2026 08:57:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wZW9o-0002Of-VB; Tue, 16 Jun 2026 11:56:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9f-0002Jy-6M for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9U-0003pF-CX for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:38 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-53-iK5ov1o0P8O7Jt7VBWf2rQ-1; Tue, 16 Jun 2026 11:56:34 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2D7B3180025B; Tue, 16 Jun 2026 15:56:32 +0000 (UTC) Received: from berrange.com (unknown [10.44.49.111]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3EB2D195419F; Tue, 16 Jun 2026 15:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781625395; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uuqZ60xVWcRIwM3ffZ1a2664p6ZIoKfbkaE0NcmmH0c=; b=av7YTWUGYQWuqdZke3fON0qfIrm/CliuHso8Xg/fj5ANBiSS/LrQdUA2uydQoU4LguHnBL rwwQp0ndKVJ0ytgpkI6o8ecZ4iArAR2h8EGSuezb+3VryrCwEcFHwxLeYCSWDGplhaTuhU 6Ru5JSUPS3Ong/y7sawsGvnIFFgOsjI= X-MC-Unique: iK5ov1o0P8O7Jt7VBWf2rQ-1 X-Mimecast-MFC-AGG-ID: iK5ov1o0P8O7Jt7VBWf2rQ_1781625392 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Peter Xu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" , Akihiko Odaki , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Aurelien Jarno , Fabiano Rosas , Paolo Bonzini , BALATON Zoltan , Mark Cave-Ayland , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [RFC 5/7] system: add qemu_irq_new / qemu_irq_new_child / qemu_irq_new_array Date: Tue, 16 Jun 2026 16:55:52 +0100 Message-ID: <20260616155554.264412-6-berrange@redhat.com> In-Reply-To: <20260616155554.264412-1-berrange@redhat.com> References: <20260616155554.264412-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1781625480174158500 Prepare for the move to dynamically allocated IRQ objects by introducing qemu_irq_new / qemu_irq_new_child / qemu_irq_new_array functions which call through to object_new instead of object_initialize. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/irq.c | 35 ++++++++++++++++++++ include/hw/core/irq.h | 75 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 106 insertions(+), 4 deletions(-) diff --git a/hw/core/irq.c b/hw/core/irq.c index 106805e241..e943c87b81 100644 --- a/hw/core/irq.c +++ b/hw/core/irq.c @@ -49,6 +49,13 @@ void qemu_init_irq(IRQState *irq, qemu_irq_handler handl= er, void *opaque, init_irq_fields(irq, handler, opaque, n); } =20 +IRQState *qemu_irq_new(qemu_irq_handler handler, void *opaque, int n) +{ + IRQState *irq =3D IRQ(object_new(TYPE_IRQ)); + init_irq_fields(irq, handler, opaque, n); + return irq; +} + void qemu_init_irq_child(Object *parent, const char *propname, IRQState *irq, qemu_irq_handler handler, void *opaque, int n) @@ -57,14 +64,42 @@ void qemu_init_irq_child(Object *parent, const char *pr= opname, init_irq_fields(irq, handler, opaque, n); } =20 +IRQState *qemu_irq_new_child(Object *parent, const char *propname, + qemu_irq_handler handler, + void *opaque, int n, + Error **errp) +{ + IRQState *irq =3D IRQ(object_new_with_props(TYPE_IRQ, parent, propname, + errp, NULL)); + if (!irq) { + return NULL; + } + init_irq_fields(irq, handler, opaque, n); + return irq; +} + + void qemu_init_irqs(IRQState irq[], size_t count, qemu_irq_handler handler, void *opaque) { for (size_t i =3D 0; i < count; i++) { + QEMU_DEPRECATIONS_OFF; qemu_init_irq(&irq[i], handler, opaque, i); + QEMU_DEPRECATIONS_ON; } } =20 +IRQState **qemu_irq_new_array(size_t count, + qemu_irq_handler handler, void *opaque) +{ + IRQState **irqs =3D g_new0(IRQState *, count); + for (size_t i =3D 0; i < count; i++) { + irqs[i] =3D qemu_irq_new(handler, opaque, i); + } + return irqs; +} + + qemu_irq *qemu_extend_irqs(qemu_irq *old, int n_old, qemu_irq_handler hand= ler, void *opaque, int n) { diff --git a/include/hw/core/irq.h b/include/hw/core/irq.h index 291fdd67df..af9bf6fb12 100644 --- a/include/hw/core/irq.h +++ b/include/hw/core/irq.h @@ -34,7 +34,12 @@ static inline void qemu_irq_pulse(qemu_irq irq) qemu_set_irq(irq, 0); } =20 -/* +/** + * qemu_init_irq: Initialize IRQ + * @handler: handler function for incoming interrupts + * @opaque: opaque data to pass to @handler + * @n: interrupt number to pass to @handler + * * Init a single IRQ. The irq is assigned with a handler, an opaque data * and the interrupt number. The caller must free this with qemu_free_irq(= ). * If you are using this inside a device's init or realize method, then @@ -42,7 +47,21 @@ static inline void qemu_irq_pulse(qemu_irq irq) * to manually clean up the IRQ. */ void qemu_init_irq(IRQState *irq, qemu_irq_handler handler, void *opaque, - int n); + int n) + QEMU_DEPRECATED; +/** + * qemu_new_irq: Allocate IRQ + * @handler: handler function for incoming interrupts + * @opaque: opaque data to pass to @handler + * @n: interrupt number to pass to @handler + * + * The returned IRQ will have a single reference, which is held by the + * caller and must be released to free the returned IRQ object when + * no longer required. + * + * Returns: the newly allocated IRQ + */ +IRQState *qemu_irq_new(qemu_irq_handler handler, void *opaque, int n); =20 /** * qemu_init_irq_child: Initialize IRQ and make it a QOM child @@ -56,10 +75,38 @@ void qemu_init_irq(IRQState *irq, qemu_irq_handler hand= ler, void *opaque, * Init a single IRQ and make the IRQ object a child of @parent with * the child-property name @propname. The IRQ object will thus be * automatically freed when @parent is destroyed. + * + * Use of this function is now deprecated. All IRQs must be + * allocated using the qemu_irq_new() family of functions and not + * statically embedded in a larger struct. */ void qemu_init_irq_child(Object *parent, const char *propname, IRQState *irq, qemu_irq_handler handler, - void *opaque, int n); + void *opaque, int n) + QEMU_DEPRECATED; + +/** + * qemu_init_irq_child: Allocate IRQ and make it a QOM child + * @parent: QOM object which owns this IRQ + * @propname: child property name + * @handler: handler function for incoming interrupts + * @opaque: opaque data to pass to @handler + * @n: interrupt number to pass to @handler + * + * Allocate a single IRQ and make the IRQ object a child of @parent with + * the child-property name @propname. + * + * The returned IRQ will have a single reference, which is held by the + * @owner object in the QOM composition tree. Thus in the absence of + * any further references being acquired, the IRQ will be freed when + * @owner is freed + * + * Returns: the newly allocated IRQ + */ +IRQState *qemu_irq_new_child(Object *parent, const char *propname, + qemu_irq_handler handler, + void *opaque, int n, + Error **errp); =20 =20 /** @@ -69,9 +116,29 @@ void qemu_init_irq_child(Object *parent, const char *pr= opname, * @count: number of IRQs to initialize * @handler: handler to assign to each IRQ * @opaque: opaque data to pass to @handler + * + * Use of this function is now deprecated. All IRQs must be + * allocated using the qemu_irq_new() family of functions and not + * statically embedded in a larger struct. */ void qemu_init_irqs(IRQState irq[], size_t count, - qemu_irq_handler handler, void *opaque); + qemu_irq_handler handler, void *opaque) + QEMU_DEPRECATED; +/** + * qemu_irq_new_array: Allocate an array of IRQs. + * @count: number of IRQs to initialize + * @handler: handler to assign to each IRQ + * @opaque: opaque data to pass to @handler + * + * The returned IRQs will have a single reference, which is held by the + * caller and must be released to free the returned IRQs object when + * no longer required. The return array memory must also be freed by + * the caller. + * + * Returns: an array of IRQ objects + */ +IRQState **qemu_irq_new_array(size_t count, + qemu_irq_handler handler, void *opaque); =20 /* Returns an array of N IRQs. Each IRQ is assigned the argument handler a= nd * opaque data. --=20 2.54.0 From nobody Sun Jul 26 13:26:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781625433; cv=none; d=zohomail.com; s=zohoarc; b=EoM/Wz7hvuXA0RdfU7jG4+kZzrsHxQkZ47qy7ZyEv6hg9xf/mjc0XvDCKPyIxCRlT7xabtbGQfM0GzyeF5UNQtw3FUhKN6ORTE9gur2pJgqcPnRGoL7Eh+Db+h5kVcvd0G66GbSPdEuP1l+EfvZFTjomfJAz41y8umCsiI09bvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781625433; h=Content-Type: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=kMrxoR+qtQ8YIacApPzKbmwL4gIuSvYrdRw8AcbTj6U=; b=I70xij/bSATWdS2U+qMkv+Wi9YYF8Y7gCNqobBy3vpO1tqSVM3flSbwkN10iHhBa8CO9mOZYjqYAEZlFRni9ON5MxWjSo/+muRxyH9WAyIeT46uu514APFUFqWrTfCQjIrv7hGP6bXIYMR7dFVOttC2ThSTgmq6UKuyPEqvfhyE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781625433864227.60468787048865; Tue, 16 Jun 2026 08:57:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wZW9x-0002YB-4t; Tue, 16 Jun 2026 11:57:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9g-0002Nw-IE for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9e-0003pW-Ov for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:48 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-A_ekmGo-OF6j-ojGcfvClQ-1; Tue, 16 Jun 2026 11:56:39 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DB87219540D5; Tue, 16 Jun 2026 15:56:37 +0000 (UTC) Received: from berrange.com (unknown [10.44.49.111]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A19A1195419E; Tue, 16 Jun 2026 15:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781625402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kMrxoR+qtQ8YIacApPzKbmwL4gIuSvYrdRw8AcbTj6U=; b=TEkRZmp/PMHx/OQIh7c93AUCTi34ARWoyFcOdjkYl/dKTSd/xXXJIExjHaW0dugDXx2TST oKfeV6GhvjL+vCsdwt9zXeMSKziqFBfHnxK792BPNnVedlLIDs6Noi36Z1urP6GK6cb/XD OMjnJf1/D8GKuo2V28a2RypctjPDnzw= X-MC-Unique: A_ekmGo-OF6j-ojGcfvClQ-1 X-Mimecast-MFC-AGG-ID: A_ekmGo-OF6j-ojGcfvClQ_1781625398 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Peter Xu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" , Akihiko Odaki , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Aurelien Jarno , Fabiano Rosas , Paolo Bonzini , BALATON Zoltan , Mark Cave-Ayland , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [RFC 6/7] hw/isa: convert PIIX embedded QOM objects to heap allocated Date: Tue, 16 Jun 2026 16:55:53 +0100 Message-ID: <20260616155554.264412-7-berrange@redhat.com> In-Reply-To: <20260616155554.264412-1-berrange@redhat.com> References: <20260616155554.264412-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781625436073158500 Update for the new preferred QOM design by removing embedded QOM objects from the PIIXState struct for the RTC, IDE, UHCI, PM, IRQ and memory region classes. XXXX: there seems to be little benefit in having any of the instance fields for RTC, IDE, UHCI, PM & IRQ objects. These objects are all kept alive via the 'child' property which owns the primary reference. The instance fields are accessed durnig setup and then never again, so all these instances fields could arguably go away entirely. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/isa/piix.c | 65 ++++++++++++++++++++++------------- include/hw/southbridge/piix.h | 12 +++---- 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/hw/isa/piix.c b/hw/isa/piix.c index 31fa53e6a4..cd23486ef9 100644 --- a/hw/isa/piix.c +++ b/hw/isa/piix.c @@ -308,18 +308,22 @@ static void pci_piix_realize(PCIDevice *dev, const ch= ar *uhci_type, return; } =20 - memory_region_init_io(&d->rcr_mem, OBJECT(dev), &rcr_ops, d, - "piix-reset-control", 1); + d->rcr_mem =3D memory_region_new_io(OBJECT(dev), &rcr_ops, d, + "piix-reset-control", 1); memory_region_add_subregion_overlap(pci_address_space_io(dev), - PIIX_RCR_IOPORT, &d->rcr_mem, 1); + PIIX_RCR_IOPORT, d->rcr_mem, 1); =20 /* PIC */ if (d->has_pic) { qemu_irq *i8259; =20 - qemu_init_irq_child(OBJECT(dev), "i8259-irq", &d->i8259_irq, - piix_request_i8259_irq, d, 0); - i8259 =3D i8259_init(isa_bus, &d->i8259_irq); + d->i8259_irq =3D qemu_irq_new_child(OBJECT(dev), "i8259-irq", + piix_request_i8259_irq, d, 0, + errp); + if (!d->i8259_irq) { + return; + } + i8259 =3D i8259_init(isa_bus, d->i8259_irq); =20 for (size_t i =3D 0; i < ISA_NUM_IRQS; i++) { d->isa_irqs_in[i] =3D i8259[i]; @@ -340,38 +344,45 @@ static void pci_piix_realize(PCIDevice *dev, const ch= ar *uhci_type, i8257_dma_init(OBJECT(dev), isa_bus, 0); =20 /* RTC */ - qdev_prop_set_int32(DEVICE(&d->rtc), "base_year", 2000); - if (!qdev_realize(DEVICE(&d->rtc), BUS(isa_bus), errp)) { + qdev_prop_set_int32(DEVICE(d->rtc), "base_year", 2000); + if (!qdev_realize(DEVICE(d->rtc), BUS(isa_bus), errp)) { return; } - irq =3D object_property_get_uint(OBJECT(&d->rtc), "irq", &error_fatal); - isa_connect_gpio_out(ISA_DEVICE(&d->rtc), 0, irq); + irq =3D object_property_get_uint(OBJECT(d->rtc), "irq", &error_fatal); + isa_connect_gpio_out(ISA_DEVICE(d->rtc), 0, irq); =20 /* IDE */ - qdev_prop_set_int32(DEVICE(&d->ide), "addr", dev->devfn + 1); - if (!qdev_realize(DEVICE(&d->ide), BUS(pci_bus), errp)) { + qdev_prop_set_int32(DEVICE(d->ide), "addr", dev->devfn + 1); + if (!qdev_realize(DEVICE(d->ide), BUS(pci_bus), errp)) { return; } =20 /* USB */ if (d->has_usb) { - object_initialize_child(OBJECT(dev), "uhci", &d->uhci, uhci_type); - qdev_prop_set_int32(DEVICE(&d->uhci), "addr", dev->devfn + 2); - if (!qdev_realize(DEVICE(&d->uhci), BUS(pci_bus), errp)) { + d->uhci =3D UHCI(object_new_with_props( + uhci_type, OBJECT(d), "uhci", errp, NULL)); + if (!d->uhci) { + return; + } + qdev_prop_set_int32(DEVICE(d->uhci), "addr", dev->devfn + 2); + if (!qdev_realize(DEVICE(d->uhci), BUS(pci_bus), errp)) { return; } } =20 /* Power Management */ if (d->has_acpi) { - object_initialize_child(OBJECT(d), "pm", &d->pm, TYPE_PIIX4_PM); - qdev_prop_set_int32(DEVICE(&d->pm), "addr", dev->devfn + 3); - qdev_prop_set_uint32(DEVICE(&d->pm), "smb_io_base", d->smb_io_base= ); - qdev_prop_set_bit(DEVICE(&d->pm), "smm-enabled", d->smm_enabled); - if (!qdev_realize(DEVICE(&d->pm), BUS(pci_bus), errp)) { + d->pm =3D PIIX4_PM(object_new_with_props( + TYPE_PIIX4_PM, OBJECT(d), "pm", errp, NULL)); + if (!d->pm) { + } + qdev_prop_set_int32(DEVICE(d->pm), "addr", dev->devfn + 3); + qdev_prop_set_uint32(DEVICE(d->pm), "smb_io_base", d->smb_io_base); + qdev_prop_set_bit(DEVICE(d->pm), "smm-enabled", d->smm_enabled); + if (!qdev_realize(DEVICE(d->pm), BUS(pci_bus), errp)) { return; } - qdev_connect_gpio_out(DEVICE(&d->pm), 0, d->isa_irqs_in[9]); + qdev_connect_gpio_out(DEVICE(d->pm), 0, d->isa_irqs_in[9]); } =20 pci_bus_irqs(pci_bus, piix_set_pci_irq, d, PIIX_NUM_PIRQS); @@ -406,7 +417,9 @@ static void pci_piix_init(Object *obj) qdev_init_gpio_out_named(DEVICE(obj), d->isa_irqs_in, "isa-irqs", ISA_NUM_IRQS); =20 - object_initialize_child(obj, "rtc", &d->rtc, TYPE_MC146818_RTC); + d->rtc =3D MC146818_RTC( + object_new_with_props(TYPE_MC146818_RTC, obj, "rtc", + &error_abort, NULL)); } =20 static const Property pci_piix_props[] =3D { @@ -462,7 +475,9 @@ static void piix3_init(Object *obj) { PIIXState *d =3D PIIX_PCI_DEVICE(obj); =20 - object_initialize_child(obj, "ide", &d->ide, TYPE_PIIX3_IDE); + d->ide =3D PCI_IDE( + object_new_with_props(TYPE_PIIX3_IDE, obj, "ide", + &error_abort, NULL)); } =20 static void piix3_class_init(ObjectClass *klass, const void *data) @@ -492,7 +507,9 @@ static void piix4_init(Object *obj) { PIIXState *s =3D PIIX_PCI_DEVICE(obj); =20 - object_initialize_child(obj, "ide", &s->ide, TYPE_PIIX4_IDE); + s->ide =3D PCI_IDE( + object_new_with_props(TYPE_PIIX4_IDE, obj, "ide", + &error_abort, NULL)); } =20 static void piix4_class_init(ObjectClass *klass, const void *data) diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h index a296b1205a..8bd24946de 100644 --- a/include/hw/southbridge/piix.h +++ b/include/hw/southbridge/piix.h @@ -53,15 +53,15 @@ struct PIIXState { qemu_irq cpu_intr; qemu_irq isa_irqs_in[ISA_NUM_IRQS]; =20 - IRQState i8259_irq; + IRQState *i8259_irq; =20 /* This member isn't used. Just for save/load compatibility */ int32_t pci_irq_levels_vmstate[PIIX_NUM_PIRQS]; =20 - MC146818RtcState rtc; - PCIIDEState ide; - UHCIState uhci; - PIIX4PMState pm; + MC146818RtcState *rtc; + PCIIDEState *ide; + UHCIState *uhci; + PIIX4PMState *pm; =20 uint32_t smb_io_base; =20 @@ -69,7 +69,7 @@ struct PIIXState { uint8_t rcr; =20 /* IO memory region for Reset Control Register (PIIX_RCR_IOPORT) */ - MemoryRegion rcr_mem; + MemoryRegion *rcr_mem; =20 bool has_acpi; bool has_pic; --=20 2.54.0 From nobody Sun Jul 26 13:26:57 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781625455; cv=none; d=zohomail.com; s=zohoarc; b=oEvrqHmzhEy+tYwcXQEZ9jfcX72SXEWzBNrPZeKxfrQwn4xfqkwgqicSdiy0bJm/7qRtSKxPiuugnYqGtjnMeyNX5ZWrguNduhxQtYc4YTtNdTZcN3EIE4AodLDKAuv9Var8KMLSFBC5EB9OgLU3WFE+XbiM40r2RovAY/4WULU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781625455; h=Content-Type: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=lgr8s/niUw4Oc3KLoZ61Pzh0nCN2NdKi1xx3OTKo8n4=; b=Td+PtHbKavSWDmVkuwT3thpU/dSzmiTDTD39UNMxcpL1g6suMW81kzomEiN5sexBZtu6whrxH9bOMrVLA0wEthkUEltRpGkQoThmu6Ucg6Iu+h7N97sf57emHRHBULm97JVIUwBfhEzhclS5K9m1EtbrKUVdA5i94bmJSnjwZpM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781625455264887.3163501581334; Tue, 16 Jun 2026 08:57:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wZWA1-0002dE-Cl; Tue, 16 Jun 2026 11:57:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9k-0002Og-HP for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZW9j-0003qE-9a for qemu-devel@nongnu.org; Tue, 16 Jun 2026 11:56:52 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-YpKC7b5APHWmISvbhe6tEA-1; Tue, 16 Jun 2026 11:56:44 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DE36119560B5; Tue, 16 Jun 2026 15:56:42 +0000 (UTC) Received: from berrange.com (unknown [10.44.49.111]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5BE31195419E; Tue, 16 Jun 2026 15:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781625410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lgr8s/niUw4Oc3KLoZ61Pzh0nCN2NdKi1xx3OTKo8n4=; b=jICluEjlD9PS0DixSeVrXOVNKkmUzsdmeb+DIBbDAJjLiInWQzNvc+EpcwZWOrV6vo991i uMbqA7e3M2Tjbrlw5K6ivlfC3xc4MmLOO9/X65hWXAfmivJFVYTPFyF0BVO/WqzNyubbeH zf+C0Iq6cRkCUiDvpRYX0PCFYnK+0B0= X-MC-Unique: YpKC7b5APHWmISvbhe6tEA-1 X-Mimecast-MFC-AGG-ID: YpKC7b5APHWmISvbhe6tEA_1781625403 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Peter Xu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , "Michael S. Tsirkin" , Akihiko Odaki , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Aurelien Jarno , Fabiano Rosas , Paolo Bonzini , BALATON Zoltan , Mark Cave-Ayland , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [RFC 7/7] qom: improve error message for invalid ID values Date: Tue, 16 Jun 2026 16:55:54 +0100 Message-ID: <20260616155554.264412-8-berrange@redhat.com> In-Reply-To: <20260616155554.264412-1-berrange@redhat.com> References: <20260616155554.264412-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781625455705158500 Include the actual ID that was validated, since this may not be obvious in all contexts. Signed-off-by: Daniel P. Berrang=C3=A9 --- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qom/object.c b/qom/object.c index 415d5c5291..9cd17e3bcc 100644 --- a/qom/object.c +++ b/qom/object.c @@ -774,7 +774,7 @@ object_new_with_props_helper(const char *typename, (id =3D=3D NULL && parent =3D=3D NULL)); =20 if (id !=3D NULL && !id_wellformed(id)) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", "an identifie= r"); + error_setg(errp, "QOM ID value '%s' is not valid", id); error_append_hint(errp, "Identifiers consist of letters, digits, " "'-', '.', '_', starting with a letter.\n"); return NULL; --=20 2.54.0