Skip to contentSkip to conversation

qom/qdev: associate properties with QAPI types fixups

PATCH In review Markus Armbruster 2 participants 8 messages Nov 5 – Nov 6 RISC-V

lore
Share & tools
lore
#0 lore raw

v2 cover qom/qdev: associate properties with QAPI types fixups

Marc-André missed one property, I lost two in my butchering of his work, and we both missed alias class properties. Not too bad for such a big series, I think.

Bonus improvement: child and link properties.

v2:
* New PATCH 5: child and link properties

Markus Armbruster (5):
target/riscv: Fix up PropertyInfo to set @qapi_type hw/gpio/pca9552: Fix @type of pca9552 property led<N>
hw: Fix up PropertyInfo to set @qapi_type
qom: Convert alias properties to QAPI-aware registration
qom: Convert child and link properties to QAPI-aware registration

 hw/gpio/pca9552.c  |  5 +++--
 hw/gpio/pca9554.c  |  5 +++--
 qom/object.c       | 13 +++++++------
 target/riscv/cpu.c |  1 +
 4 files changed, 14 insertions(+), 10 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH v2 1/5 target/riscv: Fix up PropertyInfo to set @qapi_type

When we recently updated PropertyInfo to set @qapi_type, we missed one. Update it now.

Fixes 07458a910f7b ("target/riscv: convert PropertyInfo definitions to use qapi_type")
---
 target/riscv/cpu.c | 1 +
 1 file changed, 1 insertion(+)
target/riscv/cpu.c +1 -0
index 362e561809..15c27f4ce4 100644
@@ -2075,6 +2075,7 @@ static void prop_vlen_get(Object *obj, Visitor *v, const char *name,
 
 static const PropertyInfo prop_vlen = {
     .type = "uint16",
+    .qapi_type = &uint16_type_info,
     .description = "vlen",
     .get = prop_vlen_get,
     .set = prop_vlen_set,
Signature · 1 line
2.55.0
#2 lore raw

PATCH v2 2/5 hw/gpio/pca9552: Fix @type of pca9552 property led<N>

In reply to Markus Armbruster

pca955x_initfn() passes @type "bool" to object_property_add(). The properties are actually string-typed: pca955x_get_led() and pca955x_set_led() use visit_type_str(). Pass "str" instead.

Fixes a90d8f84674d ("misc/pca9552: Add qom set and get")
---
 hw/gpio/pca9552.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/gpio/pca9552.c +1 -1
index 7e5fda4980..07ef0fb20b 100644
@@ -567,7 +567,7 @@ static void pca955x_initfn(Object *obj)
         if (k->has_led_support) {
             /* LED variant: expose the LED selector state as led%d. */
             name = g_strdup_printf("led%d", ix);
-            object_property_add(obj, name, "bool", NULL,
+            object_property_add(obj, name, "str", NULL,
                                 pca955x_get_led, pca955x_set_led, NULL, NULL);
         } else {
             /* GPIO variant: expose the pin logic level as pin%d. */
Signature · 1 line
2.55.0
#3 lore raw

PATCH v2 3/5 hw: Fix up PropertyInfo to set @qapi_type

In reply to Markus Armbruster

When we recently updated PropertyInfo to set @qapi_type, we missed a few. Update them now.

Fixes 04dc2fe4d463 ("hw: convert device-local PropertyInfo definitions to use qapi_type")
---
 hw/gpio/pca9552.c | 5 +++--
 hw/gpio/pca9554.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
hw/gpio/pca9552.c +3 -2
index 07ef0fb20b..90ccf5170e 100644
@@ -23,6 +23,7 @@
 #include "hw/core/irq.h"
 #include "migration/vmstate.h"
 #include "qapi/error.h"
+#include "qapi/qapi-builtin-type-infos.h"
 #include "qapi/visitor.h"
 #include "trace.h"
 #include "qom/object.h"
@@ -567,12 +568,12 @@ static void pca955x_initfn(Object *obj)
         if (k->has_led_support) {
             /* LED variant: expose the LED selector state as led%d. */
             name = g_strdup_printf("led%d", ix);
-            object_property_add(obj, name, "str", NULL,
+            object_property_add(obj, name, "str", &str_type_info,
                                 pca955x_get_led, pca955x_set_led, NULL, NULL);
         } else {
             /* GPIO variant: expose the pin logic level as pin%d. */
             name = g_strdup_printf("pin%d", ix);
-            object_property_add(obj, name, "str", NULL,
+            object_property_add(obj, name, "str", &str_type_info,
                                 pca955x_get_pin, pca955x_set_pin, NULL, NULL);
         }
         g_free(name);
hw/gpio/pca9554.c +3 -2
index 0dd063f93a..07bb00babf 100644
@@ -16,6 +16,7 @@
 #include "hw/core/irq.h"
 #include "migration/vmstate.h"
 #include "qapi/error.h"
+#include "qapi/qapi-builtin-type-infos.h"
 #include "qapi/visitor.h"
 #include "trace.h"
 #include "qom/object.h"
@@ -280,8 +281,8 @@ static void pca9554_initfn(Object *obj)
         char *name;
 
         name = g_strdup_printf("pin%d", pin);
-        object_property_add(obj, name, "str", NULL, pca9554_get_pin,
-                            pca9554_set_pin,
+        object_property_add(obj, name, "str", &str_type_info,
+                            pca9554_get_pin, pca9554_set_pin,
                             NULL, NULL);
         g_free(name);
     }
Signature · 1 line
2.55.0
#4 lore raw

PATCH v2 4/5 qom: Convert alias properties to QAPI-aware registration

In reply to Markus Armbruster

Pass the target property's QAPITypeInfo to object_class_property_add() / object_property_add().

Commit 53c674710b4 (qom: add qapi_type field to ObjectProperty) already monkey-patched it in object_property_add_alias(), but not in object_class_property_add_alias(). Delete that.

---
 qom/object.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
qom/object.c +4 -3
index cd0590c3fd..774a976c8b 100644
@@ -3099,13 +3099,13 @@ object_property_add_alias(Object *obj, const char *name,
     prop->target_name = g_strdup(target_name);
     prop->flags = 0;
 
-    op = object_property_add(obj, name, prop_type, NULL,
+    op = object_property_add(obj, name, prop_type,
+                             target_prop->qapi_type,
                              property_get_alias,
                              property_set_alias,
                              property_release_alias,
                              prop);
     op->resolve = property_resolve_alias;
-    op->qapi_type = target_prop->qapi_type;
     if (target_prop->defval) {
         op->defval = qobject_ref(target_prop->defval);
     }
@@ -3144,7 +3144,8 @@ object_class_property_add_alias(ObjectClass *klass, const char *name,
     prop->target_name = g_strdup(target_name);
     prop->flags = OBJ_PROP_ALIAS_CLASS;
 
-    op = object_class_property_add(klass, name, prop_type, NULL,
+    op = object_class_property_add(klass, name, prop_type,
+                                   target_prop->qapi_type,
                                    property_get_alias,
                                    property_set_alias,
                                    property_release_alias,
Signature · 1 line
2.55.0
#5 lore raw

PATCH v2 5/5 qom: Convert child and link properties to QAPI-aware registration

In reply to Markus Armbruster

Child and link properties get serialized as QOM paths, i.e. as strings. Use &str_type_info for them.

---
 qom/object.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
qom/object.c +3 -3
index 774a976c8b..9276b7a435 100644
@@ -1914,7 +1914,7 @@ object_property_try_add_child(Object *obj, const char *name,
 
     type = g_strdup_printf("child<%s>", object_get_typename(child));
 
-    op = object_property_try_add(obj, name, type, NULL,
+    op = object_property_try_add(obj, name, type, &str_type_info,
                                  object_get_child_property,
                                  NULL, object_finalize_child_property,
                                  child, errp);
@@ -2109,7 +2109,7 @@ object_add_link_prop(Object *obj, const char *name,
 
     full_type = g_strdup_printf("link<%s>", type);
 
-    op = object_property_add(obj, name, full_type, NULL,
+    op = object_property_add(obj, name, full_type, &str_type_info,
                              object_get_link_property,
                              check ? object_set_link_property : NULL,
                              object_release_link_property,
@@ -2146,7 +2146,7 @@ object_class_property_add_link(ObjectClass *oc,
 
     full_type = g_strdup_printf("link<%s>", type);
 
-    op = object_class_property_add(oc, name, full_type, NULL,
+    op = object_class_property_add(oc, name, full_type, &str_type_info,
                                    object_get_link_property,
                                    check ? object_set_link_property : NULL,
                                    object_release_link_property,
Signature · 1 line
2.55.0
Reviewed-by on v2 5/5
#6 lore raw

Re: [PATCH v2 5/5] qom: Convert child and link properties to QAPI-aware registration

Quoted 5 lines · Markus Armbruster

Child and link properties get serialized as QOM paths, i.e. as strings. Use &str_type_info for them.

Quoted 38 lines
---
 qom/object.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
qom/object.c +3 -4
index 774a976c8b..9276b7a435 100644
@@ -1914,7 +1914,7 @@ object_property_try_add_child(Object *obj, const char *name,
 
     type = g_strdup_printf("child<%s>", object_get_typename(child));
 
-    op = object_property_try_add(obj, name, type, NULL,
+    op = object_property_try_add(obj, name, type, &str_type_info,
                                  object_get_child_property,
                                  NULL, object_finalize_child_property,
                                  child, errp);
@@ -2109,7 +2109,7 @@ object_add_link_prop(Object *obj, const char *name,
 
     full_type = g_strdup_printf("link<%s>", type);
 
-    op = object_property_add(obj, name, full_type, NULL,
+    op = object_property_add(obj, name, full_type, &str_type_info,
                              object_get_link_property,
                              check ? object_set_link_property : NULL,
                              object_release_link_property,
@@ -2146,7 +2146,7 @@ object_class_property_add_link(ObjectClass *oc,
 
     full_type = g_strdup_printf("link<%s>", type);
 
-    op = object_class_property_add(oc, name, full_type, NULL,
+    op = object_class_property_add(oc, name, full_type, &str_type_info,
                                    object_get_link_property,
                                    check ? object_set_link_property : NULL,
                                    object_release_link_property,
--

2.55.0