All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/12] hw/acpi: convert object props to class props
@ 2026-07-03 13:53 Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr() Mark Cave-Ayland
                   ` (11 more replies)
  0 siblings, 12 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, 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.]

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.

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

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 (12):
  qom/object.c: rename object_class_property_uint*_ptr() to
    object_class_static_property_uint*_ptr()
  qom/object.c: add object_class_property_add_uint8_ptr()
  qom/object.c: add object_class_property_add_uint16_ptr()
  qom/object.c: add object_class_property_add_uint32_ptr()
  qom/object.c: add object_class_property_add_uint64_ptr()
  hw/acpi/ich9.c: move initial property values into
    ich9_reset_properties()
  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
  hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props
  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 object props in PIIX4_PM to class props

 include/hw/acpi/ich9.h         |   4 +-
 include/hw/pci/pci_bus.h       |   2 +
 include/qom/object.h           |  20 ++++
 hw/acpi/generic_event_device.c |  10 ++
 hw/acpi/ich9.c                 |  79 ++++++++-----
 hw/acpi/pci-bridge.c           |   9 +-
 hw/acpi/pcihp.c                |  37 +++----
 hw/acpi/piix4.c                |  51 ++++++---
 hw/arm/virt-acpi-build.c       |   7 +-
 hw/i386/acpi-build.c           |   7 +-
 hw/isa/lpc_ich9.c              |  71 +++++++++---
 hw/pci/pci.c                   |  32 ++++++
 hw/riscv/spike.c               |   5 +-
 qom/object.c                   | 196 ++++++++++++++++++++++++++++++++-
 14 files changed, 440 insertions(+), 90 deletions(-)

-- 
2.43.0



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

* [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr()
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-07 12:05   ` Daniel P. Berrangé
  2026-07-03 13:53 ` [PATCH v2 02/12] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, qemu-devel, qemu-arm

This more accurately reflects that these properties are held within the class and
not the object.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 include/qom/object.h |  8 ++++----
 hw/riscv/spike.c     |  5 +++--
 qom/object.c         | 28 ++++++++++++++++------------
 3 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 11f55613fc..89c23d45ab 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1956,7 +1956,7 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
                                               const uint8_t *v,
                                               ObjectPropertyFlags flags);
 
-ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
+ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
                                          const char *name,
                                          const uint8_t *v,
                                          ObjectPropertyFlags flags);
@@ -1977,7 +1977,7 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
                                     const uint16_t *v,
                                     ObjectPropertyFlags flags);
 
-ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
+ObjectProperty *object_class_static_property_add_uint16_ptr(ObjectClass *klass,
                                           const char *name,
                                           const uint16_t *v,
                                           ObjectPropertyFlags flags);
@@ -1998,7 +1998,7 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
                                     const uint32_t *v,
                                     ObjectPropertyFlags flags);
 
-ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
+ObjectProperty *object_class_static_property_add_uint32_ptr(ObjectClass *klass,
                                           const char *name,
                                           const uint32_t *v,
                                           ObjectPropertyFlags flags);
@@ -2019,7 +2019,7 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
                                     const uint64_t *v,
                                     ObjectPropertyFlags flags);
 
-ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
+ObjectProperty *object_class_static_property_add_uint64_ptr(ObjectClass *klass,
                                           const char *name,
                                           const uint64_t *v,
                                           ObjectPropertyFlags flags);
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
index 9fde0faf39..630b65f569 100644
--- a/hw/riscv/spike.c
+++ b/hw/riscv/spike.c
@@ -278,8 +278,9 @@ static void spike_machine_class_init(ObjectClass *oc, const void *data)
     object_class_property_add_str(oc, "signature", NULL, spike_set_signature);
     object_class_property_set_description(oc, "signature",
                                           "File to write ACT test signature");
-    object_class_property_add_uint8_ptr(oc, "signature-granularity",
-                                        &line_size, OBJ_PROP_FLAG_WRITE);
+    object_class_static_property_add_uint8_ptr(oc, "signature-granularity",
+                                               &line_size,
+                                               OBJ_PROP_FLAG_WRITE);
     object_class_property_set_description(oc, "signature-granularity",
                                           "Size of each line in ACT signature "
                                           "file");
diff --git a/qom/object.c b/qom/object.c
index f79b2cf361..d10bf848c0 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2762,9 +2762,10 @@ object_property_add_uint8_ptr(Object *obj, const char *name,
 }
 
 ObjectProperty *
-object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
-                                    const uint8_t *v,
-                                    ObjectPropertyFlags flags)
+object_class_static_property_add_uint8_ptr(ObjectClass *klass,
+                                           const char *name,
+                                           const uint8_t *v,
+                                           ObjectPropertyFlags flags)
 {
     ObjectPropertyAccessor *getter = NULL;
     ObjectPropertyAccessor *setter = NULL;
@@ -2802,9 +2803,10 @@ object_property_add_uint16_ptr(Object *obj, const char *name,
 }
 
 ObjectProperty *
-object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
-                                     const uint16_t *v,
-                                     ObjectPropertyFlags flags)
+object_class_static_property_add_uint16_ptr(ObjectClass *klass,
+                                            const char *name,
+                                            const uint16_t *v,
+                                            ObjectPropertyFlags flags)
 {
     ObjectPropertyAccessor *getter = NULL;
     ObjectPropertyAccessor *setter = NULL;
@@ -2842,9 +2844,10 @@ object_property_add_uint32_ptr(Object *obj, const char *name,
 }
 
 ObjectProperty *
-object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
-                                     const uint32_t *v,
-                                     ObjectPropertyFlags flags)
+object_class_static_property_add_uint32_ptr(ObjectClass *klass,
+                                            const char *name,
+                                            const uint32_t *v,
+                                            ObjectPropertyFlags flags)
 {
     ObjectPropertyAccessor *getter = NULL;
     ObjectPropertyAccessor *setter = NULL;
@@ -2882,9 +2885,10 @@ object_property_add_uint64_ptr(Object *obj, const char *name,
 }
 
 ObjectProperty *
-object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
-                                     const uint64_t *v,
-                                     ObjectPropertyFlags flags)
+object_class_static_property_add_uint64_ptr(ObjectClass *klass,
+                                            const char *name,
+                                            const uint64_t *v,
+                                            ObjectPropertyFlags flags)
 {
     ObjectPropertyAccessor *getter = NULL;
     ObjectPropertyAccessor *setter = NULL;
-- 
2.43.0



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

* [PATCH v2 02/12] qom/object.c: add object_class_property_add_uint8_ptr()
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr() Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-07 12:17   ` Daniel P. Berrangé
  2026-07-03 13:53 ` [PATCH v2 03/12] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, 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().

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

diff --git a/include/qom/object.h b/include/qom/object.h
index 89c23d45ab..a55f9d0e97 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1956,6 +1956,11 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
                                               const uint8_t *v,
                                               ObjectPropertyFlags flags);
 
+ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
+                                                    const char *name,
+                                                    ptrdiff_t v,
+                                                    ObjectPropertyFlags flags);
+
 ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
                                          const char *name,
                                          const uint8_t *v,
diff --git a/qom/object.c b/qom/object.c
index d10bf848c0..263c313cd2 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2741,6 +2741,38 @@ static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
     *field = value;
 }
 
+static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
+{
+    void *ptr = obj;
+    ptr += offset;
+
+    return ptr;
+}
+
+static void property_class_get_uint8_ptr(Object *obj, Visitor *v,
+                                         const char *name,
+                                         void *opaque, Error **errp)
+{
+    uint8_t value = *(uint8_t *)object_class_prop_ptr(obj,
+                                                      (ptrdiff_t)opaque);
+    visit_type_uint8(v, name, &value, errp);
+}
+
+static void property_class_set_uint8_ptr(Object *obj, Visitor *v,
+                                         const char *name,
+                                         void *opaque, Error **errp)
+{
+    uint8_t *field = (uint8_t *)object_class_prop_ptr(obj,
+                                                      (ptrdiff_t)opaque);
+    uint8_t value;
+
+    if (!visit_type_uint8(v, name, &value, errp)) {
+        return;
+    }
+
+    *field = value;
+}
+
 ObjectProperty *
 object_property_add_uint8_ptr(Object *obj, const char *name,
                               const uint8_t *v,
@@ -2761,6 +2793,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 v,
+                                    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 *)v);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint8_ptr(ObjectClass *klass,
                                            const char *name,
-- 
2.43.0



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

* [PATCH v2 03/12] qom/object.c: add object_class_property_add_uint16_ptr()
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr() Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 02/12] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 04/12] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, 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>
---
 include/qom/object.h |  5 +++++
 qom/object.c         | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index a55f9d0e97..a175505d40 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1982,6 +1982,11 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
                                     const uint16_t *v,
                                     ObjectPropertyFlags flags);
 
+ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
+                                    const char *name,
+                                    ptrdiff_t v,
+                                    ObjectPropertyFlags flags);
+
 ObjectProperty *object_class_static_property_add_uint16_ptr(ObjectClass *klass,
                                           const char *name,
                                           const uint16_t *v,
diff --git a/qom/object.c b/qom/object.c
index 263c313cd2..52e47068ed 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2773,6 +2773,30 @@ static void property_class_set_uint8_ptr(Object *obj, Visitor *v,
     *field = value;
 }
 
+static void property_class_get_uint16_ptr(Object *obj, Visitor *v,
+                                          const char *name,
+                                          void *opaque, Error **errp)
+{
+    uint16_t value = *(uint16_t *)object_class_prop_ptr(obj,
+                                                        (ptrdiff_t)opaque);
+    visit_type_uint16(v, name, &value, errp);
+}
+
+static void property_class_set_uint16_ptr(Object *obj, Visitor *v,
+                                          const char *name,
+                                          void *opaque, Error **errp)
+{
+    uint16_t *field = (uint16_t *)object_class_prop_ptr(obj,
+                                                        (ptrdiff_t)opaque);
+    uint16_t value;
+
+    if (!visit_type_uint16(v, name, &value, errp)) {
+        return;
+    }
+
+    *field = value;
+}
+
 ObjectProperty *
 object_property_add_uint8_ptr(Object *obj, const char *name,
                               const uint8_t *v,
@@ -2854,6 +2878,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 v,
+                                     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 *)v);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint16_ptr(ObjectClass *klass,
                                             const char *name,
-- 
2.43.0



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

* [PATCH v2 04/12] qom/object.c: add object_class_property_add_uint32_ptr()
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (2 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 03/12] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 05/12] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, 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>
---
 include/qom/object.h |  5 +++++
 qom/object.c         | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index a175505d40..9071d49a29 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2008,6 +2008,11 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
                                     const uint32_t *v,
                                     ObjectPropertyFlags flags);
 
+ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
+                                    const char *name,
+                                    ptrdiff_t v,
+                                    ObjectPropertyFlags flags);
+
 ObjectProperty *object_class_static_property_add_uint32_ptr(ObjectClass *klass,
                                           const char *name,
                                           const uint32_t *v,
diff --git a/qom/object.c b/qom/object.c
index 52e47068ed..3089eba273 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2797,6 +2797,30 @@ static void property_class_set_uint16_ptr(Object *obj, Visitor *v,
     *field = value;
 }
 
+static void property_class_get_uint32_ptr(Object *obj, Visitor *v,
+                                          const char *name,
+                                          void *opaque, Error **errp)
+{
+    uint32_t value = *(uint32_t *)object_class_prop_ptr(obj,
+                                                        (ptrdiff_t)opaque);
+    visit_type_uint32(v, name, &value, errp);
+}
+
+static void property_class_set_uint32_ptr(Object *obj, Visitor *v,
+                                          const char *name,
+                                          void *opaque, Error **errp)
+{
+    uint32_t *field = (uint32_t *)object_class_prop_ptr(obj,
+                                                        (ptrdiff_t)opaque);
+    uint32_t value;
+
+    if (!visit_type_uint32(v, name, &value, errp)) {
+        return;
+    }
+
+    *field = value;
+}
+
 ObjectProperty *
 object_property_add_uint8_ptr(Object *obj, const char *name,
                               const uint8_t *v,
@@ -2939,6 +2963,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 v,
+                                     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 *)v);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint32_ptr(ObjectClass *klass,
                                             const char *name,
-- 
2.43.0



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

* [PATCH v2 05/12] qom/object.c: add object_class_property_add_uint64_ptr()
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (3 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 04/12] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 06/12] hw/acpi/ich9.c: move initial property values into ich9_reset_properties() Mark Cave-Ayland
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, 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().

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

diff --git a/include/qom/object.h b/include/qom/object.h
index 9071d49a29..d5c32844a0 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -2034,6 +2034,11 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
                                     const uint64_t *v,
                                     ObjectPropertyFlags flags);
 
+ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
+                                    const char *name,
+                                    ptrdiff_t v,
+                                    ObjectPropertyFlags flags);
+
 ObjectProperty *object_class_static_property_add_uint64_ptr(ObjectClass *klass,
                                           const char *name,
                                           const uint64_t *v,
diff --git a/qom/object.c b/qom/object.c
index 3089eba273..3048131435 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2821,6 +2821,30 @@ static void property_class_set_uint32_ptr(Object *obj, Visitor *v,
     *field = value;
 }
 
+static void property_class_get_uint64_ptr(Object *obj, Visitor *v,
+                                          const char *name,
+                                          void *opaque, Error **errp)
+{
+    uint64_t value = *(uint64_t *)object_class_prop_ptr(obj,
+                                                        (ptrdiff_t)opaque);
+    visit_type_uint64(v, name, &value, errp);
+}
+
+static void property_class_set_uint64_ptr(Object *obj, Visitor *v,
+                                          const char *name,
+                                          void *opaque, Error **errp)
+{
+    uint64_t *field = (uint64_t *)object_class_prop_ptr(obj,
+                                                        (ptrdiff_t)opaque);
+    uint64_t value;
+
+    if (!visit_type_uint64(v, name, &value, errp)) {
+        return;
+    }
+
+    *field = value;
+}
+
 ObjectProperty *
 object_property_add_uint8_ptr(Object *obj, const char *name,
                               const uint8_t *v,
@@ -3024,6 +3048,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 v,
+                                     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 *)v);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint64_ptr(ObjectClass *klass,
                                             const char *name,
-- 
2.43.0



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

* [PATCH v2 06/12] hw/acpi/ich9.c: move initial property values into ich9_reset_properties()
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (4 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 05/12] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-06  7:06   ` Philippe Mathieu-Daudé
  2026-07-03 13:53 ` [PATCH v2 07/12] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, qemu-devel, qemu-arm

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 include/hw/acpi/ich9.h | 2 ++
 hw/acpi/ich9.c         | 8 ++++++--
 hw/isa/lpc_ich9.c      | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 019f0915c1..30990fcef5 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -81,6 +81,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, qemu_irq sci_irq);
 void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base);
 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_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 5c7dfb2c69..5e8f8a7eaf 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -388,9 +388,8 @@ static void ich9_pm_set_keep_pci_slot_hpc(Object *obj, bool value, Error **errp)
     s->pm.keep_pci_slot_hpc = value;
 }
 
-void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
+void ich9_pm_reset_properties(ICH9LPCPMRegs *pm)
 {
-    static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
     pm->acpi_memory_hotplug.is_enabled = true;
     pm->disable_s3 = 0;
     pm->disable_s4 = 0;
@@ -398,6 +397,11 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
     pm->acpi_pci_hotplug.use_acpi_hotplug_bridge = true;
     pm->keep_pci_slot_hpc = true;
     pm->enable_tco = true;
+}
+
+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);
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 9cec18a378..edf9783ec8 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -701,6 +701,7 @@ static void ich9_lpc_initfn(Object *obj)
                                    &lpc->smi_negotiated_features,
                                    OBJ_PROP_FLAG_READ);
 
+    ich9_pm_reset_properties(&lpc->pm);
     ich9_pm_add_properties(obj, &lpc->pm);
 }
 
-- 
2.43.0



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

* [PATCH v2 07/12] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (5 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 06/12] hw/acpi/ich9.c: move initial property values into ich9_reset_properties() Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 08/12] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, qemu-devel, qemu-arm

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

diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index edf9783ec8..f89fadb032 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);
 }
@@ -880,6 +867,40 @@ static void build_ich9_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
     qbus_build_aml(bus, scope);
 }
 
+static void ich9_lpc_get_sci_int(Object *obj, Visitor *v,
+                                 const char *name, void *opaque,
+                                 Error **errp)
+{
+    ICH9LPCState *lpc = ICH9_LPC_DEVICE(obj);
+    uint8_t sci_gsi = lpc->sci_gsi;
+
+    visit_type_uint8(v, name, &sci_gsi, errp);
+}
+
+static void ich9_lpc_get_smi_negotiated_feat(Object *obj, Visitor *v,
+                                             const char *name, void *opaque,
+                                             Error **errp)
+{
+    ICH9LPCState *lpc = ICH9_LPC_DEVICE(obj);
+    uint64_t smi_negotiated_features = lpc->smi_negotiated_features;
+
+    visit_type_uint64(v, name, &smi_negotiated_features, errp);
+}
+
+static void ich9_lpc_set_smi_negotiated_feat(Object *obj, Visitor *v,
+                                             const char *name, void *opaque,
+                                             Error **errp)
+{
+    ICH9LPCState *lpc = ICH9_LPC_DEVICE(obj);
+    uint64_t smi_negotiated_features = lpc->smi_negotiated_features;
+
+    if (!visit_type_uint64(v, name,  &smi_negotiated_features, errp)) {
+        return;
+    }
+
+    lpc->smi_negotiated_features = smi_negotiated_features;
+}
+
 static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
@@ -888,6 +909,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 +936,24 @@ 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(klass, ACPI_PM_PROP_SCI_INT, "uint8",
+                              ich9_lpc_get_sci_int,
+                              NULL,
+                              NULL, NULL);
+    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);
+    object_class_property_add(klass, ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP,
+                              "uint64",
+                              ich9_lpc_get_smi_negotiated_feat,
+                              ich9_lpc_set_smi_negotiated_feat,
+                              NULL, NULL);
 }
 
 static const TypeInfo ich9_lpc_info = {
-- 
2.43.0



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

* [PATCH v2 08/12] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (6 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 07/12] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-06  7:07   ` Philippe Mathieu-Daudé
  2026-07-03 13:53 ` [PATCH v2 09/12] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, 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>
---
 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] 23+ messages in thread

* [PATCH v2 09/12] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (7 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 08/12] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 10/12] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP " Mark Cave-Ayland
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, qemu-devel, qemu-arm

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 include/hw/acpi/ich9.h |  2 +-
 hw/acpi/ich9.c         | 62 ++++++++++++++++++++++++------------------
 hw/isa/lpc_ich9.c      |  2 +-
 3 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 30990fcef5..3180e98c93 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -83,7 +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_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..cf36dfc3d8 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -400,36 +400,44 @@ void ich9_pm_reset_properties(ICH9LPCPMRegs *pm)
     pm->enable_tco = true;
 }
 
-void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
+void ich9_pm_add_class_properties(ObjectClass *oc)
 {
     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,
-                             (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_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,
-                                  &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);
+    object_class_property_add_uint32_ptr(oc, ACPI_PM_PROP_PM_IO_BASE,
+                                         offsetof(ICH9LPCState, pm.pm_io_base),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_property_add_link(oc, "bus",
+                                   TYPE_PCI_BUS,
+                                   offsetof(ICH9LPCState,
+                                            pm.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_static_property_add_uint32_ptr(oc,
+                                                ACPI_PM_PROP_GPE0_BLK_LEN,
+                                                &gpe0_len,
+                                                OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S3_DISABLED,
+                                        offsetof(ICH9LPCState, pm.disable_s3),
+                                        OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S4_DISABLED,
+                                        offsetof(ICH9LPCState, pm.disable_s4),
+                                        OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_uint8_ptr(oc, ACPI_PM_PROP_S4_VAL,
+                                        offsetof(ICH9LPCState, pm.s4_val),
+                                        OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_bool(oc, ACPI_PM_PROP_TCO_ENABLED,
+                                   ich9_pm_get_enable_tco,
+                                   ich9_pm_set_enable_tco);
+    object_class_property_add_bool(oc, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE,
+                                   ich9_pm_get_acpi_pci_hotplug,
+                                   ich9_pm_set_acpi_pci_hotplug);
+    object_class_property_add_bool(oc, "x-keep-pci-slot-hpc",
+                                   ich9_pm_get_keep_pci_slot_hpc,
+                                   ich9_pm_set_keep_pci_slot_hpc);
 }
 
 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 f89fadb032..8e226581be 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)
@@ -954,6 +953,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
                               ich9_lpc_get_smi_negotiated_feat,
                               ich9_lpc_set_smi_negotiated_feat,
                               NULL, NULL);
+    ich9_pm_add_class_properties(klass);
 }
 
 static const TypeInfo ich9_lpc_info = {
-- 
2.43.0



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

* [PATCH v2 10/12] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (8 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 09/12] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 11/12] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 12/12] hw/acpi/piix4.c: convert object props in PIIX4_PM to class props Mark Cave-Ayland
  11 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, 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>
---
 hw/acpi/generic_event_device.c | 10 ++++++++++
 hw/acpi/ich9.c                 |  8 ++++++++
 hw/acpi/pcihp.c                |  5 -----
 hw/acpi/piix4.c                |  9 +++++++++
 4 files changed, 27 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 cf36dfc3d8..0b295cbe5b 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -438,6 +438,14 @@ void ich9_pm_add_class_properties(ObjectClass *oc)
     object_class_property_add_bool(oc, "x-keep-pci-slot-hpc",
                                    ich9_pm_get_keep_pci_slot_hpc,
                                    ich9_pm_set_keep_pci_slot_hpc);
+    object_class_property_add_uint16_ptr(oc, ACPI_PCIHP_IO_BASE_PROP,
+                                         offsetof(ICH9LPCState,
+                                                  pm.acpi_pci_hotplug.io_base),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint16_ptr(oc, ACPI_PCIHP_IO_LEN_PROP,
+                                         offsetof(ICH9LPCState,
+                                                  pm.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] 23+ messages in thread

* [PATCH v2 11/12] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (9 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 10/12] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP " Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  2026-07-03 13:53 ` [PATCH v2 12/12] hw/acpi/piix4.c: convert object props in PIIX4_PM to class props Mark Cave-Ayland
  11 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, 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 int32_t with a default value of -1 indicating that the property
has not been set.

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 include/hw/pci/pci_bus.h |  2 ++
 hw/acpi/pci-bridge.c     |  9 ++++++++-
 hw/acpi/pcihp.c          | 32 +++++++++++++++-----------------
 hw/arm/virt-acpi-build.c |  7 ++++++-
 hw/i386/acpi-build.c     |  7 ++++++-
 hw/pci/pci.c             | 32 ++++++++++++++++++++++++++++++++
 6 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index c738446788..186a157dbc 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;
+
+    int32_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..9af939363c 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;
+        int32_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_int(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
+                                       &local_err);
+
+        if (local_err == NULL && bsel >= 0) {
             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..31822f6310 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -58,8 +58,8 @@ 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,
-                                             &local_err);
+    int32_t bsel = object_property_get_int(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+                                           &local_err);
 
     if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
         error_free(local_err);
@@ -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_int(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++;
+        int32_t bsel_val = qnum_get_int(qobject_to(QNum, bsel));
+
+        if (bsel_val >= 0) {
+            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));
+    int32_t bsel_val = qnum_get_int(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 99490aa7b1..f6e1776ad0 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -1181,6 +1181,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;
+    int32_t bsel;
 
     acpi_table_begin(&table, table_data);
     dsdt = init_aml_allocator();
@@ -1243,9 +1245,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_int(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL,
+                                   &local_err);
+    if (local_err == NULL && bsel >= 0) {
         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 2ee061558c..de196f2f4a 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1197,15 +1197,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;
+        int32_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_int(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL,
+                                           &local_err);
+            if (local_err == NULL && bsel >= 0) {
                 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..1521f37658 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 = -1;
+
     vmstate_register_any(NULL, &vmstate_pcibus, bus);
 }
 
@@ -283,6 +286,30 @@ static GByteArray *pci_bus_fw_cfg_gen_data(Object *obj, Error **errp)
     return byte_array;
 }
 
+static void pci_bus_get_acpi_pcihp_bsel_val(Object *obj, Visitor *v,
+                                            const char *name, void *opaque,
+                                            Error **errp)
+{
+    PCIBus *bus = PCI_BUS(obj);
+    int32_t bsel_val = bus->acpi_pcihp_bsel_val;
+
+    visit_type_int32(v, name, &bsel_val, errp);
+}
+
+static void pci_bus_set_acpi_pcihp_bsel_val(Object *obj, Visitor *v,
+                                            const char *name, void *opaque,
+                                            Error **errp)
+{
+    PCIBus *bus = PCI_BUS(obj);
+    int32_t bsel_val = bus->acpi_pcihp_bsel_val;
+
+    if (!visit_type_int32(v, name,  &bsel_val, errp)) {
+        return;
+    }
+
+    bus->acpi_pcihp_bsel_val = bsel_val;
+}
+
 static void pci_bus_class_init(ObjectClass *klass, const void *data)
 {
     BusClass *k = BUS_CLASS(klass);
@@ -302,6 +329,11 @@ 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(klass, ACPI_PCIHP_PROP_BSEL, "int32",
+                              pci_bus_get_acpi_pcihp_bsel_val,
+                              pci_bus_set_acpi_pcihp_bsel_val,
+                              NULL, NULL);
 }
 
 static const TypeInfo pci_bus_info = {
-- 
2.43.0



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

* [PATCH v2 12/12] hw/acpi/piix4.c: convert object props in PIIX4_PM to class props
  2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
                   ` (10 preceding siblings ...)
  2026-07-03 13:53 ` [PATCH v2 11/12] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
@ 2026-07-03 13:53 ` Mark Cave-Ayland
  11 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-03 13:53 UTC (permalink / raw)
  To: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, berrange, qemu-devel, qemu-arm

Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
---
 hw/acpi/piix4.c | 42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 1d209ac96d..52bd61667f 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -405,7 +405,7 @@ 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)
+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 +413,30 @@ 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);
+    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)
@@ -480,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)
@@ -616,6 +626,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] 23+ messages in thread

* Re: [PATCH v2 06/12] hw/acpi/ich9.c: move initial property values into ich9_reset_properties()
  2026-07-03 13:53 ` [PATCH v2 06/12] hw/acpi/ich9.c: move initial property values into ich9_reset_properties() Mark Cave-Ayland
@ 2026-07-06  7:06   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-06  7:06 UTC (permalink / raw)
  To: Mark Cave-Ayland, mst, imammedo, anisinha, philmd, aurelien,
	peter.maydell, pbonzini, richard.henderson, berrange, qemu-devel,
	qemu-arm

On 3/7/26 15:53, Mark Cave-Ayland wrote:
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
>   include/hw/acpi/ich9.h | 2 ++
>   hw/acpi/ich9.c         | 8 ++++++--
>   hw/isa/lpc_ich9.c      | 1 +
>   3 files changed, 9 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>


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

* Re: [PATCH v2 08/12] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop
  2026-07-03 13:53 ` [PATCH v2 08/12] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
@ 2026-07-06  7:07   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-07-06  7:07 UTC (permalink / raw)
  To: Mark Cave-Ayland, mst, imammedo, anisinha, philmd, aurelien,
	peter.maydell, pbonzini, richard.henderson, berrange, qemu-devel,
	qemu-arm

On 3/7/26 15:53, 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>
> ---
>   hw/acpi/ich9.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>


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

* Re: [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr()
  2026-07-03 13:53 ` [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr() Mark Cave-Ayland
@ 2026-07-07 12:05   ` Daniel P. Berrangé
  2026-07-07 13:08     ` Mark Cave-Ayland
  0 siblings, 1 reply; 23+ messages in thread
From: Daniel P. Berrangé @ 2026-07-07 12:05 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, qemu-devel, qemu-arm

On Fri, Jul 03, 2026 at 02:53:03PM +0100, Mark Cave-Ayland wrote:
> This more accurately reflects that these properties are held within the class and
> not the object.
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
>  include/qom/object.h |  8 ++++----
>  hw/riscv/spike.c     |  5 +++--
>  qom/object.c         | 28 ++++++++++++++++------------
>  3 files changed, 23 insertions(+), 18 deletions(-)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 11f55613fc..89c23d45ab 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1956,7 +1956,7 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
>                                                const uint8_t *v,
>                                                ObjectPropertyFlags flags);
>  
> -ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
> +ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
>                                           const char *name,
>                                           const uint8_t *v,
>                                           ObjectPropertyFlags flags);
> @@ -1977,7 +1977,7 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
>                                      const uint16_t *v,
>                                      ObjectPropertyFlags flags);
>  
> -ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
> +ObjectProperty *object_class_static_property_add_uint16_ptr(ObjectClass *klass,
>                                            const char *name,
>                                            const uint16_t *v,
>                                            ObjectPropertyFlags flags);
> @@ -1998,7 +1998,7 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
>                                      const uint32_t *v,
>                                      ObjectPropertyFlags flags);
>  
> -ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
> +ObjectProperty *object_class_static_property_add_uint32_ptr(ObjectClass *klass,
>                                            const char *name,
>                                            const uint32_t *v,
>                                            ObjectPropertyFlags flags);
> @@ -2019,7 +2019,7 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
>                                      const uint64_t *v,
>                                      ObjectPropertyFlags flags);
>  
> -ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
> +ObjectProperty *object_class_static_property_add_uint64_ptr(ObjectClass *klass,
>                                            const char *name,
>                                            const uint64_t *v,
>                                            ObjectPropertyFlags flags);
> diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
> index 9fde0faf39..630b65f569 100644
> --- a/hw/riscv/spike.c
> +++ b/hw/riscv/spike.c
> @@ -278,8 +278,9 @@ static void spike_machine_class_init(ObjectClass *oc, const void *data)
>      object_class_property_add_str(oc, "signature", NULL, spike_set_signature);
>      object_class_property_set_description(oc, "signature",
>                                            "File to write ACT test signature");
> -    object_class_property_add_uint8_ptr(oc, "signature-granularity",
> -                                        &line_size, OBJ_PROP_FLAG_WRITE);
> +    object_class_static_property_add_uint8_ptr(oc, "signature-granularity",
> +                                               &line_size,
> +                                               OBJ_PROP_FLAG_WRITE);

When we have just one use of these "static property" API in the code base,
I wonder if we genuinely need these APIs ?

I wonder why "line_size" isn't merely a field in the machine class ?
External code ought to be able to fetch the current machine and read
a line_size struct field, surely ?


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] 23+ messages in thread

* Re: [PATCH v2 02/12] qom/object.c: add object_class_property_add_uint8_ptr()
  2026-07-03 13:53 ` [PATCH v2 02/12] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
@ 2026-07-07 12:17   ` Daniel P. Berrangé
  2026-07-07 13:13     ` Mark Cave-Ayland
  0 siblings, 1 reply; 23+ messages in thread
From: Daniel P. Berrangé @ 2026-07-07 12:17 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, qemu-devel, qemu-arm

On Fri, Jul 03, 2026 at 02:53:04PM +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().
> 
> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> ---
>  include/qom/object.h |  5 +++++
>  qom/object.c         | 52 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 57 insertions(+)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 89c23d45ab..a55f9d0e97 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -1956,6 +1956,11 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
>                                                const uint8_t *v,
>                                                ObjectPropertyFlags flags);
>  
> +ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
> +                                                    const char *name,
> +                                                    ptrdiff_t v,
> +                                                    ObjectPropertyFlags flags);
> +
>  ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
>                                           const char *name,
>                                           const uint8_t *v,
> diff --git a/qom/object.c b/qom/object.c
> index d10bf848c0..263c313cd2 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -2741,6 +2741,38 @@ static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
>      *field = value;
>  }
>  
> +static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
> +{
> +    void *ptr = obj;
> +    ptr += offset;
> +
> +    return ptr;
> +}

Perhaps just

 #define FIELD(obj, offset) ((void *)obj+(ptrdiff_t)offset)

> +
> +static void property_class_get_uint8_ptr(Object *obj, Visitor *v,
> +                                         const char *name,
> +                                         void *opaque, Error **errp)
> +{
> +    uint8_t value = *(uint8_t *)object_class_prop_ptr(obj,
> +                                                      (ptrdiff_t)opaque);

Do we need this intermediate instead of now

> +    visit_type_uint8(v, name, &value, errp);

  visit_type_uint8(v, name, FIELD(obj, opaque), errp);


> +}
> +
> +static void property_class_set_uint8_ptr(Object *obj, Visitor *v,
> +                                         const char *name,
> +                                         void *opaque, Error **errp)
> +{
> +    uint8_t *field = (uint8_t *)object_class_prop_ptr(obj,
> +                                                      (ptrdiff_t)opaque);
> +    uint8_t value;
> +
> +    if (!visit_type_uint8(v, name, &value, errp)) {
> +        return;
> +    }
> +
> +    *field = value;

Instead of all this is it sufficient to do:

   visit_type_uint8(v, name, FIELD(obj, opaque), errp);


Also, since we'll be using this pattern for int8, int16, int32,
and many more, perhaps we could define a macro that can expand
to the getter/setter impl for any scalar type. so we can do

  DEFINE_SCALAR_PROP_CALLBACKS(uint8);
  DEFINE_SCALAR_PROP_CALLBACKS(uint16);
  DEFINE_SCALAR_PROP_CALLBACKS(uint32);
  DEFINE_SCALAR_PROP_CALLBACKS(uint64);
  DEFINE_SCALAR_PROP_CALLBACKS(bool);
  ..etc..

> +}
> +
>  ObjectProperty *
>  object_property_add_uint8_ptr(Object *obj, const char *name,
>                                const uint8_t *v,

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] 23+ messages in thread

* Re: [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr()
  2026-07-07 12:05   ` Daniel P. Berrangé
@ 2026-07-07 13:08     ` Mark Cave-Ayland
  2026-07-07 13:19       ` Daniel P. Berrangé
  2026-07-07 14:19       ` Peter Maydell
  0 siblings, 2 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-07 13:08 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, qemu-devel, qemu-arm

On 07/07/2026 13:05, Daniel P. Berrangé wrote:

> On Fri, Jul 03, 2026 at 02:53:03PM +0100, Mark Cave-Ayland wrote:
>> This more accurately reflects that these properties are held within the class and
>> not the object.
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>> ---
>>   include/qom/object.h |  8 ++++----
>>   hw/riscv/spike.c     |  5 +++--
>>   qom/object.c         | 28 ++++++++++++++++------------
>>   3 files changed, 23 insertions(+), 18 deletions(-)
>>
>> diff --git a/include/qom/object.h b/include/qom/object.h
>> index 11f55613fc..89c23d45ab 100644
>> --- a/include/qom/object.h
>> +++ b/include/qom/object.h
>> @@ -1956,7 +1956,7 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
>>                                                 const uint8_t *v,
>>                                                 ObjectPropertyFlags flags);
>>   
>> -ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
>> +ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
>>                                            const char *name,
>>                                            const uint8_t *v,
>>                                            ObjectPropertyFlags flags);
>> @@ -1977,7 +1977,7 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
>>                                       const uint16_t *v,
>>                                       ObjectPropertyFlags flags);
>>   
>> -ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
>> +ObjectProperty *object_class_static_property_add_uint16_ptr(ObjectClass *klass,
>>                                             const char *name,
>>                                             const uint16_t *v,
>>                                             ObjectPropertyFlags flags);
>> @@ -1998,7 +1998,7 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
>>                                       const uint32_t *v,
>>                                       ObjectPropertyFlags flags);
>>   
>> -ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
>> +ObjectProperty *object_class_static_property_add_uint32_ptr(ObjectClass *klass,
>>                                             const char *name,
>>                                             const uint32_t *v,
>>                                             ObjectPropertyFlags flags);
>> @@ -2019,7 +2019,7 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
>>                                       const uint64_t *v,
>>                                       ObjectPropertyFlags flags);
>>   
>> -ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
>> +ObjectProperty *object_class_static_property_add_uint64_ptr(ObjectClass *klass,
>>                                             const char *name,
>>                                             const uint64_t *v,
>>                                             ObjectPropertyFlags flags);
>> diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
>> index 9fde0faf39..630b65f569 100644
>> --- a/hw/riscv/spike.c
>> +++ b/hw/riscv/spike.c
>> @@ -278,8 +278,9 @@ static void spike_machine_class_init(ObjectClass *oc, const void *data)
>>       object_class_property_add_str(oc, "signature", NULL, spike_set_signature);
>>       object_class_property_set_description(oc, "signature",
>>                                             "File to write ACT test signature");
>> -    object_class_property_add_uint8_ptr(oc, "signature-granularity",
>> -                                        &line_size, OBJ_PROP_FLAG_WRITE);
>> +    object_class_static_property_add_uint8_ptr(oc, "signature-granularity",
>> +                                               &line_size,
>> +                                               OBJ_PROP_FLAG_WRITE);
> 
> When we have just one use of these "static property" API in the code base,
> I wonder if we genuinely need these APIs ?

There are actually more uses in hw/acpi later on in the series: see 
patches 7, 9 and 12.

> I wonder why "line_size" isn't merely a field in the machine class ?
> External code ought to be able to fetch the current machine and read
> a line_size struct field, surely ?

It certainly looks odd from here: one of things I wanted to discuss on 
the call was how to approach the conversion.

My current thinking is that the aim should be simply to convert 
everything as-is, and avoid attempting any refactorings or converting to 
a device class prop via device_class_set_props() if possible. Otherwise 
anyone attempting conversions will get stuck in the details of the 
individual devices, which I would argue is more the remit of maintainers.


ATB,

Mark.



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

* Re: [PATCH v2 02/12] qom/object.c: add object_class_property_add_uint8_ptr()
  2026-07-07 12:17   ` Daniel P. Berrangé
@ 2026-07-07 13:13     ` Mark Cave-Ayland
  2026-07-07 13:20       ` Daniel P. Berrangé
  0 siblings, 1 reply; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-07 13:13 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, qemu-devel, qemu-arm

On 07/07/2026 13:17, Daniel P. Berrangé wrote:

> On Fri, Jul 03, 2026 at 02:53:04PM +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().
>>
>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>> ---
>>   include/qom/object.h |  5 +++++
>>   qom/object.c         | 52 ++++++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 57 insertions(+)
>>
>> diff --git a/include/qom/object.h b/include/qom/object.h
>> index 89c23d45ab..a55f9d0e97 100644
>> --- a/include/qom/object.h
>> +++ b/include/qom/object.h
>> @@ -1956,6 +1956,11 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
>>                                                 const uint8_t *v,
>>                                                 ObjectPropertyFlags flags);
>>   
>> +ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
>> +                                                    const char *name,
>> +                                                    ptrdiff_t v,
>> +                                                    ObjectPropertyFlags flags);
>> +
>>   ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
>>                                            const char *name,
>>                                            const uint8_t *v,
>> diff --git a/qom/object.c b/qom/object.c
>> index d10bf848c0..263c313cd2 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -2741,6 +2741,38 @@ static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
>>       *field = value;
>>   }
>>   
>> +static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
>> +{
>> +    void *ptr = obj;
>> +    ptr += offset;
>> +
>> +    return ptr;
>> +}
> 
> Perhaps just
> 
>   #define FIELD(obj, offset) ((void *)obj+(ptrdiff_t)offset)

That could work.

>> +
>> +static void property_class_get_uint8_ptr(Object *obj, Visitor *v,
>> +                                         const char *name,
>> +                                         void *opaque, Error **errp)
>> +{
>> +    uint8_t value = *(uint8_t *)object_class_prop_ptr(obj,
>> +                                                      (ptrdiff_t)opaque);
> 
> Do we need this intermediate instead of now
> 
>> +    visit_type_uint8(v, name, &value, errp);
> 
>    visit_type_uint8(v, name, FIELD(obj, opaque), errp);

Yes, I think that would be possible. I shall give it a test and report back.

>> +}
>> +
>> +static void property_class_set_uint8_ptr(Object *obj, Visitor *v,
>> +                                         const char *name,
>> +                                         void *opaque, Error **errp)
>> +{
>> +    uint8_t *field = (uint8_t *)object_class_prop_ptr(obj,
>> +                                                      (ptrdiff_t)opaque);
>> +    uint8_t value;
>> +
>> +    if (!visit_type_uint8(v, name, &value, errp)) {
>> +        return;
>> +    }
>> +
>> +    *field = value;
> 
> Instead of all this is it sufficient to do:
> 
>     visit_type_uint8(v, name, FIELD(obj, opaque), errp);
> 
> 
> Also, since we'll be using this pattern for int8, int16, int32,
> and many more, perhaps we could define a macro that can expand
> to the getter/setter impl for any scalar type. so we can do
> 
>    DEFINE_SCALAR_PROP_CALLBACKS(uint8);
>    DEFINE_SCALAR_PROP_CALLBACKS(uint16);
>    DEFINE_SCALAR_PROP_CALLBACKS(uint32);
>    DEFINE_SCALAR_PROP_CALLBACKS(uint64);
>    DEFINE_SCALAR_PROP_CALLBACKS(bool);
>    ..etc..

That is something else that is possible: I've purposely avoided doing 
this since it's not a pattern already in use within object.c. Do you 
think this is worth doing as a separate exercise first?

>> +}
>> +
>>   ObjectProperty *
>>   object_property_add_uint8_ptr(Object *obj, const char *name,
>>                                 const uint8_t *v,


ATB,

Mark.



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

* Re: [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr()
  2026-07-07 13:08     ` Mark Cave-Ayland
@ 2026-07-07 13:19       ` Daniel P. Berrangé
  2026-07-07 14:19       ` Peter Maydell
  1 sibling, 0 replies; 23+ messages in thread
From: Daniel P. Berrangé @ 2026-07-07 13:19 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, qemu-devel, qemu-arm

On Tue, Jul 07, 2026 at 02:08:25PM +0100, Mark Cave-Ayland wrote:
> On 07/07/2026 13:05, Daniel P. Berrangé wrote:
> 
> > On Fri, Jul 03, 2026 at 02:53:03PM +0100, Mark Cave-Ayland wrote:
> > > This more accurately reflects that these properties are held within the class and
> > > not the object.
> > > 
> > > Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> > > ---
> > >   include/qom/object.h |  8 ++++----
> > >   hw/riscv/spike.c     |  5 +++--
> > >   qom/object.c         | 28 ++++++++++++++++------------
> > >   3 files changed, 23 insertions(+), 18 deletions(-)
> > > 
> > > diff --git a/include/qom/object.h b/include/qom/object.h
> > > index 11f55613fc..89c23d45ab 100644
> > > --- a/include/qom/object.h
> > > +++ b/include/qom/object.h
> > > @@ -1956,7 +1956,7 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
> > >                                                 const uint8_t *v,
> > >                                                 ObjectPropertyFlags flags);
> > > -ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
> > > +ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
> > >                                            const char *name,
> > >                                            const uint8_t *v,
> > >                                            ObjectPropertyFlags flags);
> > > @@ -1977,7 +1977,7 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
> > >                                       const uint16_t *v,
> > >                                       ObjectPropertyFlags flags);
> > > -ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
> > > +ObjectProperty *object_class_static_property_add_uint16_ptr(ObjectClass *klass,
> > >                                             const char *name,
> > >                                             const uint16_t *v,
> > >                                             ObjectPropertyFlags flags);
> > > @@ -1998,7 +1998,7 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
> > >                                       const uint32_t *v,
> > >                                       ObjectPropertyFlags flags);
> > > -ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
> > > +ObjectProperty *object_class_static_property_add_uint32_ptr(ObjectClass *klass,
> > >                                             const char *name,
> > >                                             const uint32_t *v,
> > >                                             ObjectPropertyFlags flags);
> > > @@ -2019,7 +2019,7 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
> > >                                       const uint64_t *v,
> > >                                       ObjectPropertyFlags flags);
> > > -ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
> > > +ObjectProperty *object_class_static_property_add_uint64_ptr(ObjectClass *klass,
> > >                                             const char *name,
> > >                                             const uint64_t *v,
> > >                                             ObjectPropertyFlags flags);
> > > diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
> > > index 9fde0faf39..630b65f569 100644
> > > --- a/hw/riscv/spike.c
> > > +++ b/hw/riscv/spike.c
> > > @@ -278,8 +278,9 @@ static void spike_machine_class_init(ObjectClass *oc, const void *data)
> > >       object_class_property_add_str(oc, "signature", NULL, spike_set_signature);
> > >       object_class_property_set_description(oc, "signature",
> > >                                             "File to write ACT test signature");
> > > -    object_class_property_add_uint8_ptr(oc, "signature-granularity",
> > > -                                        &line_size, OBJ_PROP_FLAG_WRITE);
> > > +    object_class_static_property_add_uint8_ptr(oc, "signature-granularity",
> > > +                                               &line_size,
> > > +                                               OBJ_PROP_FLAG_WRITE);
> > 
> > When we have just one use of these "static property" API in the code base,
> > I wonder if we genuinely need these APIs ?
> 
> There are actually more uses in hw/acpi later on in the series: see patches
> 7, 9 and 12.

Ok, I missed that, only looking an existnig code.

> > I wonder why "line_size" isn't merely a field in the machine class ?
> > External code ought to be able to fetch the current machine and read
> > a line_size struct field, surely ?
> 
> It certainly looks odd from here: one of things I wanted to discuss on the
> call was how to approach the conversion.
> 
> My current thinking is that the aim should be simply to convert everything
> as-is, and avoid attempting any refactorings or converting to a device class
> prop via device_class_set_props() if possible. Otherwise anyone attempting
> conversions will get stuck in the details of the individual devices, which I
> would argue is more the remit of maintainers.

Yeah, ok, that is probably a wise approach to minimizing complexity.

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] 23+ messages in thread

* Re: [PATCH v2 02/12] qom/object.c: add object_class_property_add_uint8_ptr()
  2026-07-07 13:13     ` Mark Cave-Ayland
@ 2026-07-07 13:20       ` Daniel P. Berrangé
  0 siblings, 0 replies; 23+ messages in thread
From: Daniel P. Berrangé @ 2026-07-07 13:20 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: mst, imammedo, anisinha, philmd, aurelien, peter.maydell,
	pbonzini, richard.henderson, qemu-devel, qemu-arm

On Tue, Jul 07, 2026 at 02:13:24PM +0100, Mark Cave-Ayland wrote:
> On 07/07/2026 13:17, Daniel P. Berrangé wrote:
> 
> > On Fri, Jul 03, 2026 at 02:53:04PM +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().
> > > 
> > > Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
> > > ---
> > >   include/qom/object.h |  5 +++++
> > >   qom/object.c         | 52 ++++++++++++++++++++++++++++++++++++++++++++
> > >   2 files changed, 57 insertions(+)
> > > 
> > > diff --git a/include/qom/object.h b/include/qom/object.h
> > > index 89c23d45ab..a55f9d0e97 100644
> > > --- a/include/qom/object.h
> > > +++ b/include/qom/object.h
> > > @@ -1956,6 +1956,11 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
> > >                                                 const uint8_t *v,
> > >                                                 ObjectPropertyFlags flags);
> > > +ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
> > > +                                                    const char *name,
> > > +                                                    ptrdiff_t v,
> > > +                                                    ObjectPropertyFlags flags);
> > > +
> > >   ObjectProperty *object_class_static_property_add_uint8_ptr(ObjectClass *klass,
> > >                                            const char *name,
> > >                                            const uint8_t *v,
> > > diff --git a/qom/object.c b/qom/object.c
> > > index d10bf848c0..263c313cd2 100644
> > > --- a/qom/object.c
> > > +++ b/qom/object.c
> > > @@ -2741,6 +2741,38 @@ static void property_set_uint64_ptr(Object *obj, Visitor *v, const char *name,
> > >       *field = value;
> > >   }
> > > +static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
> > > +{
> > > +    void *ptr = obj;
> > > +    ptr += offset;
> > > +
> > > +    return ptr;
> > > +}
> > 
> > Perhaps just
> > 
> >   #define FIELD(obj, offset) ((void *)obj+(ptrdiff_t)offset)
> 
> That could work.
> 
> > > +
> > > +static void property_class_get_uint8_ptr(Object *obj, Visitor *v,
> > > +                                         const char *name,
> > > +                                         void *opaque, Error **errp)
> > > +{
> > > +    uint8_t value = *(uint8_t *)object_class_prop_ptr(obj,
> > > +                                                      (ptrdiff_t)opaque);
> > 
> > Do we need this intermediate instead of now
> > 
> > > +    visit_type_uint8(v, name, &value, errp);
> > 
> >    visit_type_uint8(v, name, FIELD(obj, opaque), errp);
> 
> Yes, I think that would be possible. I shall give it a test and report back.
> 
> > > +}
> > > +
> > > +static void property_class_set_uint8_ptr(Object *obj, Visitor *v,
> > > +                                         const char *name,
> > > +                                         void *opaque, Error **errp)
> > > +{
> > > +    uint8_t *field = (uint8_t *)object_class_prop_ptr(obj,
> > > +                                                      (ptrdiff_t)opaque);
> > > +    uint8_t value;
> > > +
> > > +    if (!visit_type_uint8(v, name, &value, errp)) {
> > > +        return;
> > > +    }
> > > +
> > > +    *field = value;
> > 
> > Instead of all this is it sufficient to do:
> > 
> >     visit_type_uint8(v, name, FIELD(obj, opaque), errp);
> > 
> > 
> > Also, since we'll be using this pattern for int8, int16, int32,
> > and many more, perhaps we could define a macro that can expand
> > to the getter/setter impl for any scalar type. so we can do
> > 
> >    DEFINE_SCALAR_PROP_CALLBACKS(uint8);
> >    DEFINE_SCALAR_PROP_CALLBACKS(uint16);
> >    DEFINE_SCALAR_PROP_CALLBACKS(uint32);
> >    DEFINE_SCALAR_PROP_CALLBACKS(uint64);
> >    DEFINE_SCALAR_PROP_CALLBACKS(bool);
> >    ..etc..
> 
> That is something else that is possible: I've purposely avoided doing this
> since it's not a pattern already in use within object.c. Do you think this
> is worth doing as a separate exercise first?

Yeah, if we can convert existing scalar setters/getters that would be
nice. Otherwise we're piling up a huge amount of repetitive code
for dealing with every property type :-(

> 
> > > +}
> > > +
> > >   ObjectProperty *
> > >   object_property_add_uint8_ptr(Object *obj, const char *name,
> > >                                 const uint8_t *v,
> 
> 
> ATB,
> 
> Mark.
> 

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] 23+ messages in thread

* Re: [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr()
  2026-07-07 13:08     ` Mark Cave-Ayland
  2026-07-07 13:19       ` Daniel P. Berrangé
@ 2026-07-07 14:19       ` Peter Maydell
  2026-07-08  9:24         ` Mark Cave-Ayland
  1 sibling, 1 reply; 23+ messages in thread
From: Peter Maydell @ 2026-07-07 14:19 UTC (permalink / raw)
  To: Mark Cave-Ayland
  Cc: Daniel P. Berrangé, mst, imammedo, anisinha, philmd,
	aurelien, pbonzini, richard.henderson, qemu-devel, qemu-arm

On Tue, 7 Jul 2026 at 14:08, Mark Cave-Ayland
<mark.caveayland@nutanix.com> wrote:
>
> On 07/07/2026 13:05, Daniel P. Berrangé wrote:
>
> > On Fri, Jul 03, 2026 at 02:53:03PM +0100, Mark Cave-Ayland wrote:
> > I wonder why "line_size" isn't merely a field in the machine class ?
> > External code ought to be able to fetch the current machine and read
> > a line_size struct field, surely ?
>
> It certainly looks odd from here: one of things I wanted to discuss on
> the call was how to approach the conversion.
>
> My current thinking is that the aim should be simply to convert
> everything as-is, and avoid attempting any refactorings or converting to
> a device class prop via device_class_set_props() if possible.

Oh yeah, I was going to ask how device_class_set_props() fits in here.
That is a much nicer API for the cases where it fits. I would like
any QOM-level API for setting up class properties to be as easy
and convenient to use as that is for the basic "there is a property
and it just sets a field in the object structure" common case.
(Obviously the more oddball stuff will need finer control.)

-- PMM


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

* Re: [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr()
  2026-07-07 14:19       ` Peter Maydell
@ 2026-07-08  9:24         ` Mark Cave-Ayland
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Cave-Ayland @ 2026-07-08  9:24 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Daniel P. Berrangé, mst, imammedo, anisinha, philmd,
	aurelien, pbonzini, richard.henderson, qemu-devel, qemu-arm

On 07/07/2026 15:19, Peter Maydell wrote:

> On Tue, 7 Jul 2026 at 14:08, Mark Cave-Ayland
> <mark.caveayland@nutanix.com> wrote:
>>
>> On 07/07/2026 13:05, Daniel P. Berrangé wrote:
>>
>>> On Fri, Jul 03, 2026 at 02:53:03PM +0100, Mark Cave-Ayland wrote:
>>> I wonder why "line_size" isn't merely a field in the machine class ?
>>> External code ought to be able to fetch the current machine and read
>>> a line_size struct field, surely ?
>>
>> It certainly looks odd from here: one of things I wanted to discuss on
>> the call was how to approach the conversion.
>>
>> My current thinking is that the aim should be simply to convert
>> everything as-is, and avoid attempting any refactorings or converting to
>> a device class prop via device_class_set_props() if possible.
> 
> Oh yeah, I was going to ask how device_class_set_props() fits in here.
> That is a much nicer API for the cases where it fits. I would like
> any QOM-level API for setting up class properties to be as easy
> and convenient to use as that is for the basic "there is a property
> and it just sets a field in the object structure" common case.
> (Obviously the more oddball stuff will need finer control.)

Having a look at these series, I think we can come up with some basic 
rules as to whether an object property could be promoted to a static 
Property:

- The QOM object in question must inherit from TYPE_DEVICE

- The getter and setter must only set/retrieve the value with no
   additional logic/constraints included

- The object property in question must not be a QOM array element i.e.
   a name of the form "foo[N]"

- The object property must be declared with OBJ_PROP_FLAG_READWRITE

- The object property must be defined directly in an QOM init()
   function, or a static function called from it

Does that seem reasonable?


ATB,

Mark.



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

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

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 13:53 [PATCH v2 00/12] hw/acpi: convert object props to class props Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 01/12] qom/object.c: rename object_class_property_uint*_ptr() to object_class_static_property_uint*_ptr() Mark Cave-Ayland
2026-07-07 12:05   ` Daniel P. Berrangé
2026-07-07 13:08     ` Mark Cave-Ayland
2026-07-07 13:19       ` Daniel P. Berrangé
2026-07-07 14:19       ` Peter Maydell
2026-07-08  9:24         ` Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 02/12] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
2026-07-07 12:17   ` Daniel P. Berrangé
2026-07-07 13:13     ` Mark Cave-Ayland
2026-07-07 13:20       ` Daniel P. Berrangé
2026-07-03 13:53 ` [PATCH v2 03/12] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 04/12] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 05/12] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 06/12] hw/acpi/ich9.c: move initial property values into ich9_reset_properties() Mark Cave-Ayland
2026-07-06  7:06   ` Philippe Mathieu-Daudé
2026-07-03 13:53 ` [PATCH v2 07/12] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 08/12] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
2026-07-06  7:07   ` Philippe Mathieu-Daudé
2026-07-03 13:53 ` [PATCH v2 09/12] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 10/12] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP " Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 11/12] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
2026-07-03 13:53 ` [PATCH v2 12/12] hw/acpi/piix4.c: convert object props in PIIX4_PM to class props Mark Cave-Ayland

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.