From: Paolo Bonzini <pbonzini@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: qemu-devel@nongnu.org, aliguori@amazon.com, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH] qdev: unparent device when fails to set properties
Date: Tue, 31 Dec 2013 17:06:44 +0100 [thread overview]
Message-ID: <52C2EB94.4050906@redhat.com> (raw)
In-Reply-To: <1388477217-23491-1-git-send-email-akong@redhat.com>
Il 31/12/2013 09:06, Amos Kong ha scritto:
> When it fails to set properties, qdev's parent is already set
Do not confuse the QOM parent (which is /machine/peripheral, of which
the new device is a child) with the qdev parent bus (which has a link to
the new device)!
In general, you should add the device to the QOM tree before using it to
set a link. So I believe that object_property_add_child should be
called before qdev_set_parent_bus. This is the root cause of the bug;
the fix then could be one of the following:
1) move qdev_set_parent_bus later;
2) move object_property_add_child before the setting of properties.
I slightly prefer the first, so that initialization happens in this order:
1) create object
2) set properties -- if it fails, you can just unref the object
3) add child -- if it fails due to duplicate ID, you can again just
unref the object
4) set parent bus (cannot fail)
5) realize -- if it fails, you need to unparent the object and unref the
object
6) drop the reference now that the object is kept solidly alive by
QOM/qdev, and return.
This matches a bit more closely what happens with object-add, too.
Paolo
next prev parent reply other threads:[~2013-12-31 16:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-31 8:06 [Qemu-devel] [PATCH] qdev: unparent device when fails to set properties Amos Kong
2013-12-31 9:09 ` Hu Tao
2013-12-31 9:52 ` Amos Kong
2013-12-31 16:06 ` Paolo Bonzini [this message]
2014-01-02 1:02 ` Amos Kong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52C2EB94.4050906@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=akong@redhat.com \
--cc=aliguori@amazon.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.