diff mbox

[v2,11/27] qom: fix canonical paths vs. interfaces

Message ID 1328342577-25732-12-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Feb. 4, 2012, 8:02 a.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qom/object.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

Comments

Anthony Liguori Feb. 6, 2012, 2:24 p.m. UTC | #1
On 02/04/2012 02:02 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

> ---
>   qom/object.c |   10 ++++++++++
>   1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index 75be582..e8418bc 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -819,6 +819,12 @@ void object_property_add_child(Object *obj, const char *name,
>   {
>       gchar *type;
>
> +    /* Registering an interface object in the composition tree will mightily
> +     * confuse object_get_canonical_path (which, on the other hand, knows how
> +     * to get the canonical path of an interface object).
> +     */
> +    assert(!object_is_type(obj, type_interface));
> +
>       type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
>
>       object_property_add(obj, name, type, object_get_child_property,
> @@ -912,6 +918,10 @@ gchar *object_get_canonical_path(Object *obj)
>       Object *root = object_get_root();
>       char *newpath = NULL, *path = NULL;
>
> +    if (object_is_type(obj, type_interface)) {
> +        obj = INTERFACE(obj)->obj;
> +    }
> +
>       while (obj != root) {
>           ObjectProperty *prop = NULL;
>
diff mbox

Patch

diff --git a/qom/object.c b/qom/object.c
index 75be582..e8418bc 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -819,6 +819,12 @@  void object_property_add_child(Object *obj, const char *name,
 {
     gchar *type;
 
+    /* Registering an interface object in the composition tree will mightily
+     * confuse object_get_canonical_path (which, on the other hand, knows how
+     * to get the canonical path of an interface object).
+     */
+    assert(!object_is_type(obj, type_interface));
+
     type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
 
     object_property_add(obj, name, type, object_get_child_property,
@@ -912,6 +918,10 @@  gchar *object_get_canonical_path(Object *obj)
     Object *root = object_get_root();
     char *newpath = NULL, *path = NULL;
 
+    if (object_is_type(obj, type_interface)) {
+        obj = INTERFACE(obj)->obj;
+    }
+
     while (obj != root) {
         ObjectProperty *prop = NULL;