All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Subject: Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() for bus-less devices
Date: Wed, 05 Feb 2014 17:38:45 +0100	[thread overview]
Message-ID: <52F26915.3090104@redhat.com> (raw)
In-Reply-To: <1391609340-11023-1-git-send-email-afaerber@suse.de>

Il 05/02/2014 15:09, Andreas Färber ha scritto:
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 82a9123..14c8765 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -131,21 +131,27 @@ DeviceState *qdev_create(BusState *bus, const char *name)
>  DeviceState *qdev_try_create(BusState *bus, const char *type)
>  {
>      DeviceState *dev;
> +    ObjectClass *oc;
> +    DeviceClass *dc;
>
> -    if (object_class_by_name(type) == NULL) {
> +    oc = object_class_by_name(type);
> +    if (oc == NULL) {
>          return NULL;
>      }
> +    dc = DEVICE_CLASS(oc);
>      dev = DEVICE(object_new(type));
>      if (!dev) {
>          return NULL;
>      }
>
> -    if (!bus) {
> +    if (!bus && dc->bus_type && strcmp(dc->bus_type, "System") == 0) {

Should you check instead if dev is-a TYPE_SYSBUS_DEVICE?

Does this also leave the nand device out of info qtree, or is it still 
dumped?

Paolo

>          bus = sysbus_get_default();
>      }
>
> -    qdev_set_parent_bus(dev, bus);
> -    object_unref(OBJECT(dev));
> +    if (bus != NULL) {
> +        qdev_set_parent_bus(dev, bus);
> +        object_unref(OBJECT(dev));
> +    }
>      return dev;
>  }
>
>

  reply	other threads:[~2014-02-05 16:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-05 14:09 [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() for bus-less devices Andreas Färber
2014-02-05 16:38 ` Paolo Bonzini [this message]
2014-02-05 16:46   ` Andreas Färber
2014-02-05 17:20     ` Andreas Färber
2014-02-05 23:16     ` Peter Crosthwaite

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=52F26915.3090104@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=afaerber@suse.de \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.maydell@linaro.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 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.