aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorPeter Crosthwaite <peter.crosthwaite@xilinx.com>2014-09-25 22:19:52 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2014-10-23 16:41:25 +0200
commit8faa2f8571e399ba486bad00e25b6c9b22b6fd9a (patch)
treed1141cca524db9e0f39dc0a802d88ea7a13e07cd /qom
parentd3c4931647c16c2ffc09a2c7c80d71c73cd026c6 (diff)
qom: Demote already-has-a-parent to a regular error
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 <agraf@suse.de> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/qom/object.c b/qom/object.c
index c7ef776b4e..1812c73327 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1089,6 +1089,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,
@@ -1100,7 +1105,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: