All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/16] hw/acpi: convert object props to class props
@ 2026-08-21 11:14 Mark Cave-Ayland
  2026-08-21 11:14 ` [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro Mark Cave-Ayland
                   ` (15 more replies)
  0 siblings, 16 replies; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

[Background: based upon Peter's feedback at
 https://lists.gnu.org/archive/html/qemu-devel/2026-06/msg07717.html I realised
 that what we really need are object_class_property_add_*_ptr() equivalents to
 the existing object_property_add_*_ptr() functions to make it easier to
 convert existing properties.

 There are actually existing functions with these names that are already in use
 but after observation these are really static properties, so these are renamed
 to aid porting object props to class props, as well as making the difference
 clearer.]

[Note: this will have substantial conflicts with Marc-André's series "qom/qdev:
 associate properties with QAPI schema types" at
 https://patchew.org/QEMU/20260818-qom-qapi-v3-0-24b8bbbe3d86@redhat.com/.]

Since the use of object props is effectively deprecated, here is an attempt
to convert all use of object props in hw/acpi to class props. The eventual
aim is to continue working through the codebase, removing all remaining uses
of object props.

The series is lightly tested: it passes "make check", GitLab CI and some
simple local tests. I'm mostly interested for feedback on the conversion
strategy, and to get a feel for the best way to merge this series since once
the basic conversion patterns are in place, the same patterns can be applied
elsewhere and it would be good to minimise the merge window for such changes.

The following warnings below are generated by checkpatch but are incorrect
since they form part of macro definitions:

1/16 Checking commit 58e8d5fb5971 (qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro)
ERROR: spaces required around that '*' (ctx:WxB)
#41: FILE: qom/object.c:2720:
+        type##_t value = *(type##_t *)object_class_prop_ptr(obj, \
                                     ^

total: 1 errors, 0 warnings, 28 lines checked

Patch 1/16 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

2/15 Checking commit 2068ae0d4ded (qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro)
ERROR: spaces required around that '*' (ctx:WxV)
#28: FILE: qom/object.c:2730:
+        type##_t *field = (type##_t *)object_class_prop_ptr(obj, \
                  ^

ERROR: spaces required around that '*' (ctx:WxB)
#28: FILE: qom/object.c:2730:
+        type##_t *field = (type##_t *)object_class_prop_ptr(obj, \


Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>

(Patches still requiring review: 5, 6)


v4:
- Add R-B tags from Marc-André

- Fix comments mismatch within object_class_property_add_*_ptr() descriptions in
  object.h

- Add patch 5 implementing object_class_property_add_uint64_ptr() now required by
  patch 6

- Don't promote ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP to a Property in patch 6 since it
  must be marked as read-only: use object_class_property_add_uint64_ptr() instead


v3:
- Re-implement the object_class_property_add_*_ptr() get/set functions using
  new OBJECT_CLASS_PROPERTY_SCALAR_GETTER() and
  OBJECT_CLASS_PROPERTY_SCALAR_SETTER() macros, similar as has already been
  done for object properties

- Drop most R-B tags since nearly all patches have changed since v2

- Split conversion of static variables to static class properties into separate
  commits to act as a reference for future conversions

- Drop patch 6 from v2 since that has already been merged separately by Phil

- Use UINT32_MAX to indicate ACPI_PCIHP_PROP_BSEL has not been set in patch 13
  instead of -1. This is because the existing object_property_add_*_ptr()
  functions always use unsigned scalars: let's try and keep this the same for the
  object_class_property_add_*_ptr() functions if possible

- Add a new object_class_property_add_bool_ptr() function rather than using
  object_class_property_add_bool() in patch 10 since it avoids writing explicit
  helpers for each property, and there will likely be other cases in future

- Rebase onto master


v2:
- Add object_class_property_add_*_ptr() functions matching the existing
  object_property_add_*_ptr() functions for class functions

- Rework patch to use new functions instead of manually adding get/set
  functions as part of the conversion

- Ignore existing R-Bs since this approach is quite different to v1

- Rebase onto master


Mark Cave-Ayland (16):
  qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type)
    macro
  qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
    macro
  qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS()
    macro
  qom/object.c: add object_class_property_add_uint8_ptr()
  qom/object.c: add object_class_property_add_uint64_ptr()
  hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class
    props
  hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for
    ACPI_PM_PROP_GPE0_BLK prop
  qom/object.c: add object_class_property_add_uint32_ptr()
  hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class
    property
  qom/object.c: add object_class_property_add_bool_ptr()
  hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props
  qom/object.c: add object_class_property_add_uint16_ptr()
  hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and
    ACPI_PCIHP_IO_BASE_PROP to class props
  hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to
    class prop
  hw/acpi/piix4.c: convert static variables to static class properties
  hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop

 include/hw/acpi/ich9.h         |   2 +-
 include/hw/pci/pci_bus.h       |   2 +
 include/qom/object.h           |  90 +++++++++++++++++
 hw/acpi/generic_event_device.c |  10 ++
 hw/acpi/ich9.c                 | 126 +++++++++++-------------
 hw/acpi/pci-bridge.c           |   9 +-
 hw/acpi/pcihp.c                |  35 +++----
 hw/acpi/piix4.c                |  51 +++++++---
 hw/arm/virt-acpi-build.c       |   7 +-
 hw/i386/acpi-build.c           |   7 +-
 hw/isa/lpc_ich9.c              |  36 ++++---
 hw/pci/pci.c                   |   7 ++
 qom/object.c                   | 171 +++++++++++++++++++++++++++++++++
 13 files changed, 431 insertions(+), 122 deletions(-)

-- 
2.43.0



^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:43   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro Mark Cave-Ayland
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

This macro will be used to generate the boilerplate property_class_get_type_ptr()
QOM get function for the specified scalar type.

Note that since the macro is currently unused, the object_class_prop_ptr() helper
function is temporarily marked as __attribute__((unused)) to allow compilation to
succeed.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qom/object.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/qom/object.c b/qom/object.c
index 47977b1f44..e32ae30bd5 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2703,6 +2703,28 @@ DEFINE_OBJECT_PROPERTY_SCALAR_METHODS(uint64)
 #undef DEFINE_OBJECT_PROPERTY_SCALAR_METHODS
 
 
+__attribute__((unused))
+static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
+{
+    void *ptr = obj;
+    ptr += offset;
+
+    return ptr;
+}
+
+#define OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
+    static void property_class_get_##type##_ptr(Object *obj, Visitor *v, \
+                                                const char *name, \
+                                                void *opaque, Error **errp) \
+    { \
+        type##_t value = *(type##_t *)object_class_prop_ptr(obj, \
+                                                        (ptrdiff_t)opaque); \
+        visit_type_##type(v, name, &value, errp); \
+    }
+
+#undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
+
+
 ObjectProperty *
 object_property_add_uint8_ptr(Object *obj, const char *name,
                               const uint8_t *v,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
  2026-08-21 11:14 ` [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:44   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro Mark Cave-Ayland
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

This macro will be used to generate the boilerplate property_class_set_type_ptr()
QOM set function for the specified scalar type.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qom/object.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/qom/object.c b/qom/object.c
index e32ae30bd5..fe4e552928 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2722,7 +2722,24 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
         visit_type_##type(v, name, &value, errp); \
     }
 
+#define OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) \
+    static void property_class_set_##type##_ptr(Object *obj, Visitor *v, \
+                                                const char *name, \
+                                                void *opaque, Error **errp) \
+    { \
+        type##_t *field = (type##_t *)object_class_prop_ptr(obj, \
+                                                        (ptrdiff_t)opaque); \
+        type##_t value; \
+        \
+        if (!visit_type_##type(v, name, &value, errp)) { \
+            return; \
+        } \
+        \
+        *field = value; \
+    }
+
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
+#undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
 
 
 ObjectProperty *
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
  2026-08-21 11:14 ` [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro Mark Cave-Ayland
  2026-08-21 11:14 ` [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:44   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

This macro defines both the QOM get and set functions for the given scaler
type.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qom/object.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/qom/object.c b/qom/object.c
index fe4e552928..9cb2cae4a7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2738,8 +2738,13 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
         *field = value; \
     }
 
+#define DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(type) \
+    OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
+    OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
+
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
 #undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
+#undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
 
 
 ObjectProperty *
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr()
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (2 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:45   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

This adds a class property that references a uint8_t within the object instance
and is intended to be a replacement for object_property_add_uint8_ptr().

This commit also removes the __attribute__((unused)) annotation from
object_class_prop_ptr() which is no longer required now that the previous defined
DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() is now being used.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 23 ++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 11b1c9d2dc..eba675d218 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2033,6 +2033,24 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
                                               const uint8_t *v,
                                               ObjectPropertyFlags flags);
 
+/**
+ * object_class_property_add_uint8_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the uint8 value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an integer property in memory.  This function will add a
+ * property of type 'uint8'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
+                                         const char *name,
+                                         ptrdiff_t offset,
+                                         ObjectPropertyFlags flags);
+
 /**
  * object_class_static_property_add_uint8_ptr:
  * @klass: the object class to add a static property to
diff --git a/qom/object.c b/qom/object.c
index 9cb2cae4a7..a480fdd400 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2703,7 +2703,6 @@ DEFINE_OBJECT_PROPERTY_SCALAR_METHODS(uint64)
 #undef DEFINE_OBJECT_PROPERTY_SCALAR_METHODS
 
 
-__attribute__((unused))
 static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
 {
     void *ptr = obj;
@@ -2742,6 +2741,8 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
     OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
     OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
 
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
 #undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
 #undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
@@ -2767,6 +2768,26 @@ object_property_add_uint8_ptr(Object *obj, const char *name,
                                getter, setter, NULL, (void *)v);
 }
 
+ObjectProperty *
+object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
+                                    ptrdiff_t offset,
+                                    ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_uint8_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_uint8_ptr;
+    }
+
+    return object_class_property_add(klass, name, "uint8",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint8_ptr(ObjectClass *klass,
                                            const char *name,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr()
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (3 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:46   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

This adds a class property that references a uint8_t within the object instance
and is intended to be a replacement for object_property_add_uint64_ptr().

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index eba675d218..67ccd2b08f 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2168,6 +2168,24 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
                                     const uint64_t *v,
                                     ObjectPropertyFlags flags);
 
+/**
+ * object_class_property_add_uint64_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the uint64 value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an integer property in memory.  This function will add a
+ * property of type 'uint64'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
+                                         const char *name,
+                                         ptrdiff_t offset,
+                                         ObjectPropertyFlags flags);
+
 /**
  * object_class_static_property_add_uint64_ptr:
  * @klass: the object class to add a static property to
diff --git a/qom/object.c b/qom/object.c
index a480fdd400..271c2916b7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
     OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
 
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
 
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
 #undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
@@ -2911,6 +2912,26 @@ object_property_add_uint64_ptr(Object *obj, const char *name,
                                getter, setter, NULL, (void *)v);
 }
 
+ObjectProperty *
+object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
+                                     ptrdiff_t offset,
+                                     ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_uint64_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_uint64_ptr;
+    }
+
+    return object_class_property_add(klass, name, "uint64",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint64_ptr(ObjectClass *klass,
                                             const char *name,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (4 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:47   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

ACPI_PM_PROP_SCI_INT can be updated to use object_class_property_add_uint8_ptr()
with OBJ_PROP_FLAG_READ, whilst ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP can be updated
to use object_class_property_add_uint64_ptr().

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 hw/isa/lpc_ich9.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index edf9783ec8..07c9509cf4 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -683,24 +683,11 @@ static void ich9_lpc_initfn(Object *obj)
 {
     ICH9LPCState *lpc = ICH9_LPC_DEVICE(obj);
 
-    static const uint8_t acpi_enable_cmd = ICH9_APM_ACPI_ENABLE;
-    static const uint8_t acpi_disable_cmd = ICH9_APM_ACPI_DISABLE;
-
     object_initialize_child(obj, "rtc", &lpc->rtc, TYPE_MC146818_RTC);
 
     qdev_init_gpio_out_named(DEVICE(lpc), lpc->gsi, ICH9_GPIO_GSI,
                              IOAPIC_NUM_PINS);
 
-    object_property_add_uint8_ptr(obj, ACPI_PM_PROP_SCI_INT,
-                                  &lpc->sci_gsi, OBJ_PROP_FLAG_READ);
-    object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_ENABLE_CMD,
-                                  &acpi_enable_cmd, OBJ_PROP_FLAG_READ);
-    object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_DISABLE_CMD,
-                                  &acpi_disable_cmd, OBJ_PROP_FLAG_READ);
-    object_property_add_uint64_ptr(obj, ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP,
-                                   &lpc->smi_negotiated_features,
-                                   OBJ_PROP_FLAG_READ);
-
     ich9_pm_reset_properties(&lpc->pm);
     ich9_pm_add_properties(obj, &lpc->pm);
 }
@@ -888,6 +875,9 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
     AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(klass);
     AcpiDevAmlIfClass *amldevc = ACPI_DEV_AML_IF_CLASS(klass);
 
+    static const uint8_t acpi_enable_cmd = ICH9_APM_ACPI_ENABLE;
+    static const uint8_t acpi_disable_cmd = ICH9_APM_ACPI_DISABLE;
+
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     device_class_set_legacy_reset(dc, ich9_lpc_reset);
     k->realize = ich9_lpc_realize;
@@ -912,6 +902,23 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
     adevc->ospm_status = ich9_pm_ospm_status;
     adevc->send_event = ich9_send_gpe;
     amldevc->build_dev_aml = build_ich9_isa_aml;
+
+    object_class_property_add_uint8_ptr(klass, ACPI_PM_PROP_SCI_INT,
+                                        offsetof(ICH9LPCState, sci_gsi),
+                                        OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint64_ptr(klass,
+                                         ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP,
+                                         offsetof(ICH9LPCState,
+                                                  smi_negotiated_features),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint8_ptr(klass,
+                                               ACPI_PM_PROP_ACPI_ENABLE_CMD,
+                                               &acpi_enable_cmd,
+                                               OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint8_ptr(klass,
+                                               ACPI_PM_PROP_ACPI_DISABLE_CMD,
+                                               &acpi_disable_cmd,
+                                               OBJ_PROP_FLAG_READ);
 }
 
 static const TypeInfo ich9_lpc_info = {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (5 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:48   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

In order to convert to a class property, the ICH9LPCPMRegs instance must be
resolved by the getter/setter instead of being passed directly as an opaque.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/acpi/ich9.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 5e8f8a7eaf..ac3f452dc3 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -342,7 +342,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, qemu_irq sci_irq)
 static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
-    ICH9LPCPMRegs *pm = opaque;
+    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
+    ICH9LPCPMRegs *pm = &s->pm;
     uint32_t value = pm->pm_io_base + ICH9_PMIO_GPE0_STS;
 
     visit_type_uint32(v, name, &value, errp);
@@ -411,7 +412,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
                              OBJ_PROP_LINK_STRONG);
     object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, "uint32",
                         ich9_pm_get_gpe0_blk,
-                        NULL, NULL, pm);
+                        NULL, NULL, NULL);
     object_property_add_uint32_ptr(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
                                    &gpe0_len, OBJ_PROP_FLAG_READ);
     object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S3_DISABLED,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr()
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (6 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:48   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property Mark Cave-Ayland
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

This adds a class property that references a uint32_t within the object instance
and is intended to be a replacement for object_property_add_uint32_ptr().

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index 67ccd2b08f..8dead29284 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2129,6 +2129,24 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
                                     const uint32_t *v,
                                     ObjectPropertyFlags flags);
 
+/**
+ * object_class_property_add_uint32_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the uint32 value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an integer property in memory.  This function will add a
+ * property of type 'uint32'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
+                                    const char *name,
+                                    ptrdiff_t offset,
+                                    ObjectPropertyFlags flags);
+
 /**
  * object_class_static_property_add_uint32_ptr:
  * @klass: the object class to add a static property to
diff --git a/qom/object.c b/qom/object.c
index 271c2916b7..f91764aaa7 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
     OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
 
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint32)
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
 
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
@@ -2871,6 +2872,26 @@ object_property_add_uint32_ptr(Object *obj, const char *name,
                                getter, setter, NULL, (void *)v);
 }
 
+ObjectProperty *
+object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
+                                     ptrdiff_t offset,
+                                     ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_uint32_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_uint32_ptr;
+    }
+
+    return object_class_property_add(klass, name, "uint32",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint32_ptr(ObjectClass *klass,
                                             const char *name,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (7 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:50   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr() Mark Cave-Ayland
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

The ACPI_PM_PROP_GPE0_BLK_LEN property is assigned to a static variable and so
can be converted to a static class property. Introduce
ich9_pm_add_class_properties() to hold the ACPI_PM_PROP_GPE0_BLK_LEN property
and soon all other class props after they have been converted from object props.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/acpi/ich9.h |  1 +
 hw/acpi/ich9.c         | 14 ++++++++++----
 hw/isa/lpc_ich9.c      |  2 ++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 30990fcef5..3fb993bb9e 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -84,6 +84,7 @@ extern const VMStateDescription vmstate_ich9_pm;
 void ich9_pm_reset_properties(ICH9LPCPMRegs *pm);
 
 void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm);
+void ich9_pm_add_class_properties(ObjectClass *oc);
 
 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                                 Error **errp);
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index ac3f452dc3..774b34195f 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -402,8 +402,6 @@ void ich9_pm_reset_properties(ICH9LPCPMRegs *pm)
 
 void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
 {
-    static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
-
     object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE,
                                    &pm->pm_io_base, OBJ_PROP_FLAG_READ);
     object_property_add_link(obj, "bus", TYPE_PCI_BUS,
@@ -413,8 +411,6 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
     object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, "uint32",
                         ich9_pm_get_gpe0_blk,
                         NULL, NULL, NULL);
-    object_property_add_uint32_ptr(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
-                                   &gpe0_len, OBJ_PROP_FLAG_READ);
     object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S3_DISABLED,
                                   &pm->disable_s3, OBJ_PROP_FLAG_READWRITE);
     object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S4_DISABLED,
@@ -432,6 +428,16 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
                              ich9_pm_set_keep_pci_slot_hpc);
 }
 
+void ich9_pm_add_class_properties(ObjectClass *oc)
+{
+    static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
+
+    object_class_static_property_add_uint32_ptr(oc,
+                                                ACPI_PM_PROP_GPE0_BLK_LEN,
+                                                &gpe0_len,
+                                                OBJ_PROP_FLAG_READ);
+}
+
 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                                 Error **errp)
 {
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 07c9509cf4..d3f1358887 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -919,6 +919,8 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
                                                ACPI_PM_PROP_ACPI_DISABLE_CMD,
                                                &acpi_disable_cmd,
                                                OBJ_PROP_FLAG_READ);
+
+    ich9_pm_add_class_properties(klass);
 }
 
 static const TypeInfo ich9_lpc_info = {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr()
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (8 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:53   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

This adds a class property that references a bool within the object instance
and is intended to be used as a replacement for object_class_property_add_bool()
where possible.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index 8dead29284..de37016ba8 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2017,6 +2017,24 @@ typedef enum {
     OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
 } ObjectPropertyFlags;
 
+/**
+ * object_class_property_add_bool_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the bool value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an boolean property in memory.  This function will add a
+ * property of type 'bool'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_bool_ptr(ObjectClass *klass,
+                                         const char *name,
+                                         ptrdiff_t offset,
+                                         ObjectPropertyFlags flags);
+
 /**
  * object_property_add_uint8_ptr:
  * @obj: the object to add a property to
diff --git a/qom/object.c b/qom/object.c
index f91764aaa7..635eeeac77 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2750,6 +2750,49 @@ DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
 #undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
 
 
+static void property_class_get_bool_ptr(Object *obj, Visitor *v,
+                                        const char *name,
+                                        void *opaque, Error **errp)
+{
+    bool value = *(bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
+
+    visit_type_bool(v, name, &value, errp);
+}
+
+static void property_class_set_bool_ptr(Object *obj, Visitor *v,
+                                        const char *name,
+                                        void *opaque, Error **errp)
+{
+    bool *field = (bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
+    bool value;
+
+    if (!visit_type_bool(v, name, &value, errp)) {
+        return;
+    }
+
+    *field = value;
+}
+
+ObjectProperty *
+object_class_property_add_bool_ptr(ObjectClass *klass, const char *name,
+                                   ptrdiff_t offset,
+                                   ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_bool_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_bool_ptr;
+    }
+
+    return object_class_property_add(klass, name, "bool",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_property_add_uint8_ptr(Object *obj, const char *name,
                               const uint8_t *v,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (9 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr() Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 12:59   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

ACPI_PM_PROP_TCO_ENABLED, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE and x-keep-pci-slot-hpc
properties can be converted to use object_class_property_add_bool_ptr(). Remove
the now unused ich9_pm_add_properties() function.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/acpi/ich9.h |   3 +-
 hw/acpi/ich9.c         | 111 ++++++++++++++++-------------------------
 hw/isa/lpc_ich9.c      |   3 +-
 3 files changed, 44 insertions(+), 73 deletions(-)

diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 3fb993bb9e..6d14544751 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -83,8 +83,7 @@ extern const VMStateDescription vmstate_ich9_pm;
 
 void ich9_pm_reset_properties(ICH9LPCPMRegs *pm);
 
-void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm);
-void ich9_pm_add_class_properties(ObjectClass *oc);
+void ich9_pm_add_class_properties(ObjectClass *oc, ptrdiff_t pm_offset);
 
 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                                 Error **errp);
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 774b34195f..4aa8d36f54 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -349,46 +349,6 @@ static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v, const char *name,
     visit_type_uint32(v, name, &value, errp);
 }
 
-static bool ich9_pm_get_enable_tco(Object *obj, Error **errp)
-{
-    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
-    return s->pm.enable_tco;
-}
-
-static void ich9_pm_set_enable_tco(Object *obj, bool value, Error **errp)
-{
-    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
-    s->pm.enable_tco = value;
-}
-
-static bool ich9_pm_get_acpi_pci_hotplug(Object *obj, Error **errp)
-{
-    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
-
-    return s->pm.acpi_pci_hotplug.use_acpi_hotplug_bridge;
-}
-
-static void ich9_pm_set_acpi_pci_hotplug(Object *obj, bool value, Error **errp)
-{
-    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
-
-    s->pm.acpi_pci_hotplug.use_acpi_hotplug_bridge = value;
-}
-
-static bool ich9_pm_get_keep_pci_slot_hpc(Object *obj, Error **errp)
-{
-    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
-
-    return s->pm.keep_pci_slot_hpc;
-}
-
-static void ich9_pm_set_keep_pci_slot_hpc(Object *obj, bool value, Error **errp)
-{
-    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
-
-    s->pm.keep_pci_slot_hpc = value;
-}
-
 void ich9_pm_reset_properties(ICH9LPCPMRegs *pm)
 {
     pm->acpi_memory_hotplug.is_enabled = true;
@@ -400,35 +360,7 @@ void ich9_pm_reset_properties(ICH9LPCPMRegs *pm)
     pm->enable_tco = true;
 }
 
-void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
-{
-    object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE,
-                                   &pm->pm_io_base, OBJ_PROP_FLAG_READ);
-    object_property_add_link(obj, "bus", TYPE_PCI_BUS,
-                             (Object **)&pm->acpi_pci_hotplug.root,
-                             object_property_allow_set_link,
-                             OBJ_PROP_LINK_STRONG);
-    object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, "uint32",
-                        ich9_pm_get_gpe0_blk,
-                        NULL, NULL, NULL);
-    object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S3_DISABLED,
-                                  &pm->disable_s3, OBJ_PROP_FLAG_READWRITE);
-    object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S4_DISABLED,
-                                  &pm->disable_s4, OBJ_PROP_FLAG_READWRITE);
-    object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S4_VAL,
-                                  &pm->s4_val, OBJ_PROP_FLAG_READWRITE);
-    object_property_add_bool(obj, ACPI_PM_PROP_TCO_ENABLED,
-                             ich9_pm_get_enable_tco,
-                             ich9_pm_set_enable_tco);
-    object_property_add_bool(obj, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE,
-                             ich9_pm_get_acpi_pci_hotplug,
-                             ich9_pm_set_acpi_pci_hotplug);
-    object_property_add_bool(obj, "x-keep-pci-slot-hpc",
-                             ich9_pm_get_keep_pci_slot_hpc,
-                             ich9_pm_set_keep_pci_slot_hpc);
-}
-
-void ich9_pm_add_class_properties(ObjectClass *oc)
+void ich9_pm_add_class_properties(ObjectClass *oc, ptrdiff_t pm_offset)
 {
     static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
 
@@ -436,6 +368,47 @@ void ich9_pm_add_class_properties(ObjectClass *oc)
                                                 ACPI_PM_PROP_GPE0_BLK_LEN,
                                                 &gpe0_len,
                                                 OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint32_ptr(oc, ACPI_PM_PROP_PM_IO_BASE,
+                                         pm_offset +
+                                         offsetof(ICH9LPCPMRegs,
+                                                  pm_io_base),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_property_add_link(oc, "bus",
+                                   TYPE_PCI_BUS,
+                                   pm_offset +
+                                   offsetof(ICH9LPCPMRegs,
+                                            acpi_pci_hotplug.root),
+                                   object_property_allow_set_link,
+                                   OBJ_PROP_LINK_STRONG);
+    object_class_property_add(oc, ACPI_PM_PROP_GPE0_BLK, "uint32",
+                              ich9_pm_get_gpe0_blk,
+                              NULL, NULL, NULL);
+    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S3_DISABLED,
+                                        pm_offset +
+                                        offsetof(ICH9LPCPMRegs, disable_s3),
+                                        OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S4_DISABLED,
+                                        pm_offset +
+                                        offsetof(ICH9LPCPMRegs, disable_s4),
+                                        OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S4_VAL,
+                                        pm_offset +
+                                        offsetof(ICH9LPCPMRegs, s4_val),
+                                        OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_bool_ptr(oc, ACPI_PM_PROP_TCO_ENABLED,
+                                       pm_offset +
+                                       offsetof(ICH9LPCPMRegs, enable_tco),
+                                       OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_bool_ptr(oc, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE,
+                               pm_offset +
+                               offsetof(ICH9LPCPMRegs,
+                                   acpi_pci_hotplug.use_acpi_hotplug_bridge),
+                               OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_bool_ptr(oc, "x-keep-pci-slot-hpc",
+                                       pm_offset +
+                                       offsetof(ICH9LPCPMRegs,
+                                                keep_pci_slot_hpc),
+                                       OBJ_PROP_FLAG_READWRITE);
 }
 
 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index d3f1358887..b55b5136a3 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -689,7 +689,6 @@ static void ich9_lpc_initfn(Object *obj)
                              IOAPIC_NUM_PINS);
 
     ich9_pm_reset_properties(&lpc->pm);
-    ich9_pm_add_properties(obj, &lpc->pm);
 }
 
 static void ich9_lpc_realize(PCIDevice *d, Error **errp)
@@ -920,7 +919,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
                                                &acpi_disable_cmd,
                                                OBJ_PROP_FLAG_READ);
 
-    ich9_pm_add_class_properties(klass);
+    ich9_pm_add_class_properties(klass, offsetof(ICH9LPCState, pm));
 }
 
 static const TypeInfo ich9_lpc_info = {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr()
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (10 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 13:00   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props Mark Cave-Ayland
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

This adds a class property that references a uint16_t within the object instance
and is intended to be a replacement for object_property_add_uint16_ptr().

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index de37016ba8..e24f0a2b2d 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2108,6 +2108,24 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
                                     const uint16_t *v,
                                     ObjectPropertyFlags flags);
 
+/**
+ * object_class_property_add_uint16_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the uint16 value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an integer property in memory.  This function will add a
+ * property of type 'uint16'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
+                                         const char *name,
+                                         ptrdiff_t offset,
+                                         ObjectPropertyFlags flags);
+
 /**
  * object_class_static_property_add_uint16_ptr:
  * @klass: the object class to add a static property to
diff --git a/qom/object.c b/qom/object.c
index 635eeeac77..85bbd7f9fe 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
     OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
 
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint16)
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint32)
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
 
@@ -2874,6 +2875,26 @@ object_property_add_uint16_ptr(Object *obj, const char *name,
                                getter, setter, NULL, (void *)v);
 }
 
+ObjectProperty *
+object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
+                                     ptrdiff_t offset,
+                                     ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_uint16_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_uint16_ptr;
+    }
+
+    return object_class_property_add(klass, name, "uint16",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint16_ptr(ObjectClass *klass,
                                             const char *name,
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (11 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 13:01   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

Since the objects referenced by acpi_pcihp_init() do not inherit from a common
class, add ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP class properties
to each referenced object and remove the object properties manually added in
acpi_pcihp_init().

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/acpi/generic_event_device.c | 10 ++++++++++
 hw/acpi/ich9.c                 | 10 ++++++++++
 hw/acpi/pcihp.c                |  5 -----
 hw/acpi/piix4.c                |  9 +++++++++
 4 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
index 9e9416d406..67c9e9b3e8 100644
--- a/hw/acpi/generic_event_device.c
+++ b/hw/acpi/generic_event_device.c
@@ -11,6 +11,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qapi/visitor.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/pcihp.h"
 #include "hw/acpi/cpu.h"
@@ -608,6 +609,15 @@ static void acpi_ged_class_init(ObjectClass *class, const void *data)
 
     adevc->ospm_status = acpi_ged_ospm_status;
     adevc->send_event = acpi_ged_send_event;
+
+    object_class_property_add_uint16_ptr(class, ACPI_PCIHP_IO_BASE_PROP,
+                                         offsetof(AcpiGedState,
+                                                  pcihp_state.io_base),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint16_ptr(class, ACPI_PCIHP_IO_LEN_PROP,
+                                         offsetof(AcpiGedState,
+                                                  pcihp_state.io_len),
+                                         OBJ_PROP_FLAG_READ);
 }
 
 static const TypeInfo acpi_ged_info = {
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 4aa8d36f54..e3d526ce57 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -409,6 +409,16 @@ void ich9_pm_add_class_properties(ObjectClass *oc, ptrdiff_t pm_offset)
                                        offsetof(ICH9LPCPMRegs,
                                                 keep_pci_slot_hpc),
                                        OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_uint16_ptr(oc, ACPI_PCIHP_IO_BASE_PROP,
+                               pm_offset +
+                               offsetof(ICH9LPCPMRegs,
+                                   acpi_pci_hotplug.io_base),
+                               OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint16_ptr(oc, ACPI_PCIHP_IO_LEN_PROP,
+                               pm_offset +
+                               offsetof(ICH9LPCPMRegs,
+                                   acpi_pci_hotplug.io_len),
+                               OBJ_PROP_FLAG_READ);
 }
 
 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 87162ff2c0..a91f523c93 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -502,11 +502,6 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s,
     memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s,
                           "acpi-pci-hotplug", s->io_len);
     memory_region_add_subregion(io, s->io_base, &s->io);
-
-    object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_BASE_PROP, &s->io_base,
-                                   OBJ_PROP_FLAG_READ);
-    object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_LEN_PROP, &s->io_len,
-                                   OBJ_PROP_FLAG_READ);
 }
 
 void build_append_pci_dsm_func0_common(Aml *ctx, Aml *retvar)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 9b7f50c7af..1d209ac96d 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -607,6 +607,15 @@ static void piix4_pm_class_init(ObjectClass *klass, const void *data)
     hc->is_hotpluggable_bus = piix4_is_hotpluggable_bus;
     adevc->ospm_status = piix4_ospm_status;
     adevc->send_event = piix4_send_gpe;
+
+    object_class_property_add_uint16_ptr(klass, ACPI_PCIHP_IO_BASE_PROP,
+                                         offsetof(PIIX4PMState,
+                                                  acpi_pci_hotplug.io_base),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint16_ptr(klass, ACPI_PCIHP_IO_LEN_PROP,
+                                         offsetof(PIIX4PMState,
+                                                  acpi_pci_hotplug.io_len),
+                                         OBJ_PROP_FLAG_READ);
 }
 
 static const TypeInfo piix4_pm_info = {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (12 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 13:04   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties Mark Cave-Ayland
  2026-08-21 11:14 ` [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop Mark Cave-Ayland
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

Move the ACPI_PCIHP_PROP_BSEL property to the PCIBus object and update all
callers accordingly.

Since the existing logic checks for the existence of the ACPI_PCIHP_PROP_BSEL
property to enable the relevant ACPI changes, set the type of the underlying
variable to uint32_t with a default value of UINT32_MAX indicating that the
property has not been set.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/pci/pci_bus.h |  2 ++
 hw/acpi/pci-bridge.c     |  9 ++++++++-
 hw/acpi/pcihp.c          | 30 ++++++++++++++----------------
 hw/arm/virt-acpi-build.c |  7 ++++++-
 hw/i386/acpi-build.c     |  7 ++++++-
 hw/pci/pci.c             |  7 +++++++
 6 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index c738446788..7ecb23d13c 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -56,6 +56,8 @@ struct PCIBus {
     int *irq_count;
 
     Notifier machine_done;
+
+    uint32_t acpi_pcihp_bsel_val;
 };
 
 static inline bool pci_bus_is_cxl(PCIBus *bus)
diff --git a/hw/acpi/pci-bridge.c b/hw/acpi/pci-bridge.c
index 394a919479..1bfc5431f2 100644
--- a/hw/acpi/pci-bridge.c
+++ b/hw/acpi/pci-bridge.c
@@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
 
     if (!DEVICE(br)->hotplugged) {
         PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
+        Error *local_err = NULL;
+        uint32_t bsel;
 
         build_append_pci_bus_devices(scope, sec_bus);
 
@@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
          * generate hotplug slots descriptors if
          * bridge has ACPI PCI hotplug attached,
          */
-        if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
+        bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
+                                        &local_err);
+
+        if (local_err == NULL && bsel != UINT32_MAX) {
             build_append_pcihp_slots(scope, sec_bus);
         }
+
+        error_free(local_err);
     }
 }
 
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index a91f523c93..b26ddf0a26 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -58,7 +58,7 @@ typedef struct AcpiPciHpFind {
 static int acpi_pcihp_get_bsel(PCIBus *bus)
 {
     Error *local_err = NULL;
-    uint64_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+    uint32_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
                                              &local_err);
 
     if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
@@ -78,18 +78,14 @@ typedef struct {
 static void *acpi_set_bsel(PCIBus *bus, void *opaque)
 {
     BSELInfo *info = opaque;
-    unsigned *bus_bsel;
     DeviceState *br = bus->qbus.parent;
     bool is_bridge = IS_PCI_BRIDGE(br);
 
     /* hotplugged bridges can't be described in ACPI ignore them */
     if (qbus_is_hotpluggable(BUS(bus))) {
         if (!is_bridge || (!br->hotplugged && info->has_bridge_hotplug)) {
-            bus_bsel = g_malloc(sizeof *bus_bsel);
-
-            *bus_bsel = info->bsel_alloc++;
-            object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
-                                           bus_bsel, OBJ_PROP_FLAG_READ);
+            object_property_set_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+                                     info->bsel_alloc++, NULL);
         }
     }
 
@@ -730,14 +726,16 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)
     /* If bus supports hotplug select it and notify about local events */
     bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
     if (bsel) {
-        uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
-
-        aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
-        aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
-                                     aml_int(1))); /* Device Check */
-        aml_append(method, aml_call2("DVNT", aml_name("PCID"),
-                                     aml_int(3))); /* Eject Request */
-        nr_notifiers++;
+        uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
+
+        if (bsel_val != UINT32_MAX) {
+            aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
+            aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
+                                         aml_int(1))); /* Device Check */
+            aml_append(method, aml_call2("DVNT", aml_name("PCID"),
+                                         aml_int(3))); /* Eject Request */
+            nr_notifiers++;
+        }
     }
 
     /* Notify about child bus events in any case */
@@ -848,7 +846,7 @@ void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus)
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel = object_property_get_qobject(OBJECT(bus),
                         ACPI_PCIHP_PROP_BSEL, NULL);
-    uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
+    uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
     qobject_unref(bsel);
 
     aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index f6386088b6..7ba7b38773 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -1207,6 +1207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = vms->oem_id,
                         .oem_table_id = vms->oem_table_id };
     Aml *pci0_scope;
+    Error *local_err = NULL;
+    uint32_t bsel;
 
     acpi_table_begin(&table, table_data);
     dsdt = init_aml_allocator();
@@ -1269,9 +1271,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 
     aml_append(pci0_scope, build_pci_bridge_edsm());
     build_append_pci_bus_devices(pci0_scope, vms->bus);
-    if (object_property_find(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL)) {
+    bsel = object_property_get_uint(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL,
+                                    &local_err);
+    if (local_err == NULL && bsel != UINT32_MAX) {
         build_append_pcihp_slots(pci0_scope, vms->bus);
     }
+    error_free(local_err);
 
     if (vms->acpi_dev) {
         bool acpi_pcihp;
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 8837b69687..cc0b6e5633 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1198,15 +1198,20 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     sb_scope = aml_scope("\\_SB");
     {
         Object *pci_host = acpi_get_i386_pci_host();
+        Error *local_err = NULL;
+        uint32_t bsel;
 
         if (pci_host) {
             PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
             Aml *ascope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
             build_append_pci_bus_devices(ascope, pbus);
-            if (object_property_find(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL)) {
+            bsel = object_property_get_uint(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL,
+                                            &local_err);
+            if (local_err == NULL && bsel != UINT32_MAX) {
                 build_append_pcihp_slots(ascope, pbus);
             }
+            error_free(local_err);
             aml_append(sb_scope, ascope);
         }
     }
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index d3191609e2..e8e8a3b767 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include "qemu/datadir.h"
 #include "qemu/units.h"
+#include "hw/acpi/pcihp.h"
 #include "hw/core/irq.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bridge.h"
@@ -187,6 +188,8 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
     bus->machine_done.notify = pcibus_machine_done;
     qemu_add_machine_init_done_notifier(&bus->machine_done);
 
+    bus->acpi_pcihp_bsel_val = UINT32_MAX;
+
     vmstate_register_any(NULL, &vmstate_pcibus, bus);
 }
 
@@ -302,6 +305,10 @@ static void pci_bus_class_init(ObjectClass *klass, const void *data)
     pbc->numa_node = pcibus_numa_node;
 
     fwgc->get_data = pci_bus_fw_cfg_gen_data;
+
+    object_class_property_add_uint32_ptr(klass, ACPI_PCIHP_PROP_BSEL,
+                                         offsetof(PCIBus, acpi_pcihp_bsel_val),
+                                         OBJ_PROP_FLAG_READWRITE);
 }
 
 static const TypeInfo pci_bus_info = {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (13 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 13:05   ` Daniel P. Berrangé
  2026-08-21 11:14 ` [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop Mark Cave-Ayland
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

The majority of the properties in piix4_pm_add_properties() are assigned to
static variables and so can be converted to static class properties. Introduce
piix4_pm_add_class_properties() to hold the static properties and soon all
other class props after they have been converted from object props.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/acpi/piix4.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 1d209ac96d..6462ba970c 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -406,6 +406,12 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque)
 }
 
 static void piix4_pm_add_properties(PIIX4PMState *s)
+{
+    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE,
+                                   &s->io_base, OBJ_PROP_FLAG_READ);
+}
+
+static void piix4_pm_add_class_properties(ObjectClass *oc)
 {
     static const uint8_t acpi_enable_cmd = ACPI_ENABLE;
     static const uint8_t acpi_disable_cmd = ACPI_DISABLE;
@@ -413,18 +419,26 @@ static void piix4_pm_add_properties(PIIX4PMState *s)
     static const uint32_t gpe0_blk_len = GPE_LEN;
     static const uint16_t sci_int = 9;
 
-    object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_ENABLE_CMD,
-                                  &acpi_enable_cmd, OBJ_PROP_FLAG_READ);
-    object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_DISABLE_CMD,
-                                  &acpi_disable_cmd, OBJ_PROP_FLAG_READ);
-    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK,
-                                  &gpe0_blk, OBJ_PROP_FLAG_READ);
-    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK_LEN,
-                                  &gpe0_blk_len, OBJ_PROP_FLAG_READ);
-    object_property_add_uint16_ptr(OBJECT(s), ACPI_PM_PROP_SCI_INT,
-                                  &sci_int, OBJ_PROP_FLAG_READ);
-    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE,
-                                  &s->io_base, OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint8_ptr(oc,
+                                               ACPI_PM_PROP_ACPI_ENABLE_CMD,
+                                               &acpi_enable_cmd,
+                                               OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint8_ptr(oc,
+                                               ACPI_PM_PROP_ACPI_DISABLE_CMD,
+                                               &acpi_disable_cmd,
+                                               OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint32_ptr(oc,
+                                                ACPI_PM_PROP_GPE0_BLK,
+                                                &gpe0_blk,
+                                                OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint32_ptr(oc,
+                                                ACPI_PM_PROP_GPE0_BLK_LEN,
+                                                &gpe0_blk_len,
+                                                OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint16_ptr(oc,
+                                                ACPI_PM_PROP_SCI_INT,
+                                                &sci_int,
+                                                OBJ_PROP_FLAG_READ);
 }
 
 static void piix4_pm_realize(PCIDevice *dev, Error **errp)
@@ -616,6 +630,8 @@ static void piix4_pm_class_init(ObjectClass *klass, const void *data)
                                          offsetof(PIIX4PMState,
                                                   acpi_pci_hotplug.io_len),
                                          OBJ_PROP_FLAG_READ);
+
+    piix4_pm_add_class_properties(klass);
 }
 
 static const TypeInfo piix4_pm_info = {
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop
  2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (14 preceding siblings ...)
  2026-08-21 11:14 ` [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties Mark Cave-Ayland
@ 2026-08-21 11:14 ` Mark Cave-Ayland
  2026-08-24 13:06   ` Daniel P. Berrangé
  15 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-21 11:14 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, berrange, marcandre.lureau, qemu-devel,
	qemu-arm

ACPI_PM_PROP_PM_IO_BASE can be converted to use object_class_property_add_uint32_ptr().
Remove the now unused piix4_pm_add_properties() function.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/acpi/piix4.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 6462ba970c..52bd61667f 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -405,12 +405,6 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque)
         (memory_region_present(io_as, 0x2f8) ? 0x90 : 0);
 }
 
-static void piix4_pm_add_properties(PIIX4PMState *s)
-{
-    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE,
-                                   &s->io_base, OBJ_PROP_FLAG_READ);
-}
-
 static void piix4_pm_add_class_properties(ObjectClass *oc)
 {
     static const uint8_t acpi_enable_cmd = ACPI_ENABLE;
@@ -439,6 +433,10 @@ static void piix4_pm_add_class_properties(ObjectClass *oc)
                                                 ACPI_PM_PROP_SCI_INT,
                                                 &sci_int,
                                                 OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint32_ptr(oc,
+                                         ACPI_PM_PROP_PM_IO_BASE,
+                                         offsetof(PIIX4PMState, io_base),
+                                         OBJ_PROP_FLAG_READ);
 }
 
 static void piix4_pm_realize(PCIDevice *dev, Error **errp)
@@ -494,8 +492,6 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
 
     piix4_acpi_system_hot_add_init(pci_address_space_io(dev),
                                    pci_get_bus(dev), s);
-
-    piix4_pm_add_properties(s);
 }
 
 static void piix4_pm_init(Object *obj)
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro
  2026-08-21 11:14 ` [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro Mark Cave-Ayland
@ 2026-08-24 12:43   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:43 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:13PM +0100, Mark Cave-Ayland wrote:
> This macro will be used to generate the boilerplate property_class_get_type_ptr()
> QOM get function for the specified scalar type.
> 
> Note that since the macro is currently unused, the object_class_prop_ptr() helper
> function is temporarily marked as __attribute__((unused)) to allow compilation to
> succeed.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qom/object.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro
  2026-08-21 11:14 ` [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro Mark Cave-Ayland
@ 2026-08-24 12:44   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:44 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:14PM +0100, Mark Cave-Ayland wrote:
> This macro will be used to generate the boilerplate property_class_set_type_ptr()
> QOM set function for the specified scalar type.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qom/object.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro
  2026-08-21 11:14 ` [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro Mark Cave-Ayland
@ 2026-08-24 12:44   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:44 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:15PM +0100, Mark Cave-Ayland wrote:
> This macro defines both the QOM get and set functions for the given scaler
> type.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qom/object.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr()
  2026-08-21 11:14 ` [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
@ 2026-08-24 12:45   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:45 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:16PM +0100, Mark Cave-Ayland wrote:
> This adds a class property that references a uint8_t within the object instance
> and is intended to be a replacement for object_property_add_uint8_ptr().
> 
> This commit also removes the __attribute__((unused)) annotation from
> object_class_prop_ptr() which is no longer required now that the previous defined
> DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() is now being used.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/qom/object.h | 18 ++++++++++++++++++
>  qom/object.c         | 23 ++++++++++++++++++++++-
>  2 files changed, 40 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr()
  2026-08-21 11:14 ` [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
@ 2026-08-24 12:46   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:46 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:17PM +0100, Mark Cave-Ayland wrote:
> This adds a class property that references a uint8_t within the object instance
> and is intended to be a replacement for object_property_add_uint64_ptr().
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
>  include/qom/object.h | 18 ++++++++++++++++++
>  qom/object.c         | 21 +++++++++++++++++++++
>  2 files changed, 39 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props
  2026-08-21 11:14 ` [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
@ 2026-08-24 12:47   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:47 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:18PM +0100, Mark Cave-Ayland wrote:
> ACPI_PM_PROP_SCI_INT can be updated to use object_class_property_add_uint8_ptr()
> with OBJ_PROP_FLAG_READ, whilst ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP can be updated
> to use object_class_property_add_uint64_ptr().
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
>  hw/isa/lpc_ich9.c | 33 ++++++++++++++++++++-------------
>  1 file changed, 20 insertions(+), 13 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop
  2026-08-21 11:14 ` [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
@ 2026-08-24 12:48   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:48 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:19PM +0100, Mark Cave-Ayland wrote:
> In order to convert to a class property, the ICH9LPCPMRegs instance must be
> resolved by the getter/setter instead of being passed directly as an opaque.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/acpi/ich9.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr()
  2026-08-21 11:14 ` [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
@ 2026-08-24 12:48   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:48 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:20PM +0100, Mark Cave-Ayland wrote:
> This adds a class property that references a uint32_t within the object instance
> and is intended to be a replacement for object_property_add_uint32_ptr().
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/qom/object.h | 18 ++++++++++++++++++
>  qom/object.c         | 21 +++++++++++++++++++++
>  2 files changed, 39 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property
  2026-08-21 11:14 ` [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property Mark Cave-Ayland
@ 2026-08-24 12:50   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:50 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:21PM +0100, Mark Cave-Ayland wrote:
> The ACPI_PM_PROP_GPE0_BLK_LEN property is assigned to a static variable and so
> can be converted to a static class property. Introduce
> ich9_pm_add_class_properties() to hold the ACPI_PM_PROP_GPE0_BLK_LEN property
> and soon all other class props after they have been converted from object props.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/acpi/ich9.h |  1 +
>  hw/acpi/ich9.c         | 14 ++++++++++----
>  hw/isa/lpc_ich9.c      |  2 ++
>  3 files changed, 13 insertions(+), 4 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr()
  2026-08-21 11:14 ` [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr() Mark Cave-Ayland
@ 2026-08-24 12:53   ` Daniel P. Berrangé
  2026-08-24 13:39     ` Mark Cave-Ayland
  0 siblings, 1 reply; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:53 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:22PM +0100, Mark Cave-Ayland wrote:
> This adds a class property that references a bool within the object instance
> and is intended to be used as a replacement for object_class_property_add_bool()
> where possible.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/qom/object.h | 18 ++++++++++++++++++
>  qom/object.c         | 43 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 61 insertions(+)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 8dead29284..de37016ba8 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -2017,6 +2017,24 @@ typedef enum {
>      OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
>  } ObjectPropertyFlags;
>  
> +/**
> + * object_class_property_add_bool_ptr:
> + * @klass: the object class to add a property to
> + * @name: the name of the property
> + * @offset: the offset from the object instance where the bool value is
> + *   stored
> + * @flags: bitwise-or'd ObjectPropertyFlags
> + *
> + * Add an boolean property in memory.  This function will add a
> + * property of type 'bool'.
> + *
> + * Returns: The newly added property on success, or %NULL on failure.
> + */
> +ObjectProperty *object_class_property_add_bool_ptr(ObjectClass *klass,
> +                                         const char *name,
> +                                         ptrdiff_t offset,
> +                                         ObjectPropertyFlags flags);
> +
>  /**
>   * object_property_add_uint8_ptr:
>   * @obj: the object to add a property to
> diff --git a/qom/object.c b/qom/object.c
> index f91764aaa7..635eeeac77 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -2750,6 +2750,49 @@ DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
>  #undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
>  
>  
> +static void property_class_get_bool_ptr(Object *obj, Visitor *v,
> +                                        const char *name,
> +                                        void *opaque, Error **errp)
> +{
> +    bool value = *(bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
> +
> +    visit_type_bool(v, name, &value, errp);
> +}
> +
> +static void property_class_set_bool_ptr(Object *obj, Visitor *v,
> +                                        const char *name,
> +                                        void *opaque, Error **errp)
> +{
> +    bool *field = (bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
> +    bool value;
> +
> +    if (!visit_type_bool(v, name, &value, errp)) {
> +        return;
> +    }
> +
> +    *field = value;
> +}

Am I missing the reason why we can't use

  DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(bool)

?  If so, could that be mentioned in the commit message.

> +
> +ObjectProperty *
> +object_class_property_add_bool_ptr(ObjectClass *klass, const char *name,
> +                                   ptrdiff_t offset,
> +                                   ObjectPropertyFlags flags)
> +{
> +    ObjectPropertyAccessor *getter = NULL;
> +    ObjectPropertyAccessor *setter = NULL;
> +
> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
> +        getter = property_class_get_bool_ptr;
> +    }
> +
> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
> +        setter = property_class_set_bool_ptr;
> +    }
> +
> +    return object_class_property_add(klass, name, "bool",
> +                                     getter, setter, NULL, (void *)offset);
> +}
> +
>  ObjectProperty *
>  object_property_add_uint8_ptr(Object *obj, const char *name,
>                                const uint8_t *v,
> -- 
> 2.43.0
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props
  2026-08-21 11:14 ` [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
@ 2026-08-24 12:59   ` Daniel P. Berrangé
  2026-08-24 13:41     ` Mark Cave-Ayland
  0 siblings, 1 reply; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 12:59 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:23PM +0100, Mark Cave-Ayland wrote:
> ACPI_PM_PROP_TCO_ENABLED, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE and x-keep-pci-slot-hpc
> properties can be converted to use object_class_property_add_bool_ptr(). Remove
> the now unused ich9_pm_add_properties() function.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/acpi/ich9.h |   3 +-
>  hw/acpi/ich9.c         | 111 ++++++++++++++++-------------------------
>  hw/isa/lpc_ich9.c      |   3 +-
>  3 files changed, 44 insertions(+), 73 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

but...


> @@ -436,6 +368,47 @@ void ich9_pm_add_class_properties(ObjectClass *oc)
>                                                  ACPI_PM_PROP_GPE0_BLK_LEN,
>                                                  &gpe0_len,
>                                                  OBJ_PROP_FLAG_READ);
...it'd read nicer with

  #define REG_FIELD(n) \
    (pm_offset + offsetof(ICH9LPCPMRegs, n))

> +    object_class_property_add_uint32_ptr(oc, ACPI_PM_PROP_PM_IO_BASE,
> +                                         pm_offset +
> +                                         offsetof(ICH9LPCPMRegs,
> +                                                  pm_io_base),
> +                                         OBJ_PROP_FLAG_READ);


....

    object_class_property_add_uint32_ptr(oc, ACPI_PM_PROP_PM_IO_BASE,
                                         REG_FIELD(pm_io_base),
                                         OBJ_PROP_FLAG_READ);

...

> +    object_class_property_add_link(oc, "bus",
> +                                   TYPE_PCI_BUS,
> +                                   pm_offset +
> +                                   offsetof(ICH9LPCPMRegs,
> +                                            acpi_pci_hotplug.root),
> +                                   object_property_allow_set_link,
> +                                   OBJ_PROP_LINK_STRONG);
> +    object_class_property_add(oc, ACPI_PM_PROP_GPE0_BLK, "uint32",
> +                              ich9_pm_get_gpe0_blk,
> +                              NULL, NULL, NULL);
> +    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S3_DISABLED,
> +                                        pm_offset +
> +                                        offsetof(ICH9LPCPMRegs, disable_s3),
> +                                        OBJ_PROP_FLAG_READWRITE);
> +    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S4_DISABLED,
> +                                        pm_offset +
> +                                        offsetof(ICH9LPCPMRegs, disable_s4),
> +                                        OBJ_PROP_FLAG_READWRITE);
> +    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S4_VAL,
> +                                        pm_offset +
> +                                        offsetof(ICH9LPCPMRegs, s4_val),
> +                                        OBJ_PROP_FLAG_READWRITE);
> +    object_class_property_add_bool_ptr(oc, ACPI_PM_PROP_TCO_ENABLED,
> +                                       pm_offset +
> +                                       offsetof(ICH9LPCPMRegs, enable_tco),
> +                                       OBJ_PROP_FLAG_READWRITE);
> +    object_class_property_add_bool_ptr(oc, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE,
> +                               pm_offset +
> +                               offsetof(ICH9LPCPMRegs,
> +                                   acpi_pci_hotplug.use_acpi_hotplug_bridge),
> +                               OBJ_PROP_FLAG_READWRITE);
> +    object_class_property_add_bool_ptr(oc, "x-keep-pci-slot-hpc",
> +                                       pm_offset +
> +                                       offsetof(ICH9LPCPMRegs,
> +                                                keep_pci_slot_hpc),
> +                                       OBJ_PROP_FLAG_READWRITE);

...

  #undef REG_FIELD

>  }
>  
>  void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
> diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
> index d3f1358887..b55b5136a3 100644
> --- a/hw/isa/lpc_ich9.c
> +++ b/hw/isa/lpc_ich9.c
> @@ -689,7 +689,6 @@ static void ich9_lpc_initfn(Object *obj)
>                               IOAPIC_NUM_PINS);
>  
>      ich9_pm_reset_properties(&lpc->pm);
> -    ich9_pm_add_properties(obj, &lpc->pm);
>  }
>  
>  static void ich9_lpc_realize(PCIDevice *d, Error **errp)
> @@ -920,7 +919,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
>                                                 &acpi_disable_cmd,
>                                                 OBJ_PROP_FLAG_READ);
>  
> -    ich9_pm_add_class_properties(klass);
> +    ich9_pm_add_class_properties(klass, offsetof(ICH9LPCState, pm));
>  }
>  
>  static const TypeInfo ich9_lpc_info = {
> -- 
> 2.43.0
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr()
  2026-08-21 11:14 ` [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
@ 2026-08-24 13:00   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 13:00 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:24PM +0100, Mark Cave-Ayland wrote:
> This adds a class property that references a uint16_t within the object instance
> and is intended to be a replacement for object_property_add_uint16_ptr().
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/qom/object.h | 18 ++++++++++++++++++
>  qom/object.c         | 21 +++++++++++++++++++++
>  2 files changed, 39 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props
  2026-08-21 11:14 ` [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props Mark Cave-Ayland
@ 2026-08-24 13:01   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 13:01 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:25PM +0100, Mark Cave-Ayland wrote:
> Since the objects referenced by acpi_pcihp_init() do not inherit from a common
> class, add ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP class properties
> to each referenced object and remove the object properties manually added in
> acpi_pcihp_init().
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/acpi/generic_event_device.c | 10 ++++++++++
>  hw/acpi/ich9.c                 | 10 ++++++++++
>  hw/acpi/pcihp.c                |  5 -----
>  hw/acpi/piix4.c                |  9 +++++++++
>  4 files changed, 29 insertions(+), 5 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
  2026-08-21 11:14 ` [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
@ 2026-08-24 13:04   ` Daniel P. Berrangé
  2026-08-24 13:47     ` Mark Cave-Ayland
  0 siblings, 1 reply; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 13:04 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:26PM +0100, Mark Cave-Ayland wrote:
> Move the ACPI_PCIHP_PROP_BSEL property to the PCIBus object and update all
> callers accordingly.
> 
> Since the existing logic checks for the existence of the ACPI_PCIHP_PROP_BSEL
> property to enable the relevant ACPI changes, set the type of the underlying
> variable to uint32_t with a default value of UINT32_MAX indicating that the
> property has not been set.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/pci/pci_bus.h |  2 ++
>  hw/acpi/pci-bridge.c     |  9 ++++++++-
>  hw/acpi/pcihp.c          | 30 ++++++++++++++----------------
>  hw/arm/virt-acpi-build.c |  7 ++++++-
>  hw/i386/acpi-build.c     |  7 ++++++-
>  hw/pci/pci.c             |  7 +++++++
>  6 files changed, 43 insertions(+), 19 deletions(-)
> 
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index c738446788..7ecb23d13c 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -56,6 +56,8 @@ struct PCIBus {
>      int *irq_count;
>  
>      Notifier machine_done;
> +
> +    uint32_t acpi_pcihp_bsel_val;
>  };
>  
>  static inline bool pci_bus_is_cxl(PCIBus *bus)
> diff --git a/hw/acpi/pci-bridge.c b/hw/acpi/pci-bridge.c
> index 394a919479..1bfc5431f2 100644
> --- a/hw/acpi/pci-bridge.c
> +++ b/hw/acpi/pci-bridge.c
> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>  
>      if (!DEVICE(br)->hotplugged) {
>          PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
> +        Error *local_err = NULL;
> +        uint32_t bsel;
>  
>          build_append_pci_bus_devices(scope, sec_bus);
>  
> @@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>           * generate hotplug slots descriptors if
>           * bridge has ACPI PCI hotplug attached,
>           */
> -        if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
> +        bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
> +                                        &local_err);
> +
> +        if (local_err == NULL && bsel != UINT32_MAX) {
>              build_append_pcihp_slots(scope, sec_bus);
>          }
> +
> +        error_free(local_err);

IIUC, in this new approach the property should always exist and so I'd
expect object_property_get_uint to always succeed.

IOW, is something stopping us using &error_abort and merely checking

  if (bsel != UINT32_MAX) 

?

>      }
>  }
>  
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index a91f523c93..b26ddf0a26 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -58,7 +58,7 @@ typedef struct AcpiPciHpFind {
>  static int acpi_pcihp_get_bsel(PCIBus *bus)
>  {
>      Error *local_err = NULL;
> -    uint64_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> +    uint32_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
>                                               &local_err);
>  
>      if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
> @@ -78,18 +78,14 @@ typedef struct {
>  static void *acpi_set_bsel(PCIBus *bus, void *opaque)
>  {
>      BSELInfo *info = opaque;
> -    unsigned *bus_bsel;
>      DeviceState *br = bus->qbus.parent;
>      bool is_bridge = IS_PCI_BRIDGE(br);
>  
>      /* hotplugged bridges can't be described in ACPI ignore them */
>      if (qbus_is_hotpluggable(BUS(bus))) {
>          if (!is_bridge || (!br->hotplugged && info->has_bridge_hotplug)) {
> -            bus_bsel = g_malloc(sizeof *bus_bsel);
> -
> -            *bus_bsel = info->bsel_alloc++;
> -            object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> -                                           bus_bsel, OBJ_PROP_FLAG_READ);
> +            object_property_set_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> +                                     info->bsel_alloc++, NULL);
>          }
>      }
>  
> @@ -730,14 +726,16 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)
>      /* If bus supports hotplug select it and notify about local events */
>      bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
>      if (bsel) {
> -        uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
> -
> -        aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
> -        aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
> -                                     aml_int(1))); /* Device Check */
> -        aml_append(method, aml_call2("DVNT", aml_name("PCID"),
> -                                     aml_int(3))); /* Eject Request */
> -        nr_notifiers++;
> +        uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
> +
> +        if (bsel_val != UINT32_MAX) {
> +            aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
> +            aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
> +                                         aml_int(1))); /* Device Check */
> +            aml_append(method, aml_call2("DVNT", aml_name("PCID"),
> +                                         aml_int(3))); /* Eject Request */
> +            nr_notifiers++;
> +        }
>      }
>  
>      /* Notify about child bus events in any case */
> @@ -848,7 +846,7 @@ void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus)
>      Aml *dev, *notify_method = NULL, *method;
>      QObject *bsel = object_property_get_qobject(OBJECT(bus),
>                          ACPI_PCIHP_PROP_BSEL, NULL);
> -    uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
> +    uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
>      qobject_unref(bsel);
>  
>      aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index f6386088b6..7ba7b38773 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -1207,6 +1207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>      AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = vms->oem_id,
>                          .oem_table_id = vms->oem_table_id };
>      Aml *pci0_scope;
> +    Error *local_err = NULL;
> +    uint32_t bsel;
>  
>      acpi_table_begin(&table, table_data);
>      dsdt = init_aml_allocator();
> @@ -1269,9 +1271,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>  
>      aml_append(pci0_scope, build_pci_bridge_edsm());
>      build_append_pci_bus_devices(pci0_scope, vms->bus);
> -    if (object_property_find(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL)) {
> +    bsel = object_property_get_uint(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL,
> +                                    &local_err);
> +    if (local_err == NULL && bsel != UINT32_MAX) {
>          build_append_pcihp_slots(pci0_scope, vms->bus);
>      }
> +    error_free(local_err);
>  
>      if (vms->acpi_dev) {
>          bool acpi_pcihp;
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 8837b69687..cc0b6e5633 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1198,15 +1198,20 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>      sb_scope = aml_scope("\\_SB");
>      {
>          Object *pci_host = acpi_get_i386_pci_host();
> +        Error *local_err = NULL;
> +        uint32_t bsel;
>  
>          if (pci_host) {
>              PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
>              Aml *ascope = aml_scope("PCI0");
>              /* Scan all PCI buses. Generate tables to support hotplug. */
>              build_append_pci_bus_devices(ascope, pbus);
> -            if (object_property_find(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL)) {
> +            bsel = object_property_get_uint(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL,
> +                                            &local_err);
> +            if (local_err == NULL && bsel != UINT32_MAX) {
>                  build_append_pcihp_slots(ascope, pbus);
>              }
> +            error_free(local_err);
>              aml_append(sb_scope, ascope);
>          }
>      }
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index d3191609e2..e8e8a3b767 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -25,6 +25,7 @@
>  #include "qemu/osdep.h"
>  #include "qemu/datadir.h"
>  #include "qemu/units.h"
> +#include "hw/acpi/pcihp.h"
>  #include "hw/core/irq.h"
>  #include "hw/pci/pci.h"
>  #include "hw/pci/pci_bridge.h"
> @@ -187,6 +188,8 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
>      bus->machine_done.notify = pcibus_machine_done;
>      qemu_add_machine_init_done_notifier(&bus->machine_done);
>  
> +    bus->acpi_pcihp_bsel_val = UINT32_MAX;
> +
>      vmstate_register_any(NULL, &vmstate_pcibus, bus);
>  }
>  
> @@ -302,6 +305,10 @@ static void pci_bus_class_init(ObjectClass *klass, const void *data)
>      pbc->numa_node = pcibus_numa_node;
>  
>      fwgc->get_data = pci_bus_fw_cfg_gen_data;
> +
> +    object_class_property_add_uint32_ptr(klass, ACPI_PCIHP_PROP_BSEL,
> +                                         offsetof(PCIBus, acpi_pcihp_bsel_val),
> +                                         OBJ_PROP_FLAG_READWRITE);
>  }
>  
>  static const TypeInfo pci_bus_info = {
> -- 
> 2.43.0
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties
  2026-08-21 11:14 ` [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties Mark Cave-Ayland
@ 2026-08-24 13:05   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 13:05 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:27PM +0100, Mark Cave-Ayland wrote:
> The majority of the properties in piix4_pm_add_properties() are assigned to
> static variables and so can be converted to static class properties. Introduce
> piix4_pm_add_class_properties() to hold the static properties and soon all
> other class props after they have been converted from object props.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/acpi/piix4.c | 40 ++++++++++++++++++++++++++++------------
>  1 file changed, 28 insertions(+), 12 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop
  2026-08-21 11:14 ` [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop Mark Cave-Ayland
@ 2026-08-24 13:06   ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 13:06 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Fri, Aug 21, 2026 at 12:14:28PM +0100, Mark Cave-Ayland wrote:
> ACPI_PM_PROP_PM_IO_BASE can be converted to use object_class_property_add_uint32_ptr().
> Remove the now unused piix4_pm_add_properties() function.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/acpi/piix4.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr()
  2026-08-24 12:53   ` Daniel P. Berrangé
@ 2026-08-24 13:39     ` Mark Cave-Ayland
  2026-08-24 13:57       ` Daniel P. Berrangé
  0 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-24 13:39 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On 24/08/2026 13:53, Daniel P. Berrangé wrote:

> On Fri, Aug 21, 2026 at 12:14:22PM +0100, Mark Cave-Ayland wrote:
>> This adds a class property that references a bool within the object instance
>> and is intended to be used as a replacement for object_class_property_add_bool()
>> where possible.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>>   include/qom/object.h | 18 ++++++++++++++++++
>>   qom/object.c         | 43 +++++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 61 insertions(+)
>>
>> diff --git a/include/qom/object.h b/include/qom/object.h
>> index 8dead29284..de37016ba8 100644
>> --- a/include/qom/object.h
>> +++ b/include/qom/object.h
>> @@ -2017,6 +2017,24 @@ typedef enum {
>>       OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
>>   } ObjectPropertyFlags;
>>   
>> +/**
>> + * object_class_property_add_bool_ptr:
>> + * @klass: the object class to add a property to
>> + * @name: the name of the property
>> + * @offset: the offset from the object instance where the bool value is
>> + *   stored
>> + * @flags: bitwise-or'd ObjectPropertyFlags
>> + *
>> + * Add an boolean property in memory.  This function will add a
>> + * property of type 'bool'.
>> + *
>> + * Returns: The newly added property on success, or %NULL on failure.
>> + */
>> +ObjectProperty *object_class_property_add_bool_ptr(ObjectClass *klass,
>> +                                         const char *name,
>> +                                         ptrdiff_t offset,
>> +                                         ObjectPropertyFlags flags);
>> +
>>   /**
>>    * object_property_add_uint8_ptr:
>>    * @obj: the object to add a property to
>> diff --git a/qom/object.c b/qom/object.c
>> index f91764aaa7..635eeeac77 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -2750,6 +2750,49 @@ DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
>>   #undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
>>   
>>   
>> +static void property_class_get_bool_ptr(Object *obj, Visitor *v,
>> +                                        const char *name,
>> +                                        void *opaque, Error **errp)
>> +{
>> +    bool value = *(bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
>> +
>> +    visit_type_bool(v, name, &value, errp);
>> +}
>> +
>> +static void property_class_set_bool_ptr(Object *obj, Visitor *v,
>> +                                        const char *name,
>> +                                        void *opaque, Error **errp)
>> +{
>> +    bool *field = (bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
>> +    bool value;
>> +
>> +    if (!visit_type_bool(v, name, &value, errp)) {
>> +        return;
>> +    }
>> +
>> +    *field = value;
>> +}
> 
> Am I missing the reason why we can't use
> 
>    DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(bool)
> 
> ?  If so, could that be mentioned in the commit message.

It's because bool is actually a macro according to C99 which causes the 
expansion to fail.

I'll update the commit message accordingly for v5.

>> +
>> +ObjectProperty *
>> +object_class_property_add_bool_ptr(ObjectClass *klass, const char *name,
>> +                                   ptrdiff_t offset,
>> +                                   ObjectPropertyFlags flags)
>> +{
>> +    ObjectPropertyAccessor *getter = NULL;
>> +    ObjectPropertyAccessor *setter = NULL;
>> +
>> +    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
>> +        getter = property_class_get_bool_ptr;
>> +    }
>> +
>> +    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
>> +        setter = property_class_set_bool_ptr;
>> +    }
>> +
>> +    return object_class_property_add(klass, name, "bool",
>> +                                     getter, setter, NULL, (void *)offset);
>> +}
>> +
>>   ObjectProperty *
>>   object_property_add_uint8_ptr(Object *obj, const char *name,
>>                                 const uint8_t *v,
>> -- 
>> 2.43.0

ATB,

Mark.



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props
  2026-08-24 12:59   ` Daniel P. Berrangé
@ 2026-08-24 13:41     ` Mark Cave-Ayland
  0 siblings, 0 replies; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-24 13:41 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On 24/08/2026 13:59, Daniel P. Berrangé wrote:

> On Fri, Aug 21, 2026 at 12:14:23PM +0100, Mark Cave-Ayland wrote:
>> ACPI_PM_PROP_TCO_ENABLED, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE and x-keep-pci-slot-hpc
>> properties can be converted to use object_class_property_add_bool_ptr(). Remove
>> the now unused ich9_pm_add_properties() function.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>>   include/hw/acpi/ich9.h |   3 +-
>>   hw/acpi/ich9.c         | 111 ++++++++++++++++-------------------------
>>   hw/isa/lpc_ich9.c      |   3 +-
>>   3 files changed, 44 insertions(+), 73 deletions(-)
> 
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> 
> but...
> 
> 
>> @@ -436,6 +368,47 @@ void ich9_pm_add_class_properties(ObjectClass *oc)
>>                                                   ACPI_PM_PROP_GPE0_BLK_LEN,
>>                                                   &gpe0_len,
>>                                                   OBJ_PROP_FLAG_READ);
> ...it'd read nicer with
> 
>    #define REG_FIELD(n) \
>      (pm_offset + offsetof(ICH9LPCPMRegs, n))

I don't feel strongly about it either way, but I'll try implementing it 
using a PM_REG_FIELD() macro as suggested above (I'm worried that 
REG_FIELD() is a generic enough name that it may end up clashing with 
something internally).
>> +    object_class_property_add_uint32_ptr(oc, ACPI_PM_PROP_PM_IO_BASE,
>> +                                         pm_offset +
>> +                                         offsetof(ICH9LPCPMRegs,
>> +                                                  pm_io_base),
>> +                                         OBJ_PROP_FLAG_READ);
> 
> 
> ....
> 
>      object_class_property_add_uint32_ptr(oc, ACPI_PM_PROP_PM_IO_BASE,
>                                           REG_FIELD(pm_io_base),
>                                           OBJ_PROP_FLAG_READ);
> 
> ...
> 
>> +    object_class_property_add_link(oc, "bus",
>> +                                   TYPE_PCI_BUS,
>> +                                   pm_offset +
>> +                                   offsetof(ICH9LPCPMRegs,
>> +                                            acpi_pci_hotplug.root),
>> +                                   object_property_allow_set_link,
>> +                                   OBJ_PROP_LINK_STRONG);
>> +    object_class_property_add(oc, ACPI_PM_PROP_GPE0_BLK, "uint32",
>> +                              ich9_pm_get_gpe0_blk,
>> +                              NULL, NULL, NULL);
>> +    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S3_DISABLED,
>> +                                        pm_offset +
>> +                                        offsetof(ICH9LPCPMRegs, disable_s3),
>> +                                        OBJ_PROP_FLAG_READWRITE);
>> +    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S4_DISABLED,
>> +                                        pm_offset +
>> +                                        offsetof(ICH9LPCPMRegs, disable_s4),
>> +                                        OBJ_PROP_FLAG_READWRITE);
>> +    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S4_VAL,
>> +                                        pm_offset +
>> +                                        offsetof(ICH9LPCPMRegs, s4_val),
>> +                                        OBJ_PROP_FLAG_READWRITE);
>> +    object_class_property_add_bool_ptr(oc, ACPI_PM_PROP_TCO_ENABLED,
>> +                                       pm_offset +
>> +                                       offsetof(ICH9LPCPMRegs, enable_tco),
>> +                                       OBJ_PROP_FLAG_READWRITE);
>> +    object_class_property_add_bool_ptr(oc, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE,
>> +                               pm_offset +
>> +                               offsetof(ICH9LPCPMRegs,
>> +                                   acpi_pci_hotplug.use_acpi_hotplug_bridge),
>> +                               OBJ_PROP_FLAG_READWRITE);
>> +    object_class_property_add_bool_ptr(oc, "x-keep-pci-slot-hpc",
>> +                                       pm_offset +
>> +                                       offsetof(ICH9LPCPMRegs,
>> +                                                keep_pci_slot_hpc),
>> +                                       OBJ_PROP_FLAG_READWRITE);
> 
> ...
> 
>    #undef REG_FIELD
> 
>>   }
>>   
>>   void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
>> diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
>> index d3f1358887..b55b5136a3 100644
>> --- a/hw/isa/lpc_ich9.c
>> +++ b/hw/isa/lpc_ich9.c
>> @@ -689,7 +689,6 @@ static void ich9_lpc_initfn(Object *obj)
>>                                IOAPIC_NUM_PINS);
>>   
>>       ich9_pm_reset_properties(&lpc->pm);
>> -    ich9_pm_add_properties(obj, &lpc->pm);
>>   }
>>   
>>   static void ich9_lpc_realize(PCIDevice *d, Error **errp)
>> @@ -920,7 +919,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
>>                                                  &acpi_disable_cmd,
>>                                                  OBJ_PROP_FLAG_READ);
>>   
>> -    ich9_pm_add_class_properties(klass);
>> +    ich9_pm_add_class_properties(klass, offsetof(ICH9LPCState, pm));
>>   }
>>   
>>   static const TypeInfo ich9_lpc_info = {
>> -- 
>> 2.43.0

ATB,

Mark.



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
  2026-08-24 13:04   ` Daniel P. Berrangé
@ 2026-08-24 13:47     ` Mark Cave-Ayland
  2026-08-25  7:17       ` Markus Armbruster
  0 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-24 13:47 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm,
	Markus Armbruster

On 24/08/2026 14:04, Daniel P. Berrangé wrote:

> On Fri, Aug 21, 2026 at 12:14:26PM +0100, Mark Cave-Ayland wrote:
>> Move the ACPI_PCIHP_PROP_BSEL property to the PCIBus object and update all
>> callers accordingly.
>>
>> Since the existing logic checks for the existence of the ACPI_PCIHP_PROP_BSEL
>> property to enable the relevant ACPI changes, set the type of the underlying
>> variable to uint32_t with a default value of UINT32_MAX indicating that the
>> property has not been set.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>>   include/hw/pci/pci_bus.h |  2 ++
>>   hw/acpi/pci-bridge.c     |  9 ++++++++-
>>   hw/acpi/pcihp.c          | 30 ++++++++++++++----------------
>>   hw/arm/virt-acpi-build.c |  7 ++++++-
>>   hw/i386/acpi-build.c     |  7 ++++++-
>>   hw/pci/pci.c             |  7 +++++++
>>   6 files changed, 43 insertions(+), 19 deletions(-)
>>
>> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
>> index c738446788..7ecb23d13c 100644
>> --- a/include/hw/pci/pci_bus.h
>> +++ b/include/hw/pci/pci_bus.h
>> @@ -56,6 +56,8 @@ struct PCIBus {
>>       int *irq_count;
>>   
>>       Notifier machine_done;
>> +
>> +    uint32_t acpi_pcihp_bsel_val;
>>   };
>>   
>>   static inline bool pci_bus_is_cxl(PCIBus *bus)
>> diff --git a/hw/acpi/pci-bridge.c b/hw/acpi/pci-bridge.c
>> index 394a919479..1bfc5431f2 100644
>> --- a/hw/acpi/pci-bridge.c
>> +++ b/hw/acpi/pci-bridge.c
>> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>   
>>       if (!DEVICE(br)->hotplugged) {
>>           PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
>> +        Error *local_err = NULL;
>> +        uint32_t bsel;
>>   
>>           build_append_pci_bus_devices(scope, sec_bus);
>>   
>> @@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>            * generate hotplug slots descriptors if
>>            * bridge has ACPI PCI hotplug attached,
>>            */
>> -        if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
>> +        bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
>> +                                        &local_err);
>> +
>> +        if (local_err == NULL && bsel != UINT32_MAX) {
>>               build_append_pcihp_slots(scope, sec_bus);
>>           }
>> +
>> +        error_free(local_err);
> 
> IIUC, in this new approach the property should always exist and so I'd
> expect object_property_get_uint to always succeed.
> 
> IOW, is something stopping us using &error_abort and merely checking
> 
>    if (bsel != UINT32_MAX)
> 
> ?

I think that would work, although in the back of my mind I have a memory 
that we should try avoiding error_abort where at all possible.

Markus, any thoughts/comments on error_abort usage?

>>       }
>>   }
>>   
>> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
>> index a91f523c93..b26ddf0a26 100644
>> --- a/hw/acpi/pcihp.c
>> +++ b/hw/acpi/pcihp.c
>> @@ -58,7 +58,7 @@ typedef struct AcpiPciHpFind {
>>   static int acpi_pcihp_get_bsel(PCIBus *bus)
>>   {
>>       Error *local_err = NULL;
>> -    uint64_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
>> +    uint32_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
>>                                                &local_err);
>>   
>>       if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
>> @@ -78,18 +78,14 @@ typedef struct {
>>   static void *acpi_set_bsel(PCIBus *bus, void *opaque)
>>   {
>>       BSELInfo *info = opaque;
>> -    unsigned *bus_bsel;
>>       DeviceState *br = bus->qbus.parent;
>>       bool is_bridge = IS_PCI_BRIDGE(br);
>>   
>>       /* hotplugged bridges can't be described in ACPI ignore them */
>>       if (qbus_is_hotpluggable(BUS(bus))) {
>>           if (!is_bridge || (!br->hotplugged && info->has_bridge_hotplug)) {
>> -            bus_bsel = g_malloc(sizeof *bus_bsel);
>> -
>> -            *bus_bsel = info->bsel_alloc++;
>> -            object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
>> -                                           bus_bsel, OBJ_PROP_FLAG_READ);
>> +            object_property_set_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
>> +                                     info->bsel_alloc++, NULL);
>>           }
>>       }
>>   
>> @@ -730,14 +726,16 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)
>>       /* If bus supports hotplug select it and notify about local events */
>>       bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
>>       if (bsel) {
>> -        uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
>> -
>> -        aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
>> -        aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
>> -                                     aml_int(1))); /* Device Check */
>> -        aml_append(method, aml_call2("DVNT", aml_name("PCID"),
>> -                                     aml_int(3))); /* Eject Request */
>> -        nr_notifiers++;
>> +        uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
>> +
>> +        if (bsel_val != UINT32_MAX) {
>> +            aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
>> +            aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
>> +                                         aml_int(1))); /* Device Check */
>> +            aml_append(method, aml_call2("DVNT", aml_name("PCID"),
>> +                                         aml_int(3))); /* Eject Request */
>> +            nr_notifiers++;
>> +        }
>>       }
>>   
>>       /* Notify about child bus events in any case */
>> @@ -848,7 +846,7 @@ void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus)
>>       Aml *dev, *notify_method = NULL, *method;
>>       QObject *bsel = object_property_get_qobject(OBJECT(bus),
>>                           ACPI_PCIHP_PROP_BSEL, NULL);
>> -    uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
>> +    uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
>>       qobject_unref(bsel);
>>   
>>       aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> index f6386088b6..7ba7b38773 100644
>> --- a/hw/arm/virt-acpi-build.c
>> +++ b/hw/arm/virt-acpi-build.c
>> @@ -1207,6 +1207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>>       AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = vms->oem_id,
>>                           .oem_table_id = vms->oem_table_id };
>>       Aml *pci0_scope;
>> +    Error *local_err = NULL;
>> +    uint32_t bsel;
>>   
>>       acpi_table_begin(&table, table_data);
>>       dsdt = init_aml_allocator();
>> @@ -1269,9 +1271,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>>   
>>       aml_append(pci0_scope, build_pci_bridge_edsm());
>>       build_append_pci_bus_devices(pci0_scope, vms->bus);
>> -    if (object_property_find(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL)) {
>> +    bsel = object_property_get_uint(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL,
>> +                                    &local_err);
>> +    if (local_err == NULL && bsel != UINT32_MAX) {
>>           build_append_pcihp_slots(pci0_scope, vms->bus);
>>       }
>> +    error_free(local_err);
>>   
>>       if (vms->acpi_dev) {
>>           bool acpi_pcihp;
>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>> index 8837b69687..cc0b6e5633 100644
>> --- a/hw/i386/acpi-build.c
>> +++ b/hw/i386/acpi-build.c
>> @@ -1198,15 +1198,20 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>>       sb_scope = aml_scope("\\_SB");
>>       {
>>           Object *pci_host = acpi_get_i386_pci_host();
>> +        Error *local_err = NULL;
>> +        uint32_t bsel;
>>   
>>           if (pci_host) {
>>               PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
>>               Aml *ascope = aml_scope("PCI0");
>>               /* Scan all PCI buses. Generate tables to support hotplug. */
>>               build_append_pci_bus_devices(ascope, pbus);
>> -            if (object_property_find(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL)) {
>> +            bsel = object_property_get_uint(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL,
>> +                                            &local_err);
>> +            if (local_err == NULL && bsel != UINT32_MAX) {
>>                   build_append_pcihp_slots(ascope, pbus);
>>               }
>> +            error_free(local_err);
>>               aml_append(sb_scope, ascope);
>>           }
>>       }
>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>> index d3191609e2..e8e8a3b767 100644
>> --- a/hw/pci/pci.c
>> +++ b/hw/pci/pci.c
>> @@ -25,6 +25,7 @@
>>   #include "qemu/osdep.h"
>>   #include "qemu/datadir.h"
>>   #include "qemu/units.h"
>> +#include "hw/acpi/pcihp.h"
>>   #include "hw/core/irq.h"
>>   #include "hw/pci/pci.h"
>>   #include "hw/pci/pci_bridge.h"
>> @@ -187,6 +188,8 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
>>       bus->machine_done.notify = pcibus_machine_done;
>>       qemu_add_machine_init_done_notifier(&bus->machine_done);
>>   
>> +    bus->acpi_pcihp_bsel_val = UINT32_MAX;
>> +
>>       vmstate_register_any(NULL, &vmstate_pcibus, bus);
>>   }
>>   
>> @@ -302,6 +305,10 @@ static void pci_bus_class_init(ObjectClass *klass, const void *data)
>>       pbc->numa_node = pcibus_numa_node;
>>   
>>       fwgc->get_data = pci_bus_fw_cfg_gen_data;
>> +
>> +    object_class_property_add_uint32_ptr(klass, ACPI_PCIHP_PROP_BSEL,
>> +                                         offsetof(PCIBus, acpi_pcihp_bsel_val),
>> +                                         OBJ_PROP_FLAG_READWRITE);
>>   }
>>   
>>   static const TypeInfo pci_bus_info = {
>> -- 
>> 2.43.0

ATB,

Mark.



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr()
  2026-08-24 13:39     ` Mark Cave-Ayland
@ 2026-08-24 13:57       ` Daniel P. Berrangé
  0 siblings, 0 replies; 40+ messages in thread
From: Daniel P. Berrangé @ 2026-08-24 13:57 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	richard.henderson, marcandre.lureau, qemu-devel, qemu-arm

On Mon, Aug 24, 2026 at 02:39:11PM +0100, Mark Cave-Ayland wrote:
> On 24/08/2026 13:53, Daniel P. Berrangé wrote:
> 
> > On Fri, Aug 21, 2026 at 12:14:22PM +0100, Mark Cave-Ayland wrote:
> > > This adds a class property that references a bool within the object instance
> > > and is intended to be used as a replacement for object_class_property_add_bool()
> > > where possible.
> > > 
> > > Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> > > Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > >   include/qom/object.h | 18 ++++++++++++++++++
> > >   qom/object.c         | 43 +++++++++++++++++++++++++++++++++++++++++++
> > >   2 files changed, 61 insertions(+)
> > > 
> > > diff --git a/include/qom/object.h b/include/qom/object.h
> > > index 8dead29284..de37016ba8 100644
> > > --- a/include/qom/object.h
> > > +++ b/include/qom/object.h
> > > @@ -2017,6 +2017,24 @@ typedef enum {
> > >       OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
> > >   } ObjectPropertyFlags;
> > > +/**
> > > + * object_class_property_add_bool_ptr:
> > > + * @klass: the object class to add a property to
> > > + * @name: the name of the property
> > > + * @offset: the offset from the object instance where the bool value is
> > > + *   stored
> > > + * @flags: bitwise-or'd ObjectPropertyFlags
> > > + *
> > > + * Add an boolean property in memory.  This function will add a
> > > + * property of type 'bool'.
> > > + *
> > > + * Returns: The newly added property on success, or %NULL on failure.
> > > + */
> > > +ObjectProperty *object_class_property_add_bool_ptr(ObjectClass *klass,
> > > +                                         const char *name,
> > > +                                         ptrdiff_t offset,
> > > +                                         ObjectPropertyFlags flags);
> > > +
> > >   /**
> > >    * object_property_add_uint8_ptr:
> > >    * @obj: the object to add a property to
> > > diff --git a/qom/object.c b/qom/object.c
> > > index f91764aaa7..635eeeac77 100644
> > > --- a/qom/object.c
> > > +++ b/qom/object.c
> > > @@ -2750,6 +2750,49 @@ DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
> > >   #undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
> > > +static void property_class_get_bool_ptr(Object *obj, Visitor *v,
> > > +                                        const char *name,
> > > +                                        void *opaque, Error **errp)
> > > +{
> > > +    bool value = *(bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
> > > +
> > > +    visit_type_bool(v, name, &value, errp);
> > > +}
> > > +
> > > +static void property_class_set_bool_ptr(Object *obj, Visitor *v,
> > > +                                        const char *name,
> > > +                                        void *opaque, Error **errp)
> > > +{
> > > +    bool *field = (bool *)object_class_prop_ptr(obj, (ptrdiff_t)opaque);
> > > +    bool value;
> > > +
> > > +    if (!visit_type_bool(v, name, &value, errp)) {
> > > +        return;
> > > +    }
> > > +
> > > +    *field = value;
> > > +}
> > 
> > Am I missing the reason why we can't use
> > 
> >    DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(bool)
> > 
> > ?  If so, could that be mentioned in the commit message.
> 
> It's because bool is actually a macro according to C99 which causes the
> expansion to fail.
> 
> I'll update the commit message accordingly for v5.

Ah yes, I see it gets messy as you end up expanding
to  visit_type__Bool which of course doesn't exist.


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
  2026-08-24 13:47     ` Mark Cave-Ayland
@ 2026-08-25  7:17       ` Markus Armbruster
  2026-08-25 12:53         ` Mark Cave-Ayland
  0 siblings, 1 reply; 40+ messages in thread
From: Markus Armbruster @ 2026-08-25  7:17 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: Daniel P. Berrangé, mst, imammedo, anisinha, philmd,
	aurelien, peter.maydell, richard.henderson, marcandre.lureau,
	qemu-devel, qemu-arm

Mark Cave-Ayland <mark.caveayland@nutanix.com> writes:

> On 24/08/2026 14:04, Daniel P. Berrangé wrote:
>
>> On Fri, Aug 21, 2026 at 12:14:26PM +0100, Mark Cave-Ayland wrote:
>>> Move the ACPI_PCIHP_PROP_BSEL property to the PCIBus object and update all
>>> callers accordingly.
>>>
>>> Since the existing logic checks for the existence of the ACPI_PCIHP_PROP_BSEL
>>> property to enable the relevant ACPI changes, set the type of the underlying
>>> variable to uint32_t with a default value of UINT32_MAX indicating that the
>>> property has not been set.
>>>
>>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>> ---
>>>   include/hw/pci/pci_bus.h |  2 ++
>>>   hw/acpi/pci-bridge.c     |  9 ++++++++-
>>>   hw/acpi/pcihp.c          | 30 ++++++++++++++----------------
>>>   hw/arm/virt-acpi-build.c |  7 ++++++-
>>>   hw/i386/acpi-build.c     |  7 ++++++-
>>>   hw/pci/pci.c             |  7 +++++++
>>>   6 files changed, 43 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
>>> index c738446788..7ecb23d13c 100644
>>> --- a/include/hw/pci/pci_bus.h
>>> +++ b/include/hw/pci/pci_bus.h
>>> @@ -56,6 +56,8 @@ struct PCIBus {
>>>       int *irq_count;
>>>         Notifier machine_done;
>>> +
>>> +    uint32_t acpi_pcihp_bsel_val;
>>>   };
>>>     static inline bool pci_bus_is_cxl(PCIBus *bus)
>>> diff --git a/hw/acpi/pci-bridge.c b/hw/acpi/pci-bridge.c
>>> index 394a919479..1bfc5431f2 100644
>>> --- a/hw/acpi/pci-bridge.c
>>> +++ b/hw/acpi/pci-bridge.c
>>> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>>  
>>>      if (!DEVICE(br)->hotplugged) {
>>>          PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
>>> +        Error *local_err = NULL;
>>> +        uint32_t bsel;
>>>  
>>>          build_append_pci_bus_devices(scope, sec_bus);
>>>  
>>> @@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>>           * generate hotplug slots descriptors if
>>>           * bridge has ACPI PCI hotplug attached,
>>>           */
>>> -        if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
>>> +        bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
>>> +                                        &local_err);
>>> +
>>> +        if (local_err == NULL && bsel != UINT32_MAX) {
>>>              build_append_pcihp_slots(scope, sec_bus);
>>>          }
>>> +
>>> +        error_free(local_err);
>> IIUC, in this new approach the property should always exist and so I'd
>> expect object_property_get_uint to always succeed.
>> IOW, is something stopping us using &error_abort and merely checking
>>    if (bsel != UINT32_MAX)
>> ?
>
> I think that would work, although in the back of my mind I have a memory that we should try avoiding error_abort where at all possible.
>
> Markus, any thoughts/comments on error_abort usage?

&error_abort is an assertion, just like assert().

Assertions are strictly for programming errors.  When the program
detects such an error, it is defective and needs fixing.

Commonly, the program is in an invalid state then, and continuing
execution is unsafe.  Aborting it is the only sane option.

Assertions conveniently combine the error check and the abort, and also
scream "this is a a programming error" both to readers of the code and
unfortunate users tripping them.  Good!

I particularly dislike the pattern

    if (programming error detected) {
        error recovery that should never be reached
    }

where the code doesn't actually *tell* me it's a programming error.
This matters!  The error recovery needs to be treated with extreme
suspicion then, because it's not testable and almost certainly unsafe.

The pattern can also make me go "huh, I wonder how this error can
happen, let me figure that out", wasting my time.

Another gripe of mine: we often pass NULL where we should pass
&error_abort.

Questions?

[...]



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
  2026-08-25  7:17       ` Markus Armbruster
@ 2026-08-25 12:53         ` Mark Cave-Ayland
  2026-08-25 13:29           ` Markus Armbruster
  0 siblings, 1 reply; 40+ messages in thread
From: Mark Cave-Ayland @ 2026-08-25 12:53 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Daniel P. Berrangé, mst, imammedo, anisinha, philmd,
	aurelien, peter.maydell, richard.henderson, marcandre.lureau,
	qemu-devel, qemu-arm

On 25/08/2026 08:17, Markus Armbruster wrote:

> Mark Cave-Ayland <mark.caveayland@nutanix.com> writes:
> 
>> On 24/08/2026 14:04, Daniel P. Berrangé wrote:
>>
>>> On Fri, Aug 21, 2026 at 12:14:26PM +0100, Mark Cave-Ayland wrote:
>>>> Move the ACPI_PCIHP_PROP_BSEL property to the PCIBus object and update all
>>>> callers accordingly.
>>>>
>>>> Since the existing logic checks for the existence of the ACPI_PCIHP_PROP_BSEL
>>>> property to enable the relevant ACPI changes, set the type of the underlying
>>>> variable to uint32_t with a default value of UINT32_MAX indicating that the
>>>> property has not been set.
>>>>
>>>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>>>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>>> ---
>>>>    include/hw/pci/pci_bus.h |  2 ++
>>>>    hw/acpi/pci-bridge.c     |  9 ++++++++-
>>>>    hw/acpi/pcihp.c          | 30 ++++++++++++++----------------
>>>>    hw/arm/virt-acpi-build.c |  7 ++++++-
>>>>    hw/i386/acpi-build.c     |  7 ++++++-
>>>>    hw/pci/pci.c             |  7 +++++++
>>>>    6 files changed, 43 insertions(+), 19 deletions(-)
>>>>
>>>> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
>>>> index c738446788..7ecb23d13c 100644
>>>> --- a/include/hw/pci/pci_bus.h
>>>> +++ b/include/hw/pci/pci_bus.h
>>>> @@ -56,6 +56,8 @@ struct PCIBus {
>>>>        int *irq_count;
>>>>          Notifier machine_done;
>>>> +
>>>> +    uint32_t acpi_pcihp_bsel_val;
>>>>    };
>>>>      static inline bool pci_bus_is_cxl(PCIBus *bus)
>>>> diff --git a/hw/acpi/pci-bridge.c b/hw/acpi/pci-bridge.c
>>>> index 394a919479..1bfc5431f2 100644
>>>> --- a/hw/acpi/pci-bridge.c
>>>> +++ b/hw/acpi/pci-bridge.c
>>>> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>>> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>>>   
>>>>       if (!DEVICE(br)->hotplugged) {
>>>>           PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
>>>> +        Error *local_err = NULL;
>>>> +        uint32_t bsel;
>>>>   
>>>>           build_append_pci_bus_devices(scope, sec_bus);
>>>>   
>>>> @@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>>>>            * generate hotplug slots descriptors if
>>>>            * bridge has ACPI PCI hotplug attached,
>>>>            */
>>>> -        if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
>>>> +        bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
>>>> +                                        &local_err);
>>>> +
>>>> +        if (local_err == NULL && bsel != UINT32_MAX) {
>>>>               build_append_pcihp_slots(scope, sec_bus);
>>>>           }
>>>> +
>>>> +        error_free(local_err);
>>> IIUC, in this new approach the property should always exist and so I'd
>>> expect object_property_get_uint to always succeed.
>>> IOW, is something stopping us using &error_abort and merely checking
>>>     if (bsel != UINT32_MAX)
>>> ?
>>
>> I think that would work, although in the back of my mind I have a memory that we should try avoiding error_abort where at all possible.
>>
>> Markus, any thoughts/comments on error_abort usage?
> 
> &error_abort is an assertion, just like assert().
> 
> Assertions are strictly for programming errors.  When the program
> detects such an error, it is defective and needs fixing.
> 
> Commonly, the program is in an invalid state then, and continuing
> execution is unsafe.  Aborting it is the only sane option.
> 
> Assertions conveniently combine the error check and the abort, and also
> scream "this is a a programming error" both to readers of the code and
> unfortunate users tripping them.  Good!
> 
> I particularly dislike the pattern
> 
>      if (programming error detected) {
>          error recovery that should never be reached
>      }
> 
> where the code doesn't actually *tell* me it's a programming error.
> This matters!  The error recovery needs to be treated with extreme
> suspicion then, because it's not testable and almost certainly unsafe.
> 
> The pattern can also make me go "huh, I wonder how this error can
> happen, let me figure that out", wasting my time.
> 
> Another gripe of mine: we often pass NULL where we should pass
> &error_abort.
> 
> Questions?
Always :)  Seriously though, for this particular case I think 
error_abort is reasonable since if you've managed to get a non-PCIBus 
from pci_bridge_get_sec_bus() then things are generally looking pretty bad.

Thanks for the pointers as it's something else to add to my set of notes 
as to how we should best model these things in QEMU. I wonder if there 
is a suitable place in the documentation we could add this?


ATB,

Mark.



^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
  2026-08-25 12:53         ` Mark Cave-Ayland
@ 2026-08-25 13:29           ` Markus Armbruster
  0 siblings, 0 replies; 40+ messages in thread
From: Markus Armbruster @ 2026-08-25 13:29 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: Daniel P. Berrangé, mst, imammedo, anisinha, philmd,
	aurelien, peter.maydell, richard.henderson, marcandre.lureau,
	qemu-devel, qemu-arm

Mark Cave-Ayland <mark.caveayland@nutanix.com> writes:

[...]

> Thanks for the pointers as it's something else to add to my set of notes as to how we should best model these things in QEMU. I wonder if there is a suitable place in the documentation we could add this?

docs/devel/style.rst has a section "Error handling and reporting".

There's quite a bit of documentation in qapi/error.h.

Feel free to propose improvements.



^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2026-08-25 13:30 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
2026-08-21 11:14 ` [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro Mark Cave-Ayland
2026-08-24 12:43   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro Mark Cave-Ayland
2026-08-24 12:44   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro Mark Cave-Ayland
2026-08-24 12:44   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
2026-08-24 12:45   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
2026-08-24 12:46   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
2026-08-24 12:47   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
2026-08-24 12:48   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
2026-08-24 12:48   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property Mark Cave-Ayland
2026-08-24 12:50   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr() Mark Cave-Ayland
2026-08-24 12:53   ` Daniel P. Berrangé
2026-08-24 13:39     ` Mark Cave-Ayland
2026-08-24 13:57       ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
2026-08-24 12:59   ` Daniel P. Berrangé
2026-08-24 13:41     ` Mark Cave-Ayland
2026-08-21 11:14 ` [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
2026-08-24 13:00   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props Mark Cave-Ayland
2026-08-24 13:01   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
2026-08-24 13:04   ` Daniel P. Berrangé
2026-08-24 13:47     ` Mark Cave-Ayland
2026-08-25  7:17       ` Markus Armbruster
2026-08-25 12:53         ` Mark Cave-Ayland
2026-08-25 13:29           ` Markus Armbruster
2026-08-21 11:14 ` [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties Mark Cave-Ayland
2026-08-24 13:05   ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop Mark Cave-Ayland
2026-08-24 13:06   ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.