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=1792493528; b=Qy28O2N7dWjE+iBhIOtxxVjH9WTCQz0xrx0xYSOmy40XlXk/d3Ipf6+pEL6s/o6HFNc7 WVU8vNopmuIcJmk2ysmrKbNS8T90C3X++IkK1vvofEFf0BZBzp/mOpp4RDW87vU5SGpEx 2bJgXE11CLIr42hYZQ8Wl7GVRbLE+aZDG4tHhIePm5y9PIsdZ4gyJno2ZnVX9qpP/VuHG 6p1UGioW8lyhy10Bhh5gifWCm84tKDKlQHfmTWQ6VIQQMeRALebZdBcOGkfQdg13mw28d 4OWTGlaVivt2MzPdiKjFuy+3SLkRJ3e6sgTaiPjGlvB/GX7WZuFPk0uF42vOwMcX7dw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792493528; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id: References:In-Reply-To:To:Cc:X-Developer-Signature:X-Developer-Key: X-Scanned-By; bh=edIbxy8j0ZeLmK0JPM910tAFzYTrVmN4a79XoyzsTPs=; b=jdfUs28gYZszNQ0dc+OKiz9SZMq7oOtWOXW2iOvgZO0l5e5Mhw32HZkM0CktXxBuMGP2 AKJJU7YrlEOQGJ5zJoFNIUXhxjLfnm6CpQknSV0Q9t1bBATr2vKhsIAcXGN0i+EeksfHZ u9r3Sq4CpPgnnXjKyXoVPJZcI4U5M96nr19A5FAA6CUpw9+vxlMLjBWlLIAduycKz/wLV Rsd4yhVuxByTRyHkHRSi/nyjZVMhH3g/6f0aLBkoOkh3kmAqPPHQec5Un5Rws+yi4Elws 9oEnugiynEdPu+h6bNFsi/IvFn3/NJRVGZriCWU95zosd95j/jFqnM3AhPLG/MlmHXg== 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=XWLOffIq; 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 A0562606A31B for ; Tue, 20 Oct 2026 10:52:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A0562606A31B 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=XWLOffIq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792493526; 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=edIbxy8j0ZeLmK0JPM910tAFzYTrVmN4a79XoyzsTPs=; b=XWLOffIqp0dzfMN7npTE8ln70l0mHDaJQ4YaNJRInktXlCaBxNhmbyBVPhyAV6otDDtdZy SGBHj4GLBUSArH6Iom+X3eSUe1sm1Jj0316wi3U4uAgDVTXTIztlHtKwQV/ossAe8gzT6w DXMxUDvxjwkY5B0h7ZOJsOZASue9/7c= 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-607-UkF2cxSIP0KFpD-x2kfPug-1; Tue, 20 Oct 2026 10:52:03 +0000 X-MC-Unique: UkF2cxSIP0KFpD-x2kfPug-1 X-Mimecast-MFC-AGG-ID: UkF2cxSIP0KFpD-x2kfPug_1792493519 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 171B41955DE8; Tue, 20 Oct 2026 10:51:59 +0000 (UTC) Received: from localhost (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D26A65BC; Tue, 20 Oct 2026 10:51:55 +0000 (UTC) From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Tue, 20 Oct 2026 14:46:21 +0400 Subject: [PATCH v7 64/65] qom: use QAPITypeInfo in object_property_get_enum 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: 8bit Message-Id: <20261020-qom-qapi-v7-64-431a86b02b58@redhat.com> References: <20261020-qom-qapi-v7-0-431a86b02b58@redhat.com> In-Reply-To: <20261020-qom-qapi-v7-0-431a86b02b58@redhat.com> To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , John Snow , Peter Maydell , Mauro Carvalho Chehab , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_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 , =?utf-8?q?Philippe_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 , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=4777; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=btPOLigegMrUtE/H8gDPhCCZC+0Be3DpIj2amZiGpeM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBq10ZdBPk60N5wT01axiLdb48ZwuPjCejnM2ZCc 8PglQD+RAWJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCatdGXQAKCRDa6OEJdZac 5SPyEAC5HRZ0r0eZqxI5kzCsHrclz4H0Z1qTSRRBggURJDWP1KPYcglKwzX4001DDcIq+3FTVpq uqL6jJTS5vpJyJyR897eCp/+/txzLU8tlhsslIoDbOhlREexjvA38cJU7R22vQlvcx+DpICRHE3 a5XvP5h0s1/Pyiwdap+iMevEvuEEcbH/jRuSHep2d8iVv7Koi8q0iUC8zZ9PuwSKBiXi/oILGfy aiMrs8f/RgP9W/MoV3ZQRoFzC+PDRjFuTVfcaA60kq0BkbXlZZqC8u7Z+II9Xx+mxD8jpqF0dvl YdxYl9iXw3cbjdx662K6DNPPTjQqlqch+lUyD9IDKGSOxwMVRZODMwFtKF8oOvp/VlJSjSI2dYp n/X+gSwpl4DPtL64HznEe7j1fcGEq0YFRHnDbDHbwuxtIa57jCuK6wDAdaarfxUiuLtPfX7zXKA 1mhzw7Xk53JCYfVRtyhDDwz68cwocztkSeDoHbr+rWIMtJWAgR3K0ZgRcwpuhUoaQpp7LtkUpd6 SttTn4wc4MNuYc4Awpzamcf3DaIFaC+EQhFDU5i9gl+OPJb5rstVcuwsDzcleSXgUaDrqgSpCQo Bgm5lkNrnrlf7BG0h6WM3CgbBEadCmph3q1159HTgqfLA36QI7zt946mDEQrtiXWNDke3TZA+Wo l6wkFmd77J6ABag== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 The typename parameter becomes a QAPITypeInfo pointer, and the validation compares prop->qapi_type against it instead of matching prop->type strings. Signed-off-by: Markus Armbruster Signed-off-by: Marc-André Lureau --- hw/core/machine-qmp-cmds.c | 4 +++- include/qom/object.h | 4 ++-- qom/object.c | 8 ++++---- tests/unit/check-qom-proplist.c | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 3fee45d568da..6b425baeb2da 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -18,6 +18,7 @@ #include "qapi/qapi-commands-accelerator.h" #include "qapi/qapi-commands-machine.h" #include "qobject/qobject.h" +#include "qapi/qapi-type-infos-common.h" #include "qapi/qobject-input-visitor.h" #include "qapi/type-helpers.h" #include "qemu/uuid.h" @@ -252,7 +253,8 @@ static int query_memdev(Object *obj, void *opaque) } else { m->has_reserve = true; } - m->policy = object_property_get_enum(obj, "policy", "HostMemPolicy", + m->policy = object_property_get_enum(obj, "policy", + &HostMemPolicy_type_info, &error_abort); host_nodes = object_property_get_qobject(obj, "host-nodes", diff --git a/include/qom/object.h b/include/qom/object.h index a9bbc44cfcc9..9f937e30dae5 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1566,7 +1566,7 @@ uint64_t object_property_get_uint(Object *obj, const char *name, * object_property_get_enum: * @obj: the object * @name: the name of the property - * @typename: the name of the enum data type + * @type_info: the QAPITypeInfo of the enum * @errp: returns an error if this function fails * * Returns: the value of the property, converted to an integer (which @@ -1574,7 +1574,7 @@ uint64_t object_property_get_uint(Object *obj, const char *name, * value is not an enum). */ int object_property_get_enum(Object *obj, const char *name, - const char *typename, Error **errp); + const QAPITypeInfo *type_info, Error **errp); /** * object_property_set: diff --git a/qom/object.c b/qom/object.c index 791d981dc689..40b569d4d574 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1775,7 +1775,7 @@ uint64_t object_property_get_uint(Object *obj, const char *name, } int object_property_get_enum(Object *obj, const char *name, - const char *typename, Error **errp) + const QAPITypeInfo *type_info, Error **errp) { char *str; int ret; @@ -1785,10 +1785,10 @@ int object_property_get_enum(Object *obj, const char *name, return -1; } - if (!g_str_equal(prop->type, typename)) { + if (prop->qapi_type != type_info) { error_setg(errp, "Property %s on %s is not '%s' enum type", - name, object_class_get_name( - object_get_class(obj)), typename); + name, object_class_get_name(object_get_class(obj)), + type_info->name); return -1; } diff --git a/tests/unit/check-qom-proplist.c b/tests/unit/check-qom-proplist.c index 69155e720751..1cb48c7490ef 100644 --- a/tests/unit/check-qom-proplist.c +++ b/tests/unit/check-qom-proplist.c @@ -582,14 +582,14 @@ static void test_dummy_getenum(void) val = object_property_get_enum(OBJECT(dobj), "av", - "DummyAnimal", + &dummy_animal_qapi_type_info, &error_abort); g_assert(val == DUMMY_PLATYPUS); /* A bad enum type name */ val = object_property_get_enum(OBJECT(dobj), "av", - "BadAnimal", + &dummy_str_qapi_type_info, &err); g_assert(val == -1); error_free_or_abort(&err); @@ -597,7 +597,7 @@ static void test_dummy_getenum(void) /* A non-enum property name */ val = object_property_get_enum(OBJECT(dobj), "iv", - "DummyAnimal", + &dummy_animal_qapi_type_info, &err); g_assert(val == -1); error_free_or_abort(&err); -- 2.56.0.116.g6de20f6092dc