qom: do nothing on unparent of object without parent

Otherwise, device_unparent will fail to get a canonical path of
the object.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1364910600-3418-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
master
Paolo Bonzini 2013-04-02 15:50:00 +02:00 committed by Anthony Liguori
parent 2f7bd829db
commit e0a83fc2c1
1 changed files with 4 additions and 0 deletions

View File

@ -362,6 +362,10 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp)
void object_unparent(Object *obj)
{
if (!obj->parent) {
return;
}
object_ref(obj);
if (obj->class->unparent) {
(obj->class->unparent)(obj);