qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel Developers <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Alexander Graf <agraf@suse.de>,
	Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() semantics
Date: Fri, 17 Feb 2012 03:00:01 +0100	[thread overview]
Message-ID: <4F3DB4A1.10104@suse.de> (raw)
In-Reply-To: <1329443264-13819-1-git-send-email-afaerber@suse.de>

Am 17.02.2012 02:47, schrieb Andreas Färber:
> Since QOM'ification, qdev_try_create() uses object_new() internally,
> which asserts "type != NULL" when the type is not registered.
> This was revealed by the combination of kvmclock's kvm_enabled() check
> and early QOM type registration.
> 
> Check whether the class exists before calling object_new(), so that
> the caller (e.g., qdev_create) can fail gracefully, telling us which
> device could not be created.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> Cc: Anthony Liguori <aliguori@codemonkey.ws>

Er, it's late here... ;)

As one can guess I've managed to convert x86. Still need to cleanup but
I pushed my work branch for the curious (and as backup!):

http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-cpu

Andreas

> ---
>  hw/qdev.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/qdev.c b/hw/qdev.c
> index f0eb3a7..ee21d90 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -117,6 +117,9 @@ DeviceState *qdev_try_create(BusState *bus, const char *name)
>  {
>      DeviceState *dev;
>  
> +    if (object_class_by_name(name) == NULL) {
> +        return NULL;
> +    }
>      dev = DEVICE(object_new(name));
>      if (!dev) {
>          return NULL;

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2012-02-17  2:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-17  1:47 [Qemu-devel] [PATCH] qdev: Fix qdev_try_create() semantics Andreas Färber
2012-02-17  2:00 ` Andreas Färber [this message]
2012-02-17 18:16   ` Anthony Liguori

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=4F3DB4A1.10104@suse.de \
    --to=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=imammedo@redhat.com \
    --cc=jan.kiszka@siemens.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 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).