All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Frederic <fred.konrad@greensocs.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add() (v2)
Date: Thu, 29 Nov 2012 16:20:32 +0100	[thread overview]
Message-ID: <50B77D40.8020109@greensocs.com> (raw)
In-Reply-To: <1354201932-9329-1-git-send-email-aliguori@us.ibm.com>

On 29/11/2012 16:12, Anthony Liguori wrote:
> We are currently checking for an exact type match.  Use QOM dynamic_cast to
> check for a compatible type instead.
>
> Cc: Konrad Frederic<fred.konrad@greensocs.com>
> Cc: Peter Maydell<peter.maydell@linaro.org>
> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
> ---
> v1 ->  v2:
>   - also add cast to qbus_find_recursive (Peter)
>   - simplify by doing object_dynamic_cast instead of messing with classes
> ---
>   hw/qdev-monitor.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
> index 479eecd..a1b4d6a 100644
> --- a/hw/qdev-monitor.c
> +++ b/hw/qdev-monitor.c
> @@ -289,8 +289,7 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
>       if (name&&  (strcmp(bus->name, name) != 0)) {
>           match = 0;
>       }
> -    if (bus_typename&&
> -        (strcmp(object_get_typename(OBJECT(bus)), bus_typename) != 0)) {
> +    if (bus_typename&&  !object_dynamic_cast(OBJECT(bus), bus_typename)) {
>           match = 0;
>       }
>       if (match) {
> @@ -435,7 +434,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
>           if (!bus) {
>               return NULL;
>           }
> -        if (strcmp(object_get_typename(OBJECT(bus)), k->bus_type) != 0) {
> +        if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) {
>               qerror_report(QERR_BAD_BUS_FOR_DEVICE,
>                             driver, object_get_typename(OBJECT(bus)));
>               return NULL;
That seems to work.

Thanks,

Fred.

  reply	other threads:[~2012-11-29 15:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-29 15:12 [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add() (v2) Anthony Liguori
2012-11-29 15:20 ` Konrad Frederic [this message]
2012-11-29 15:36 ` Andreas Färber

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=50B77D40.8020109@greensocs.com \
    --to=fred.konrad@greensocs.com \
    --cc=aliguori@us.ibm.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.