From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793563921; b=xDwg+fWWN7wGDakfor+SgZkUzz29BvjvkvhOhJtTeEkkSaDuh3pJz8X9m3MuGX3Oag1X 1jn/ehkwSS/laylhOu9HkYRhrSSZgAgcIyx0zL6VWsi4AMTU/BdiPJldC7/pALCjNdc2J 9qZSf22Qd2Z4V6qDOkD56XDslSjmHFUKrA11N1f2IpS0BokgmxtD/Ktt62yOuFwTMfUqv SO/a5OE1PvPObhRaSt/BoekP6RkFZXOwQWneTOLJ+lwuQTAah9rQ6nUoD2O8vKwInMoVH AJg9+lzU0XHoqQHxRr7IRQeRoFH8jj/tMoWbSNxuM1Pf+FBsdZrNZDylslcNqazNaTw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793563921; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Received:Resent-To: Resent-From:Resent-Date:Resent-Message-ID:From:To:Cc:Subject: In-Reply-To:References:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Content-Transfer-Encoding:Lines:X-Scanned-By; bh=pn06HY/bU7f4uyfbIipnbJnjf3nU/iS9+J50VskAMwg=; b=IOz4KATLVXqQ8W8+s2x+MRzCJtM5ezvLE3tTEd3NkDl7Jg4+K43wGg1Vyi6E+ZOuEWTJ fqYxdTETqvdRqzF+aOwD/1+MSLkb7h4e4CtLSYDnYpxhySt0XqHO+tEDhNdTSZg0n+/LU B/6NPnk6Yw2h/en5GkqLq+pO6w4scCzRZ2cRTdVMnx5xl06retY3aMvlClVKRhTZgOxrm YVkVG4ffE35FQjAQPJA0AhgS4AGdu9gbjZypOtd7IqEORXG06YoH/qszkxevMw/X3XbQ3 D3Pl1gNc92N2DB6HQiLAolcN5iTFNbXvcrQNFUyl/5b2BmNGI5alpnOP89a9ozzL+rA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RTEHkke3; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6686C606A325 for ; Sun, 1 Nov 2026 20:12:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6686C606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RTEHkke3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793563919; 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:resent-to: resent-from:resent-message-id:in-reply-to:in-reply-to: references:references; bh=pn06HY/bU7f4uyfbIipnbJnjf3nU/iS9+J50VskAMwg=; b=RTEHkke3vtp7bYWhz4pCrjjq545SbT4JaFXnbyYX77/Bnfc3tpmAWT5V4ckUsfQF/zJl7/ j26rMHkdqvQ421ZOT+jEYexF8OOLoyVA8ck0xkyxfDH3ZjjiBn28KBBG8TLc7apaaxt2RF TH8GJ97DO0CPuqjScLVrrAnYcBbR6gA= 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-235-4TFtM2YWOHWzydJNIPJiaQ-1; Sun, 01 Nov 2026 15:11:53 -0500 X-MC-Unique: 4TFtM2YWOHWzydJNIPJiaQ-1 X-Mimecast-MFC-AGG-ID: 4TFtM2YWOHWzydJNIPJiaQ_1793563909 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 9B4FC1955F45; Sun, 1 Nov 2026 20:11:48 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.2]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C405C1956088; Sun, 1 Nov 2026 20:11:47 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6A55721E6A04; Sun, 01 Nov 2026 21:11:45 +0100 (CET) Resent-To: 17746591750@163.com, pasic@linux.ibm.com, alistair@alistair23.me, rathc@linux.ibm.com, graf@amazon.com, stefanb@linux.vnet.ibm.com, FangSheng.Huang@amd.com, xen-devel@lists.xenproject.org, michael.roth@amd.com, jamin_lin@aspeedtech.com, kane_chen@aspeedtech.com, palmer@dabbelt.com, rbolshakov@ddn.com, foss@defmacro.it, sebastian.huber@embedded-brains.de, fam@euphon.net, jiaxun.yang@flygoat.com, lizhijian@fujitsu.com, atar4qemu@gmail.com, edgar.iglesias@gmail.com, jasowangio@gmail.com, liwei1518@gmail.com, npiggin@gmail.com, zhangckid@gmail.com, titusr@google.com, wuhaotsh@google.com, arei.gonglei@huawei.com, berto@igalia.com, mark.cave-ayland@ilande.co.uk, junjie.cao@intel.com, zhao1.liu@intel.com, its@irrelevant.dk, clg@kaod.org, conor@kernel.org, david@kernel.org, jic23@kernel.org, kbusch@kernel.org, mchehab+huawei@kernel.org, sstabellini@kernel.org, peter.maydell@linaro.org, richard.henderson@linaro.org, zhiwei_liu@linux.alibaba.com, zhenwei.pi@linux.dev, adityag@linux.ibm.com, alifm@linux.ibm.com, amachhiw@linux.ibm.com, borntraeger@linux.ibm.com, brueckner@linux.ibm.com, farman@linux.ibm.com, harshpb@linux.ibm.com, iii@linux.ibm.com, jjherne@linux.ibm.com, milesg@linux.ibm.com, mjrosato@linux.ibm.com, luc@lmichel.fr, lixianglai@loongson.cn, maobibo@loongson.cn, pbarbuda@microsoft.com, yoshinori.sato@nifty.com, qemu-arm@nongnu.org, qemu-block@nongnu.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, john.levon@nutanix.com, thanos.makatos@nutanix.com, kfting@nuvoton.com, den@openvz.org, elena.ufimtseva@oracle.com, jag.raman@oracle.com, daniel.barboza@oss.qualcomm.com, philmd@oss.qualcomm.com, pierrick.bouvier@oss.qualcomm.com, phil@philjordan.eu, tangtao1634@phytium.com.cn, chao.liu@processmission.com, jiri@resnulli.us, sam@rfc1149.net, anisa.su@samsung.com, alex@shazbot.org, farosas@suse.de, mohamed@unpredictable.fr, kvm@vger.kernel.org, linux-cxl@vger.kernel.org, alistair.francis@wdc.com, anthony@xenproject.org Resent-From: Markus Armbruster Resent-Date: Sun, 01 Nov 2026 21:11:45 +0100 Resent-Message-ID: <87ecd41fcu.fsf@pond.sub.org> From: Markus Armbruster To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel@nongnu.org, Michael Roth , John Snow , Peter Maydell , Mauro Carvalho Chehab , Pierrick Bouvier , Paolo Bonzini , Daniel P. =?utf-8?Q?Berrang=C3=A9?= , Kostiantyn Kostiuk , Eric Blake , David Hildenbrand , Igor Mammedov , "Edgar E. Iglesias" , Jason Wang , Marcelo Tosatti , kvm@vger.kernel.org, Alberto Garcia , Kevin Wolf , Hanna Reitz , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Zhao Liu , Jonathan Cameron , Junjie Cao , Anisa Su , Elena Ufimtseva , Jagannathan Raman , John Levon , Thanos Makatos , =?utf-8?Q?C=C3=A9dric?= Le Goater , Cornelia Huck , Eric Farman , Matthew Rosato , Richard Henderson , Ilya Leoshkevich , qemu-block@nongnu.org, linux-cxl@vger.kernel.org, qemu-s390x@nongnu.org, "Michael S. Tsirkin" , Sergio Lopez , qemu-arm@nongnu.org, Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , qemu-riscv@nongnu.org, Song Gao <17746591750@163.com>, Bibo Mao , Xianglai Li , Jiaxun Yang , Pedro Barbuda , Mohamed Mediouni , Nicholas Piggin , Harsh Prateek Bora , Amit Machhiwal , qemu-ppc@nongnu.org, Zhang Chen , Li Zhijian , Alistair Francis , Alexander Graf , "Gonglei (Arei)" , zhenwei pi , Ani Sinha , Luc Michel , =?utf-8?Q?C=C3=A9dric?= Le Goater , Jamin Lin , Kane Chen , Samuel Tardieu , "Denis V. Lunev" , FangSheng Huang , Tyrone Ting , Hao Wu , Keith Busch , Klaus Jensen , Jesper Devantier , Aditya Gupta , Glenn Miles , Conor Dooley , Sebastian Huber , Halil Pasic , Christian Borntraeger , Jason Herne , Titus Rwantare , Stefano Stabellini , Anthony PERARD , Peter Xu , Chinmay Rath , Hendrik Brueckner , xen-devel@lists.xenproject.org, Roman Bolshakov , Phil Dennis-Jordan , Fam Zheng , Farhan Ali , Alex Williamson , Tao Tang , Stefan Berger , Fabiano Rosas , Mark Cave-Ayland , Artyom Tarasenko , Yoshinori Sato , Jiri Pirko , Eric Auger , Laurent Vivier Subject: Re: [PATCH v7 17/65] qom: add object_{class_}property_add_qapi_enum In-Reply-To: (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Fri, 30 Oct 2026 16:11:12 +0400") References: <20261020-qom-qapi-v7-0-431a86b02b58@redhat.com> <20261020-qom-qapi-v7-17-431a86b02b58@redhat.com> <871p97a4mf.fsf@pond.sub.org> Date: Sun, 01 Nov 2026 12:18:09 +0100 Message-ID: <87se1k7qby.fsf@pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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.12 Marc-Andr=C3=A9 Lureau writes: > Hi > > On Fri, Oct 30, 2026 at 2:02=E2=80=AFPM Markus Armbruster wrote: >> >> Marc-Andr=C3=A9 Lureau writes: >> >> > Signed-off-by: Markus Armbruster >> > Signed-off-by: Marc-Andr=C3=A9 Lureau >> > --- >> > include/qom/object.h | 74 ++++++++++++++++++++++++++++++++++++++++++ >> > qom/object.c | 90 +++++++++++++++++++++++++++++++++++++++++++= ++++++--- >> > 2 files changed, 159 insertions(+), 5 deletions(-) >> > >> > diff --git a/include/qom/object.h b/include/qom/object.h >> > index eb61d8842b80..e04be4caed57 100644 >> > --- a/include/qom/object.h >> > +++ b/include/qom/object.h >> > @@ -2027,6 +2027,80 @@ ObjectProperty *object_class_property_add_enum(= ObjectClass *klass, >> > int (*get)(Object *, Error **), >> > void (*set)(Object *, int, Error = **)); >> > >> > +/** >> > + * struct QapiEnumProp: Descriptor for a property backed by a QAPI en= um type >> > + * >> > + * Binds a QOM object property to a QAPI enum, providing automatic >> > + * string<->int conversion through QAPI visitors and optional >> > + * default-value initialization during object instance init. >> > + * >> > + * Use the QAPI_ENUM_PROP() macro to construct instances inline. >> > + * >> > + * @name: property name exposed on the QOM object >> > + * @description: human-readable description (shown in ``-device help`= `, etc.) >> > + * @default_value: initial enum value applied via @set during instanc= e init, >> > + * or -1 (the QAPI_ENUM_PROP default) to skip initial= ization >> > + * @qapi_type: pointer to the generated QAPITypeInfo for the enum >> > + * (provides the string<->int lookup table) >> > + * @get: getter that returns the current enum value as int, or -1 on = error >> > + * @set: setter that receives the enum value as int; %NULL for read-o= nly props >> > + */ >> > +typedef struct QapiEnumProp { >> > + const char *name; >> > + const char *description; >> > + const int default_value; >> > + const QAPITypeInfo *qapi_type; >> > + int (*get)(Object *, Error **); >> > + void (*set)(Object *, int, Error **); >> > +} QapiEnumProp; >> > + >> > +#define QAPI_ENUM_PROP(...) ({ = \ >> > + static const QapiEnumProp _prop =3D { = \ >> > + .default_value =3D -1, __VA_ARGS__ = \ >> > + }; = \ >> > + &_prop; }) >> >> This is a cute and reasonably well-known macro trick for optional >> keyword arguments in C. >> >> The example [*] below specifies all arguments. What happens when we >> omit any? They default to zero via default initializaion, except for >> .default_value, which defaults to -1. >> >> Trap for developers: some arguments aren't actually optional! If you >> forget to specify @name or @qapi_type, the code compiles, but crashes at >> run time. >> >> Not a fan. > > Agree (not a fan of C either). We could probably add more > static/runtime checks. Or clearly state that there is room for > improvements, or just drop it altogether - either as follow up or with > the series. I leave that up to you since you are going to respin it. > thanks! I dropped it for v8. Was a bit of a pain, but the patches became simpler. [...]