From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v3 05/10] qom: have object_set_props_keyval return bool
Date: Mon, 11 May 2026 15:14:15 +0100 [thread overview]
Message-ID: <20260511141420.229023-6-berrange@redhat.com> (raw)
In-Reply-To: <20260511141420.229023-1-berrange@redhat.com>
This matches the convention established by the object_set_props and
object_set_propv methods.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
include/qom/object.h | 4 +++-
qom/object_interfaces.c | 13 +++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index d841c338a2..20a04cc4a9 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -924,8 +924,10 @@ bool type_print_class_properties(const char *type);
*
* For each key in the dictionary, parse the value string if needed,
* then set the corresponding property in @obj.
+ *
+ * Returns: %true on success, %false on error.
*/
-void object_set_props_from_keyval(Object *obj, const QDict *qdict,
+bool object_set_props_from_keyval(Object *obj, const QDict *qdict,
bool from_json, Error **errp);
/**
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 4377d65b76..50736b80c8 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -44,13 +44,14 @@ bool user_creatable_can_be_deleted(UserCreatable *uc)
}
}
-static void object_set_props_from_qdict(Object *obj, const QDict *qdict,
+static bool object_set_props_from_qdict(Object *obj, const QDict *qdict,
Visitor *v, Error **errp)
{
+ ERRP_GUARD();
const QDictEntry *e;
if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
- return;
+ return false;
}
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
if (!object_property_set(obj, e->key, v, errp)) {
@@ -60,19 +61,23 @@ static void object_set_props_from_qdict(Object *obj, const QDict *qdict,
visit_check_struct(v, errp);
out:
visit_end_struct(v, NULL);
+
+ return *errp == NULL;
}
-void object_set_props_from_keyval(Object *obj, const QDict *qdict,
+bool object_set_props_from_keyval(Object *obj, const QDict *qdict,
bool from_json, Error **errp)
{
+ bool ret;
Visitor *v;
if (from_json) {
v = qobject_input_visitor_new(QOBJECT(qdict));
} else {
v = qobject_input_visitor_new_keyval(QOBJECT(qdict));
}
- object_set_props_from_qdict(obj, qdict, v, errp);
+ ret = object_set_props_from_qdict(obj, qdict, v, errp);
visit_free(v);
+ return ret;
}
Object *user_creatable_add_type(const char *type, const char *id,
--
2.54.0
next prev parent reply other threads:[~2026-05-11 14:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 14:14 [PATCH v3 00/10] qom: misc cleanups / fixes Daniel P. Berrangé
2026-05-11 14:14 ` [PATCH v3 01/10] qom: add trace events for object/property lifecycle Daniel P. Berrangé
2026-05-11 14:14 ` [PATCH v3 02/10] qom: validate ID format when creating objects Daniel P. Berrangé
2026-05-11 14:14 ` [PATCH v3 03/10] qom: make errp last param in methods taking va_list Daniel P. Berrangé
2026-05-11 14:14 ` [PATCH v3 04/10] qom: shorten name of object_set_properties_from_keyval Daniel P. Berrangé
2026-05-11 14:14 ` Daniel P. Berrangé [this message]
2026-05-11 14:14 ` [PATCH v3 06/10] qom: move object_set_prop_keyval into object.c Daniel P. Berrangé
2026-05-11 14:14 ` [PATCH v3 07/10] qom: add object_new_with_props_from_qdict Daniel P. Berrangé
2026-05-11 14:14 ` [PATCH v3 08/10] qom: fix ability to create objects without a parent Daniel P. Berrangé
2026-05-11 15:43 ` marcandre.lureau
2026-05-11 14:14 ` [PATCH v3 09/10] qom: allow object_new_with_prop* to trigger module loading Daniel P. Berrangé
2026-05-11 14:14 ` [PATCH v3 10/10] qom: drop user_creatable_add_type method Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260511141420.229023-6-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox