From nobody Tue Feb 10 19:23:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1770692343; cv=none; d=zohomail.com; s=zohoarc; b=MmPelBJ4A175R/GeKtJqD5za0sXqGivOPn0qI2yrV8twl/qIjSS3Y3a5bQd8heLZZH4iwYhcK+aEvoxCncDytbTePkdTrPshDqlrY9iowpCxrcodgeGTdEBMhAkB85RD0DP60i1++udk9qjrUu5GeOKIJVJ6aJbIE4HMyz+PP0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770692343; h=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=SKzzBt3VWSreE2CygljN90FG+G54tYzwhrhwURpmul0=; b=m4ndzpiKoQxbadk+7lqlUxKrGYVvn9gx7eq8R9bYx/VfMt947bl4AfNyXXS2l3zTjKKwzQwtBfE/PTeN7Wo0r2lHPSQjPYrzEEmPbOiWD3UAMoJJVyg+3h148RaPjJZsYMSs4pTgjrJVy1XeLw05kElacFu08sPmmpw0FzANWrQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177069234371836.96822858998405; Mon, 9 Feb 2026 18:59:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vpdxO-00062J-8W; Mon, 09 Feb 2026 21:58:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vpdxM-00061w-Cj for qemu-devel@nongnu.org; Mon, 09 Feb 2026 21:58:28 -0500 Received: from mgamail.intel.com ([198.175.65.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vpdxK-00046a-Ig for qemu-devel@nongnu.org; Mon, 09 Feb 2026 21:58:28 -0500 Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2026 18:58:25 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa008.jf.intel.com with ESMTP; 09 Feb 2026 18:58:19 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1770692307; x=1802228307; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3N/SwZLpsJhPnT1hj2JLd5OJ+UF0eDFP2x5yKTQlPEg=; b=DCZfstVpGBvqzrv1qmMkUOnqzHdJZS58ttK3ChBT2cfRbMhYCtkv/6D4 lWW3rWngkT/Eu8OuXzreOaibHW+SFyT7jzoz212xuX0tmT8d5gtgVaSjc WlYUU+xVlXhRk5Y4WYSqrM9RF6cubU4tj/0igtj/7aeK8njICo5hLTjNb wcHGPp71mZiE7HsN+ek8gKog37tn0+A4dtc0Vj9vl+f1h5572a2AJ37gY BOXKS1nHOmQRMFHmjsDzA6yeFOUJdyr2uIL69SVp2PwbJEh4NzwSGQAJn GRFkHAi05LAyuaqXJeMFwiGd1jPZSQAWmFgl5QFJzr+lC1eg7+RVs8BlX g==; X-CSE-ConnectionGUID: cUrpRaNqQaKM2OdUVEd37g== X-CSE-MsgGUID: l6MibZx7RzyEikh+S5jfFg== X-IronPort-AV: E=McAfee;i="6800,10657,11696"; a="71854237" X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="71854237" X-CSE-ConnectionGUID: Kh4wfJ2nRp2esYlklM4GwA== X-CSE-MsgGUID: zoSKirtdQNSWvFThDGGnHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,283,1763452800"; d="scan'208";a="211800442" From: Zhao Liu To: Paolo Bonzini , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Eduardo Habkost , Markus Armbruster , Thomas Huth , Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Cc: Richard Henderson , Peter Maydell , "Michael S . Tsirkin" , BALATON Zoltan , Mark Cave-Ayland , Pierrick Bouvier , Zide Chen , Dapeng Mi , Zhao Liu , qemu-devel@nongnu.org, devel@lists.libvirt.org Subject: [PATCH v2 02/21] qom/object: cache ObjectPropertyFlags in ObjectProperty Date: Tue, 10 Feb 2026 11:23:29 +0800 Message-Id: <20260210032348.987549-3-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260210032348.987549-1-zhao1.liu@intel.com> References: <20260210032348.987549-1-zhao1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=198.175.65.18; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1770692345536154100 Content-Type: text/plain; charset="utf-8" Introduce a 'flags' field in the ObjectProperty structure to store property-specific behavior modifiers. Currently, ObjectPropertyFlags (READ/WRITE) are only used for property creation (e.g., initialize accessors for pointer properties). By caching these flags directly in ObjectProperty, we can: 1. Preserve the initial access intent (read/write) of the property. * the READ/WRITE flags cached in ObjectProperty have no effect for now, but they may be useful for cases need write-once, if needed. 2. Reuse existing ObjectPropertyFlags and provide a foundation for future flags (e.g., to track if a property was explicitly set by external user). To avoid "incomplete type" error, move ObjectPropertyFlags before ObjectProperty definition, and polish the comment of ObjectPropertyFlags to clarify how READ/WRITE flags work for general properties. Suggested-by: Igor Mammedov Signed-off-by: Zhao Liu --- include/qom/object.h | 34 +++++++++++++++++++++++++--------- qom/object.c | 16 +++++++++++++++- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 6226b88c1eda..05706d4d7e3a 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -87,6 +87,30 @@ typedef void (ObjectPropertyRelease)(Object *obj, */ typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop); =20 +typedef enum { + /* + * The property is readable and has a getter. + * + * For pointer property, this flag (set in object_{class_}property_add= _*_ptr()) + * will automatically add a getter to this property. + */ + OBJ_PROP_FLAG_READ =3D BIT(0), + /* + * The property is writable and has a setter. + * + * For pointer property, this flag (set in object_{class_}property_add= _*_ptr()) + * will automatically add a setter to this property. + */ + OBJ_PROP_FLAG_WRITE =3D BIT(1), + /* + * The property is readable and writable, as well as has a getter and = a setter. + * + * For pointer property, this flag (set in object_{class_}property_add= _*_ptr()) + * will automatically add a getter and a setter to this property. + */ + OBJ_PROP_FLAG_READWRITE =3D (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE), +} ObjectPropertyFlags; + struct ObjectProperty { char *name; @@ -99,6 +123,7 @@ struct ObjectProperty ObjectPropertyInit *init; void *opaque; QObject *defval; + ObjectPropertyFlags flags; }; =20 /** @@ -1840,15 +1865,6 @@ ObjectProperty *object_class_property_add_tm(ObjectC= lass *klass, const char *name, void (*get)(Object *, struct tm *, Error **)); =20 -typedef enum { - /* Automatically add a getter to the property */ - OBJ_PROP_FLAG_READ =3D BIT(0), - /* Automatically add a setter to the property */ - OBJ_PROP_FLAG_WRITE =3D BIT(1), - /* Automatically add a getter and a setter to the property */ - OBJ_PROP_FLAG_READWRITE =3D (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE), -} ObjectPropertyFlags; - /** * object_property_add_uint8_ptr: * @obj: the object to add a property to diff --git a/qom/object.c b/qom/object.c index ff8ede8a328e..f5801f4624c8 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1233,6 +1233,19 @@ void object_unref(void *objptr) } } =20 +static inline void object_property_flags_init(ObjectProperty *prop) +{ + uint8_t flags =3D 0; + + if (prop->set) { + flags |=3D OBJ_PROP_FLAG_WRITE; + } + if (prop->get) { + flags |=3D OBJ_PROP_FLAG_READ; + } + prop->flags |=3D flags; +} + ObjectProperty * object_property_try_add(Object *obj, const char *name, const char *type, ObjectPropertyAccessor *get, @@ -1279,6 +1292,7 @@ object_property_try_add(Object *obj, const char *name= , const char *type, prop->set =3D set; prop->release =3D release; prop->opaque =3D opaque; + object_property_flags_init(prop); =20 g_hash_table_insert(obj->properties, prop->name, prop); return prop; @@ -1317,9 +1331,9 @@ object_class_property_add(ObjectClass *klass, prop->set =3D set; prop->release =3D release; prop->opaque =3D opaque; + object_property_flags_init(prop); =20 g_hash_table_insert(klass->properties, prop->name, prop); - return prop; } =20 --=20 2.34.1