Commit e7cce67f authored by Paolo Bonzini's avatar Paolo Bonzini Committed by Andreas Färber
Browse files

qom: Add object_class_get_parent()



This simple bit of functionality was missing and we'll need it soon,
so add it.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
[AF: Document possible NULL return value]
Signed-off-by: default avatarAndreas Färber <afaerber@suse.de>
parent eb2aeacf
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -547,6 +547,14 @@ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *klass,
ObjectClass *object_class_dynamic_cast(ObjectClass *klass,
                                       const char *typename);

/**
 * object_class_get_parent:
 * @klass: The class to obtain the parent for.
 *
 * Returns: The parent for @klass or %NULL if none.
 */
ObjectClass *object_class_get_parent(ObjectClass *klass);

/**
 * object_class_get_name:
 * @klass: The class to obtain the QOM typename for.
+13 −0
Original line number Diff line number Diff line
@@ -545,6 +545,19 @@ ObjectClass *object_class_by_name(const char *typename)
    return type->class;
}

ObjectClass *object_class_get_parent(ObjectClass *class)
{
    TypeImpl *type = type_get_parent(class->type);

    if (!type) {
        return NULL;
    }

    type_initialize(type);

    return type->class;
}

typedef struct OCFData
{
    void (*fn)(ObjectClass *klass, void *opaque);