[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/28] qom: Demote already-has-a-parent to a regular
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 06/28] qom: Demote already-has-a-parent to a regular error |
Date: |
Mon, 27 Oct 2014 16:13:23 +0100 |
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 c7ef776..1812c73 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:
--
1.8.3.1
- [Qemu-devel] [PULL 00/28] Changes for 2014-10-27, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 06/28] qom: Demote already-has-a-parent to a regular error,
Paolo Bonzini <=
- [Qemu-devel] [PULL 07/28] qdev: gpio: Re-implement qdev_connect_gpio QOM style, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 02/28] virtio-scsi: dataplane: print why starting failed, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 04/28] virtio-scsi: dataplane: stop trying on notifier error, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 01/28] virtio-scsi-dataplane: Add op blocker, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 05/28] qom: Allow clearing of a Link property, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 09/28] qtest/irq: Rework IRQ interception, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 03/28] virtio-scsi: dataplane: fail setup gracefully, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 10/28] irq: Remove qemu_irq_intercept_out, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 08/28] qdev: gpio: Add API for intercepting a GPIO, Paolo Bonzini, 2014/10/27
- [Qemu-devel] [PULL 11/28] qdev: gpio: delete NamedGPIOList::out, Paolo Bonzini, 2014/10/27