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 1/9] qom: add trace events for object/property lifecycle
Date: Wed, 29 Apr 2026 22:08:22 +0100 [thread overview]
Message-ID: <20260429210830.594724-2-berrange@redhat.com> (raw)
In-Reply-To: <20260429210830.594724-1-berrange@redhat.com>
This adds tracing around object allocation & finalization, the addition &
deletion of properties, and the addition & deletion of children.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
qom/object.c | 34 +++++++++++++++++++++++++++-------
qom/trace-events | 12 ++++++++++--
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index f981e27044..b99da7309d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -603,6 +603,8 @@ static void object_property_del_all(Object *obj)
object_property_iter_init(&iter, obj);
while ((prop = object_property_iter_next(&iter)) != NULL) {
if (g_hash_table_add(done, prop)) {
+ trace_object_property_del(obj, obj->class->type->name,
+ prop->name, prop->opaque);
if (prop->release) {
prop->release(obj, prop->name, prop->opaque);
released = true;
@@ -621,10 +623,14 @@ static void object_property_del_child(Object *obj, Object *child)
GHashTableIter iter;
gpointer key, value;
+ trace_object_property_del_child(obj, obj->class->type->name,
+ child, child->class->type->name);
g_hash_table_iter_init(&iter, obj->properties);
while (g_hash_table_iter_next(&iter, &key, &value)) {
prop = value;
if (object_property_is_child(prop) && prop->opaque == child) {
+ trace_object_property_del(obj, obj->class->type->name,
+ prop->name, prop->opaque);
if (prop->release) {
prop->release(obj, prop->name, prop->opaque);
prop->release = NULL;
@@ -664,7 +670,7 @@ static void object_finalize(void *data)
{
Object *obj = data;
TypeImpl *ti = obj->class->type;
-
+ trace_object_finalize(obj, obj->class->type->name);
object_property_del_all(obj);
object_deinit(obj, ti);
@@ -714,6 +720,7 @@ static Object *object_new_with_type(Type type)
object_initialize_with_type(obj, size, type);
obj->free = obj_free;
+ trace_object_new(obj, obj ? obj->class->type->name : "(null)");
return obj;
}
@@ -844,8 +851,9 @@ Object *object_dynamic_cast(Object *obj, const char *typename)
Object *object_dynamic_cast_assert(Object *obj, const char *typename,
const char *file, int line, const char *func)
{
- trace_object_dynamic_cast_assert(obj ? obj->class->type->name : "(null)",
- typename, file, line, func);
+ trace_object_dynamic_cast_assert(
+ obj, obj ? obj->class->type->name : "(null)",
+ typename, file, line, func);
#ifdef CONFIG_QOM_CAST_DEBUG
int i;
@@ -935,8 +943,9 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *class,
{
ObjectClass *ret;
- trace_object_class_dynamic_cast_assert(class ? class->type->name : "(null)",
- typename, file, line, func);
+ trace_object_class_dynamic_cast_assert(
+ class ? class->type->name : "(null)",
+ typename, file, line, func);
#ifdef CONFIG_QOM_CAST_DEBUG
int i;
@@ -1220,6 +1229,8 @@ object_property_try_add(Object *obj, const char *name, const char *type,
prop->release = release;
prop->opaque = opaque;
+ trace_object_property_add(obj, obj->class->type->name,
+ prop->name, prop->opaque);
g_hash_table_insert(obj->properties, prop->name, prop);
return prop;
}
@@ -1258,6 +1269,8 @@ object_class_property_add(ObjectClass *klass,
prop->release = release;
prop->opaque = opaque;
+ trace_object_class_property_add(klass->type->name, prop->name,
+ prop->opaque);
g_hash_table_insert(klass->properties, prop->name, prop);
return prop;
@@ -1346,6 +1359,8 @@ void object_property_del(Object *obj, const char *name)
{
ObjectProperty *prop = g_hash_table_lookup(obj->properties, name);
+ trace_object_property_del(obj, obj->class->type->name, prop->name,
+ prop->opaque);
if (prop->release) {
prop->release(obj, name, prop->opaque);
}
@@ -1634,8 +1649,11 @@ int object_property_get_enum(Object *obj, const char *name,
bool object_property_parse(Object *obj, const char *name,
const char *string, Error **errp)
{
- Visitor *v = string_input_visitor_new(string);
- bool ok = object_property_set(obj, name, v, errp);
+ Visitor *v;
+ bool ok;
+ trace_object_property_parse(obj, obj->class->type->name, name, string);
+ v = string_input_visitor_new(string);
+ ok = object_property_set(obj, name, v, errp);
visit_free(v);
return ok;
@@ -1766,6 +1784,8 @@ object_property_try_add_child(Object *obj, const char *name,
g_autofree char *type = NULL;
ObjectProperty *op;
+ trace_object_property_add_child(obj, obj->class->type->name, name,
+ child, child->class->type->name);
assert(!child->parent);
type = g_strdup_printf("child<%s>", object_get_typename(child));
diff --git a/qom/trace-events b/qom/trace-events
index b2e9f4a712..9aabbae4f7 100644
--- a/qom/trace-events
+++ b/qom/trace-events
@@ -1,5 +1,13 @@
# See docs/devel/tracing.rst for syntax documentation.
# object.c
-object_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
-object_class_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "%s->%s (%s:%d:%s)"
+object_dynamic_cast_assert(void *obj, const char *type, const char *target, const char *file, int line, const char *func) "obj=%p type=%s->%s (%s:%d:%s)"
+object_finalize(void *obj, const char *type) "obj=%p type=%s"
+object_new(void *obj, const char *type) "obj=%p type=%s"
+object_property_add(void *obj, const char *type, const char *name, void *value) "obj=%p type=%s name=%s value=%p"
+object_property_add_child(void *obj, const char *type, const char *name, void *parent, const char *parenttype) "obj=%p type=%s name=%s parent=%p parent-type=%s"
+object_property_del(void *obj, const char *type, const char *name, void *value) "obj=%p type=%s name=%s value=%p"
+object_property_del_child(void *obj, const char *type, void *parent, const char *parenttype) "obj=%p type=%s parent=%p parent-type=%s"
+object_property_parse(void *obj, const char *type, const char *name, const char *value) "obj=%p type=%s prop=%s value=%s"
+object_class_dynamic_cast_assert(const char *type, const char *target, const char *file, int line, const char *func) "type=%s->%s (%s:%d:%s)"
+object_class_property_add(const char *type, const char *name, void *value) "type=%s name=%s value=%p"
--
2.54.0
next prev parent reply other threads:[~2026-04-29 21:08 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 ` Daniel P. Berrangé [this message]
2026-04-29 21:40 ` [PATCH 1/9] qom: add trace events for object/property lifecycle 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 ` [PATCH 6/9] qom: move object_set_prop_keyval into object.c Daniel P. Berrangé
2026-04-29 21:40 ` 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-2-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.