QOM: Fail casts for unknown types

When we try to cast an object to an unknown type, fail the cast. Today
we would simply run into an assert().

This fixes a bug on qemu-system-s390x for me that gets triggered by the
audio code looking for PCI and ISA buses.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1367326936-28539-1-git-send-email-agraf@suse.de
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Alexander Graf 2013-04-30 15:02:16 +02:00 committed by Anthony Liguori
parent b7da6c6081
commit 9ab880b3a2

View file

@ -453,6 +453,11 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class,
TypeImpl *type = class->type;
ObjectClass *ret = NULL;
if (!target_type) {
/* target class type unknown, so fail the cast */
return NULL;
}
if (type->class->interfaces &&
type_is_ancestor(target_type, type_interface)) {
int found = 0;