From: Amos Kong <akong@redhat.com>
To: Hu Tao <hutao@cn.fujitsu.com>
Cc: pbonzini@redhat.com, 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:52:19 +0800 [thread overview]
Message-ID: <20131231095219.GA22565@amosk.info> (raw)
In-Reply-To: <20131231090936.GA30667@G08FNSTD100614.fnst.cn.fujitsu.com>
On Tue, Dec 31, 2013 at 05:09:36PM +0800, Hu Tao wrote:
> On Tue, Dec 31, 2013 at 04:06:57PM +0800, Amos Kong wrote:
> > Test steps:
> > (qemu) device_add e1000,addr=adsf
> > Property 'e1000.addr' doesn't take value 'adsf'
> > (qemu) info qtree
> > Then qemu crashed.
> >
> > When it fails to set properties, qdev's parent is already set, but the
> > object hasn't been added to parent object, object_unparent() won't
> > unparent the device. This patch unparents device in the mediacy.
> >
> > Signed-off-by: Amos Kong <akong@redhat.com>
> > ---
> > qdev-monitor.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/qdev-monitor.c b/qdev-monitor.c
> > index dc37a43..3d8b4f4 100644
> > --- a/qdev-monitor.c
> > +++ b/qdev-monitor.c
> > @@ -527,7 +527,9 @@ DeviceState *qdev_device_add(QemuOpts *opts)
> > dev->id = id;
> > }
> > if (qemu_opt_foreach(opts, set_property, dev, 1) != 0) {
> > - object_unparent(OBJECT(dev));
> > + if (OBJECT(dev)->class->unparent) {
> > + (OBJECT(dev)->class->unparent)(OBJECT(dev));
> > + }
>
Hi Tao,
> This means object_unparent()(or device_unparent()) doesn't handle
> incompletely initialized object correctly. How about fix it in
> object_unparent()/device_unparent()?
We can't fix object_unparent() to cleanup this immature object.
device_unparent() is used to clean device, but it's not called.
OBJECT(dev)->class->unparent is initialized to device_unparent().
So my patch just called OBJECT(dev)->class->unparent().
> BTW, it must be commit e0a83fc2c1582dc8 introdues the problem.
Yes.
--
Amos.
next prev parent reply other threads:[~2013-12-31 9:52 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 [this message]
2013-12-31 16:06 ` Paolo Bonzini
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=20131231095219.GA22565@amosk.info \
--to=akong@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=hutao@cn.fujitsu.com \
--cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).