qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH qom v4 05/13] qom: Demote already-has-a-parent to a


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH qom v4 05/13] qom: Demote already-has-a-parent to a regular error
Date: Fri, 17 Oct 2014 18:24:47 +0200

From: Peter Crosthwaite <address@hidden>

Rather than an abort(). This allows callers to decide whether parenting
an already-parented object is a fatal error condition.

Useful for providing a default value for an object's parent in the case
where you want to set one iff it doesn't already have one.

Reviewed-by: Alexander Graf <address@hidden>
Signed-off-by: Peter Crosthwaite <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
 qom/object.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index 7d617da..04cb6fd 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1079,6 +1079,11 @@ void object_property_add_child(Object *obj, const char 
*name,
     gchar *type;
     ObjectProperty *op;
 
+    if (child->parent != NULL) {
+        error_setg(errp, "child object is already parented");
+        return;
+    }
+
     type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
 
     op = object_property_add(obj, name, type, object_get_child_property, NULL,
@@ -1090,7 +1095,6 @@ void object_property_add_child(Object *obj, const char 
*name,
 
     op->resolve = object_resolve_child_property;
     object_ref(child);
-    g_assert(child->parent == NULL);
     child->parent = obj;
 
 out:
-- 
2.1.0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]