qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>, Alon Levy <alevy@redhat.com>,
	qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH] hw/qdev-monitor: report error for -device <not-a-device-type>
Date: Wed, 28 Nov 2012 10:21:19 -0200	[thread overview]
Message-ID: <20121128102119.5de147f2@doriath.home> (raw)
In-Reply-To: <50B60158.2000205@suse.de>

On Wed, 28 Nov 2012 13:19:36 +0100
Andreas Färber <afaerber@suse.de> wrote:

> Am 28.11.2012 13:14, schrieb Luiz Capitulino:
> > On Wed, 28 Nov 2012 13:02:26 +0100
> > Paolo Bonzini <pbonzini@redhat.com> wrote:
> > 
> >> Il 28/11/2012 12:54, Luiz Capitulino ha scritto:
> >>> On Wed, 28 Nov 2012 10:54:33 +0200
> >>> Alon Levy <alevy@redhat.com> wrote:
> >>>
> >>>> Instead of aborting immediately after at DEVICE_CLASS(obj)
> >>>>
> >>>> Signed-off-by: Alon Levy <alevy@redhat.com>
> >>>> ---
> >>>>  hw/qdev-monitor.c | 5 +++++
> >>>>  1 file changed, 5 insertions(+)
> >>>>
> >>>> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
> >>>> index 479eecd..3b70cdb 100644
> >>>> --- a/hw/qdev-monitor.c
> >>>> +++ b/hw/qdev-monitor.c
> >>>> @@ -426,6 +426,11 @@ DeviceState *qdev_device_add(QemuOpts *opts)
> >>>>          return NULL;
> >>>>      }
> >>>>  
> >>>> +    if (!object_class_dynamic_cast(obj, "device")) {
> >>>> +        qerror_report(QERR_INVALID_PARAMETER_TYPE, "driver", "device type");
> >>>> +        return NULL;
> >>>> +    }
> >>>
> >>> Gives me the impression that something is wrong before this, but it's
> >>> better to ask a QOM guy (CC'ing them).
> >>
> >> I would reuse the same error message as for "if (!obj)", and also use
> >> TYPE_DEVICE instead of the hardcoded string, but the patch is ok.
> > 
> > It's a bit weird to me that you check for a condition and right next
> > you also assert it (it's what DEVICE_CLASS() will do). But I'm not familiar
> > with QOM, so I'll just trust you.
> 
> We could just as well do:
> 
> k = object_class_dynamic_cast(obj, TYPE_DEVICE);
> if (k == NULL) {
>     // do the error reporting
>     return ...;
> }

Yeah, was reaching this solution after some code reading :)

> 
> /* find bus */
> ...
> 
> Andreas
> 

  reply	other threads:[~2012-11-28 12:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-28  8:54 [Qemu-devel] [PATCH] hw/qdev-monitor: report error for -device <not-a-device-type> Alon Levy
2012-11-28 11:54 ` Luiz Capitulino
2012-11-28 12:02   ` Paolo Bonzini
2012-11-28 12:14     ` Luiz Capitulino
2012-11-28 12:19       ` Andreas Färber
2012-11-28 12:21         ` Luiz Capitulino [this message]
2012-11-28 12:18     ` Alon Levy
2012-11-28 12:15   ` Andreas Färber
2012-11-28 12:17   ` Alon Levy
2012-11-28 12:00 ` Markus Armbruster

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=20121128102119.5de147f2@doriath.home \
    --to=lcapitulino@redhat.com \
    --cc=afaerber@suse.de \
    --cc=alevy@redhat.com \
    --cc=armbru@redhat.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).