From: hitmoon <zxq_yx_007@163.com>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
"Andreas Färber" <afaerber@suse.de>,
patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] sd: Fix "info qtree" on boards with SD cards
Date: Wed, 16 Mar 2016 10:14:50 +0800 [thread overview]
Message-ID: <56E8C19A.3010002@163.com> (raw)
In-Reply-To: <1458061009-7733-1-git-send-email-peter.maydell@linaro.org>
在 2016年03月16日 00:56, Peter Maydell 写道:
> The SD card object is not a SysBusDevice, so don't create it with
> qdev_create() if we're not assigning it to a specific bus; use
> object_new() instead.
>
> This was causing 'info qtree' to segfault on boards with SD cards,
> because qdev_create(NULL, TYPE_FOO) puts the created object on the
> system bus, and then we may try to run functions like sysbus_dev_print()
> on it, which fail when casting the object to SysBusDevice.
>
> (This is the same mistake that we made with the NAND device
> and fixed in commit 6749695eaaf346c1.)
>
> Reported-by: hitmoon <zxq_yx_007@163.com>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> I assume that using qdev_create() for non-SysBus devices is
> OK if we are passing in a specific bus pointer, because we do
> this already for various things including PCI devices. The
> various "properly QOMified" uses of TYPE_SD_CARD do that; only
> this sd_init() function for the legacy uses doesn't.
> ---
> hw/sd/sd.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index 00c320d..1568057 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -563,17 +563,19 @@ static const VMStateDescription sd_vmstate = {
> /* Legacy initialization function for use by non-qdevified callers */
> SDState *sd_init(BlockBackend *blk, bool is_spi)
> {
> + Object *obj;
> DeviceState *dev;
> Error *err = NULL;
>
> - dev = qdev_create(NULL, TYPE_SD_CARD);
> + obj = object_new(TYPE_SD_CARD);
> + dev = DEVICE(obj);
> qdev_prop_set_drive(dev, "drive", blk, &err);
> if (err) {
> error_report("sd_init failed: %s", error_get_pretty(err));
> return NULL;
> }
> qdev_prop_set_bit(dev, "spi", is_spi);
> - object_property_set_bool(OBJECT(dev), true, "realized", &err);
> + object_property_set_bool(obj, true, "realized", &err);
> if (err) {
> error_report("sd_init failed: %s", error_get_pretty(err));
> return NULL;
Nice patch !
Reviewed-by: xiaoqiang.zhao <zxq_yx_007@163.com>
prev parent reply other threads:[~2016-03-16 2:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-15 16:56 [Qemu-devel] [PATCH] sd: Fix "info qtree" on boards with SD cards Peter Maydell
2016-03-15 20:28 ` [Qemu-devel] [Qemu-arm] " Thomas Hanson
2016-03-15 20:33 ` Peter Maydell
2016-03-15 20:41 ` Peter Maydell
2016-03-16 13:22 ` Thomas Hanson
2016-03-16 2:14 ` hitmoon [this message]
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=56E8C19A.3010002@163.com \
--to=zxq_yx_007@163.com \
--cc=afaerber@suse.de \
--cc=crosthwaite.peter@gmail.com \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--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).