[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 02/12] qom: Create object_configure()
From: |
Kevin Wolf |
Subject: |
[RFC PATCH 02/12] qom: Create object_configure() |
Date: |
Wed, 3 Nov 2021 18:29:52 +0100 |
This renames object_set_properties_from_qdict() to object_configure()
and removes the QDict parameter from it: With visit_next_struct_member()
it can set all properties without looking at the keys of the QDict.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qom/object_interfaces.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 3b61c195c5..f9f5608194 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -42,16 +42,15 @@ bool user_creatable_can_be_deleted(UserCreatable *uc)
}
}
-static void object_set_properties_from_qdict(Object *obj, const QDict *qdict,
- Visitor *v, Error **errp)
+static void object_configure(Object *obj, Visitor *v, Error **errp)
{
- const QDictEntry *e;
+ const char *key;
if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
return;
}
- for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
- if (!object_property_set(obj, e->key, v, errp)) {
+ while ((key = visit_next_struct_member(v))) {
+ if (!object_property_set(obj, key, v, errp)) {
goto out;
}
}
@@ -69,7 +68,7 @@ void object_set_properties_from_keyval(Object *obj, const
QDict *qdict,
} else {
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
}
- object_set_properties_from_qdict(obj, qdict, v, errp);
+ object_configure(obj, v, errp);
visit_free(v);
}
@@ -108,7 +107,7 @@ Object *user_creatable_add_type(const char *type, const
char *id,
assert(qdict);
obj = object_new(type);
- object_set_properties_from_qdict(obj, qdict, v, &local_err);
+ object_configure(obj, v, &local_err);
if (local_err) {
goto out;
}
--
2.31.1
- [RFC PATCH 00/12] QOM/QAPI integration part 1, Kevin Wolf, 2021/11/03
- [RFC PATCH 02/12] qom: Create object_configure(),
Kevin Wolf <=
- [RFC PATCH 01/12] qapi: Add visit_next_struct_member(), Kevin Wolf, 2021/11/03
- [RFC PATCH 03/12] qom: Make object_configure() public, Kevin Wolf, 2021/11/03
- [RFC PATCH 04/12] qom: Add instance_config() to TypeInfo, Kevin Wolf, 2021/11/03
- [RFC PATCH 05/12] rng-random: Implement .instance_config, Kevin Wolf, 2021/11/03
- [RFC PATCH 06/12] rng-backend: Implement .instance_config, Kevin Wolf, 2021/11/03
- [RFC PATCH 07/12] qapi: Allow defining QOM classes, Kevin Wolf, 2021/11/03
- [RFC PATCH 08/12] qapi: Create qom-config:... type for classes, Kevin Wolf, 2021/11/03