On Tue, 10 Feb 2026, Zhao Liu wrote:
Introduce three new flags to `ObjectPropertyFlags` to better manage
property interactions with external users (CLI, QMP, HMP):

1. OBJ_PROP_FLAG_USER_SET:
  Marks a property as having been modified by an external user.

  This flag is designed to be "sticky": once set, it persists even if
  the property value is subsequently overwritten by internal logic.
  It allows the QEMU system to distinguish user intent.

  The advantage of this design is that it is not needed to manually
  clear the USER_SET flag on every internal write. This simplifies the
  logic and decouples flag management from the current property setting
  path (object_property_set()).

  This is chosen over a strict "current origin" approach (where
  internal writes would clear the flag) for a practical reason: QEMU
  code often modifies underlying struct fields (which are defined as
  properties) directly, bypassing the property API entirely. This makes
  it impossible to "accurately" track whether the *current* value truly
  comes from the user. Therefore, a sticky "user touched this" flag is
  the only meaningful and robust solution.

2. OBJ_PROP_FLAG_DEPRECATED:
  Marks a property as deprecated.

3. OBJ_PROP_FLAG_INTERNAL:
  Marks a property as internal-only, disallowing external user access.

Additionally, update object_property_set_flags() to implement the
enforcement logic. When a property is flagged with
OBJ_PROP_FLAG_USER_SET:
- If the property is also marked OBJ_PROP_FLAG_DEPRECATED, report a
  warning.
- If the property is also marked OBJ_PROP_FLAG_INTERNAL, raise an error
  and stop the operation.

Suggested-by: Igor Mammedov <[email protected]>
Signed-off-by: Zhao Liu <[email protected]>
---
include/qom/object.h | 24 ++++++++++++++++++++++++
qom/object.c         | 15 +++++++++++++++
2 files changed, 39 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index 856b12e7289c..1b77429aa28b 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -109,6 +109,30 @@ typedef enum {
     * will automatically add a getter and a setter to this property.
     */
    OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
+    /*
+     * The property was explicitly set by an external user.
+     *
+     * This flag is set whenever the property is modified via external 
interfaces
+     * (CLI, QMP, HMP). It allows internal code to distinguish whether the
+     * property has been modified by the user.
+     *
+     * Once set, this flag persists even if the property value is subsequently
+     * overwritten by internal logic. It is NOT automatically cleared and must
+     * be explicitly cleared using object_property_clear_flags().
+     */
+    OBJ_PROP_FLAG_USER_SET = BIT(2),

As this isn't strictly for user set maybe jusr call it OBJ_PROP_FLAG_EXTERNAL? (Can be set by external management application or global compat prop in later patches so user set is not quite right name,)

Reply via email to