From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH 6/9] qom: move object_set_prop_keyval into object.c
Date: Wed, 29 Apr 2026 22:08:27 +0100 [thread overview]
Message-ID: <20260429210830.594724-7-berrange@redhat.com> (raw)
In-Reply-To: <20260429210830.594724-1-berrange@redhat.com>
This matches the location of the object_set_props and object_set_propv
methods, since this method is not inherently tied to the user creatable
interface. As part of this, object_set_props_from_qdict is also exposed
as a public API since it is still called from object_interfaces.c.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
include/qom/object.h | 47 +++++++++++++++++++++++++++--------------
qom/object.c | 37 ++++++++++++++++++++++++++++++++
qom/object_interfaces.c | 36 -------------------------------
3 files changed, 68 insertions(+), 52 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index 20a04cc4a9..1b2b2702fc 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -748,6 +748,37 @@ bool object_set_props(Object *obj, Error **errp, ...) G_GNUC_NULL_TERMINATED;
*/
bool object_set_propv(Object *obj, va_list vargs, Error **errp);
+/**
+ * object_set_props_from_qdict:
+ * @obj: a QOM object
+ * @qdict: a dictionary with the properties to be set
+ * @v: a visitor to iterate over @dict
+ * @errp: pointer to error object
+ *
+ * For each key in the dictionary, set the corresponding
+ * property in @obj.
+ *
+ * Returns: %true on success, %false on error.
+ */
+bool object_set_props_from_qdict(Object *obj, const QDict *qdict,
+ Visitor *v, Error **errp);
+
+/**
+ * object_set_props_from_keyval:
+ * @obj: a QOM object
+ * @qdict: a dictionary with the properties to be set
+ * @from_json: true if leaf values of @qdict are typed, false if they
+ * are strings
+ * @errp: pointer to error object
+ *
+ * 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.
+ */
+bool object_set_props_from_keyval(Object *obj, const QDict *qdict,
+ bool from_json, Error **errp);
+
/**
* object_initialize:
* @obj: A pointer to the memory to be used for the object.
@@ -914,22 +945,6 @@ type_init(do_qemu_init_ ## type_array)
*/
bool type_print_class_properties(const char *type);
-/**
- * object_set_props_from_keyval:
- * @obj: a QOM object
- * @qdict: a dictionary with the properties to be set
- * @from_json: true if leaf values of @qdict are typed, false if they
- * are strings
- * @errp: pointer to error object
- *
- * 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.
- */
-bool object_set_props_from_keyval(Object *obj, const QDict *qdict,
- bool from_json, Error **errp);
-
/**
* object_class_dynamic_cast_assert:
* @klass: The #ObjectClass to attempt to cast.
diff --git a/qom/object.c b/qom/object.c
index 2671c471ab..c44e2b2eff 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -23,7 +23,9 @@
#include "qapi/qobject-input-visitor.h"
#include "qapi/forward-visitor.h"
#include "qapi/qapi-builtin-visit.h"
+#include "qobject/qdict.h"
#include "qobject/qjson.h"
+#include "qobject/qdict.h"
#include "qemu/id.h"
#include "qapi/qmp/qerror.h"
#include "trace.h"
@@ -847,6 +849,41 @@ bool object_set_propv(Object *obj,
return true;
}
+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 false;
+ }
+ for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
+ if (!object_property_set(obj, e->key, v, errp)) {
+ goto out;
+ }
+ }
+ visit_check_struct(v, errp);
+out:
+ visit_end_struct(v, NULL);
+
+ return *errp == NULL;
+}
+
+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));
+ }
+ ret = object_set_props_from_qdict(obj, qdict, v, errp);
+ visit_free(v);
+ return ret;
+}
Object *object_dynamic_cast(Object *obj, const char *typename)
{
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 50736b80c8..e0a3cd8d0f 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -44,42 +44,6 @@ bool user_creatable_can_be_deleted(UserCreatable *uc)
}
}
-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 false;
- }
- for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
- if (!object_property_set(obj, e->key, v, errp)) {
- goto out;
- }
- }
- visit_check_struct(v, errp);
-out:
- visit_end_struct(v, NULL);
-
- return *errp == NULL;
-}
-
-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));
- }
- 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,
const QDict *qdict,
Visitor *v, Error **errp)
--
2.54.0
next prev parent reply other threads:[~2026-04-29 21:09 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 21:08 [PATCH 0/9] qom: misc cleanups / fixes Daniel P. Berrangé
2026-04-29 21:08 ` [PATCH 1/9] qom: add trace events for object/property lifecycle Daniel P. Berrangé
2026-04-29 21:40 ` marcandre.lureau
2026-04-30 7:56 ` Daniel P. Berrangé
2026-04-29 21:08 ` [PATCH 2/9] qom: validate ID format when creating objects Daniel P. Berrangé
2026-04-29 21:08 ` [PATCH 3/9] qom: make errp last param in methods taking va_list Daniel P. Berrangé
2026-04-30 8:14 ` Philippe Mathieu-Daudé
2026-04-29 21:08 ` [PATCH 4/9] qom: shorten name of object_set_properties_from_keyval Daniel P. Berrangé
2026-04-30 8:14 ` Philippe Mathieu-Daudé
2026-04-29 21:08 ` [PATCH 5/9] qom: have object_set_props_keyval return bool Daniel P. Berrangé
2026-04-29 21:08 ` Daniel P. Berrangé [this message]
2026-04-29 21:40 ` [PATCH 6/9] qom: move object_set_prop_keyval into object.c marcandre.lureau
2026-04-29 21:08 ` [PATCH 7/9] qom: add object_new_with_props_from_qdict Daniel P. Berrangé
2026-04-29 21:08 ` [PATCH 8/9] qom: fix ability to create objects without a parent Daniel P. Berrangé
2026-04-29 21:08 ` [PATCH 9/9] qom: drop user_creatable_add_type method Daniel P. Berrangé
2026-04-29 21:40 ` marcandre.lureau
2026-04-30 7:54 ` 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=20260429210830.594724-7-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=pbonzini@redhat.com \
--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 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.