From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A8EBCD6E7C for ; Fri, 5 Jun 2026 15:18:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVWJQ-00043V-0v; Fri, 05 Jun 2026 11:18:20 -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 1wVWJN-00042n-Qn for qemu-devel@nongnu.org; Fri, 05 Jun 2026 11:18:18 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wVWJL-0005K4-9F for qemu-devel@nongnu.org; Fri, 05 Jun 2026 11:18:17 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A0AF76B35F; Fri, 5 Jun 2026 15:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1780672693; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vDpNPUigs65jEa9G7QEOJsEJ9qLu0anggDAH1Z76ER4=; b=k5SsOLAi2jyfQwO33OUYbR96hfKNg32HruKG3ZPkbumH2yd1Ks2iqXWcl8n0yR5tKzvjs+ jm+CKOj098plc/ly2URgNBRBo5h6Rzeg/Y3Uf+XuPE/lqvQpJV0TcArTq82Ag8+JHwSOG4 Qc/Pp1A8+b8xA9NtFSMgVVbml+2L+ho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1780672693; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vDpNPUigs65jEa9G7QEOJsEJ9qLu0anggDAH1Z76ER4=; b=O5AmwomreyDStg40S65AFaEoSWYwvTzsjHeQWz4A0wAWhc1dYdGnFsz3kkgGRlV0rMBDg2 lFI8q8EYZ+IEVADA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=k5SsOLAi; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=O5Amwomr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1780672693; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vDpNPUigs65jEa9G7QEOJsEJ9qLu0anggDAH1Z76ER4=; b=k5SsOLAi2jyfQwO33OUYbR96hfKNg32HruKG3ZPkbumH2yd1Ks2iqXWcl8n0yR5tKzvjs+ jm+CKOj098plc/ly2URgNBRBo5h6Rzeg/Y3Uf+XuPE/lqvQpJV0TcArTq82Ag8+JHwSOG4 Qc/Pp1A8+b8xA9NtFSMgVVbml+2L+ho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1780672693; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vDpNPUigs65jEa9G7QEOJsEJ9qLu0anggDAH1Z76ER4=; b=O5AmwomreyDStg40S65AFaEoSWYwvTzsjHeQWz4A0wAWhc1dYdGnFsz3kkgGRlV0rMBDg2 lFI8q8EYZ+IEVADA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3B0E7779A8; Fri, 5 Jun 2026 15:18:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 1yLnArXoImp9fQAAD6G6ig (envelope-from ); Fri, 05 Jun 2026 15:18:13 +0000 From: Fabiano Rosas To: Mark Cave-Ayland , Peter Xu , qemu-devel@nongnu.org Cc: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Juraj Marcin , Vladimir Sementsov-Ogievskiy , =?utf-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Sana Sharma , Eric Blake , Markus Armbruster , Kevin Wolf , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Akihiko Odaki , =?utf-8?Q?C=C3=A9dric?= Le Goater , "Dr . David Alan Gilbert" Subject: Re: [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev In-Reply-To: References: <20260604231118.1584889-1-peterx@redhat.com> <20260604231118.1584889-2-peterx@redhat.com> Date: Fri, 05 Jun 2026 12:18:06 -0300 Message-ID: <874ijh6moh.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[16]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MISSING_XM_UA(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid, suse.de:dkim, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: A0AF76B35F Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Mark Cave-Ayland writes: > On 05/06/2026 00:11, Peter Xu wrote: > >> Property itself is a well defined interface to either support smooth >> conversions to Object's properties, or supports global properties. However >> currently it's tied to DeviceClass, aka, qdev. So non-qdev cannot use >> Property list. > > That's indeed because Property is a qdev-only concept. > >> My current observation shows Property is almost ready to be used as a >> separated exported interface, except two small things that may need touch >> up internally: >> >> qdev_prop_allow_set >> qdev_prop_check_globals >> >> The 1st one currently checks against realize state (which is part of qdev >> attributes only). The 2nd one checks for all global property being used in >> all non-pluggable qdevs. >> >> We can loose the check in both spots, keep the check if the driver is a >> qdev, otherwise we can safely whitelist non-qdev use cases of Property. > > I'm really not sure this is the right approach: surely you would want to > flip this on its head so that -global makes use of the underlying QOM > APIs instead of qdev APIs? > That's a good point. It seems we could do the same as qdev does without having to use the Property directly. It creates some awkwardness with the setting of defaults, but it's probably quite doable. >> Signed-off-by: Peter Xu >> --- >> hw/core/qdev-properties.c | 24 ++++++++++++++++++++---- >> tests/unit/test-qdev-global-props.c | 6 +++++- >> 2 files changed, 25 insertions(+), 5 deletions(-) >> >> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c >> index 34d7b26a73..8f870c85fc 100644 >> --- a/hw/core/qdev-properties.c >> +++ b/hw/core/qdev-properties.c >> @@ -31,8 +31,14 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name, >> static bool qdev_prop_allow_set(Object *obj, const char *name, >> const PropertyInfo *info, Error **errp) >> { >> - DeviceState *dev = DEVICE(obj); >> + DeviceState *dev; >> + >> + if (!object_dynamic_cast(obj, TYPE_DEVICE)) { >> + /* Currently, non-qdev can always set Property anytime */ >> + return true; >> + } >> >> + dev = DEVICE(obj); >> if (dev->realized && !info->realized_set_allowed) { >> qdev_prop_set_after_realize(dev, name, errp); >> return false; >> @@ -997,6 +1003,7 @@ int qdev_prop_check_globals(void) >> >> for (i = 0; i < global_props()->len; i++) { >> GlobalProperty *prop; >> + bool hotpluggable; >> ObjectClass *oc; >> DeviceClass *dc; >> >> @@ -1005,15 +1012,24 @@ int qdev_prop_check_globals(void) >> continue; >> } >> oc = object_class_by_name(prop->driver); >> - oc = object_class_dynamic_cast(oc, TYPE_DEVICE); >> if (!oc) { >> warn_report("global %s.%s has invalid class name", >> prop->driver, prop->property); >> ret = 1; >> continue; >> } >> - dc = DEVICE_CLASS(oc); >> - if (!dc->hotpluggable && !prop->used) { >> + oc = object_class_dynamic_cast(oc, TYPE_DEVICE); >> + if (oc) { >> + dc = DEVICE_CLASS(oc); >> + hotpluggable = dc->hotpluggable; >> + } else { >> + /* >> + * Currently, to be strict to assume all non-qdev are not >> + * hotpluggable (whoever will use -global). >> + */ >> + hotpluggable = false; >> + } >> + if (!hotpluggable && !prop->used) { >> warn_report("global %s.%s=%s not used", >> prop->driver, prop->property, prop->value); >> ret = 1; >> diff --git a/tests/unit/test-qdev-global-props.c b/tests/unit/test-qdev-global-props.c >> index 8ea362cbb9..86bb1458d9 100644 >> --- a/tests/unit/test-qdev-global-props.c >> +++ b/tests/unit/test-qdev-global-props.c >> @@ -275,8 +275,12 @@ static void test_dynamic_globalprop(void) >> g_test_trap_assert_stderr_unmatched("*prop4*"); >> g_test_trap_assert_stderr( >> "*warning: global nohotplug-type.prop5=105 not used*"); >> + /* >> + * TYPE_OBJECT can opt-in for global properties, so the error is "not >> + * used" too for nondevice-type. >> + */ >> g_test_trap_assert_stderr( >> - "*warning: global nondevice-type.prop6 has invalid class name*"); >> + "*warning: global nondevice-type.prop6=106 not used*"); >> g_test_trap_assert_stdout(""); >> } > > > ATB, > > Mark.