diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2013-03-25 13:15:13 +0000 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-03-26 09:27:02 -0500 |
commit | 54852b03711f06c5f24af72de583346922176947 (patch) | |
tree | 7eaed56ff92a2a9c7000e013ee749a765d0dfabe /qom/object.c | |
parent | b000dfbd42e8aac9af66ae0ed787ef1021bea29f (diff) |
qom: Detect attempts to add a property that already exists
Detect attempts to add a property to an object if one of
that name already exists, and report them as errors.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1364217314-7400-2-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qom/object.c')
-rw-r--r-- | qom/object.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/qom/object.c b/qom/object.c index 3d638ff27..3f7796856 100644 --- a/qom/object.c +++ b/qom/object.c @@ -629,7 +629,18 @@ void object_property_add(Object *obj, const char *name, const char *type, ObjectPropertyRelease *release, void *opaque, Error **errp) { - ObjectProperty *prop = g_malloc0(sizeof(*prop)); + ObjectProperty *prop; + + QTAILQ_FOREACH(prop, &obj->properties, node) { + if (strcmp(prop->name, name) == 0) { + error_setg(errp, "attempt to add duplicate property '%s'" + " to object (type '%s')", name, + object_get_typename(obj)); + return; + } + } + + prop = g_malloc0(sizeof(*prop)); prop->name = g_strdup(name); prop->type = g_strdup(type); |