qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
	"Andreas Färber" <afaerber@suse.de>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH RFC 0/2] QMP command qom-new
Date: Thu, 24 May 2012 09:35:24 -0500	[thread overview]
Message-ID: <4FBE472C.7010801@codemonkey.ws> (raw)
In-Reply-To: <CAFEAcA_g=NqOeHLBhHr5zBu-t6BHg6mo0iTXRz5CZvpP=HNpTA@mail.gmail.com>

On 05/24/2012 09:23 AM, Peter Maydell wrote:
> On 24 May 2012 15:10, Anthony Liguori<anthony@codemonkey.ws>  wrote:
>> On 05/24/2012 08:18 AM, Peter Maydell wrote:
>>> Last time I was trying to argue for keeping the "create, set properties,
>>> realize" interface for devices/objects as simple as possible you wanted
>>> it to have an error-return interface rather than asserting...
>>
>>
>> You need to be more specific than that I'm afraid..
>
> https://lists.gnu.org/archive/html/qemu-devel/2012-05/msg00079.html

Ah, okay.  So you're taking those comments a bit out of context.

The right way to use object_new() is:

Object *foo = object_new(TYPE_E1000);

If you mistype TYPE_E1000, you should get a compile failure.  There's basically 
no way that this is going to fail unless you do:

Object *foo = object_new("garbage");

There's no point in adding error handling here because if you make this much of 
a mistake, then you're likely not going to handle errors properly.  That's 
entirely different from:

connect(foo, "baz", bar, "caz");

It's extremely likely that you'll mistype one of the property names.  We have 
existence proofs in the three with qdev_prop_set*().  This can be deep within 
the bowels of device initialization and assert()'ing QEMU doing a device_add is 
a pretty nasty thing to do.  There's also type errors that can occur here that 
are even more likely to happen by accident.

Contrast that with:

foo->baz = &bar->caz;

If you mistype the property names or mess up the types, you will get a compile 
error.

Regards,

Anthony Liguori

>
> -- PMM

  reply	other threads:[~2012-05-24 14:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 11:43 [Qemu-devel] [PATCH RFC 0/2] QMP command qom-new Markus Armbruster
2012-05-24 11:43 ` [Qemu-devel] [PATCH RFC 1/2] qom: Give type_get_by_name() external linkage Markus Armbruster
2012-05-24 11:43 ` [Qemu-devel] [PATCH RFC 2/2] qmp: New command qom-new Markus Armbruster
2012-05-24 11:51   ` Paolo Bonzini
2012-05-24 12:58     ` Anthony Liguori
2012-05-24 13:01       ` Andreas Färber
2012-05-24 13:44       ` Paolo Bonzini
2012-05-24 14:12         ` Anthony Liguori
2012-05-24 13:04   ` Anthony Liguori
2012-05-24 13:48     ` Igor Mammedov
2012-05-24 14:01       ` Andreas Färber
2012-05-24 14:07         ` Anthony Liguori
2012-05-24 15:33         ` Igor Mammedov
2012-05-24 14:04       ` Anthony Liguori
2012-05-24 14:24     ` Markus Armbruster
2012-05-24 15:15       ` Michael Roth
2012-05-24 12:32 ` [Qemu-devel] [PATCH RFC 0/2] QMP " Andreas Färber
2012-05-24 13:06   ` Anthony Liguori
2012-05-24 13:18     ` Peter Maydell
2012-05-24 14:10       ` Anthony Liguori
2012-05-24 14:23         ` Peter Maydell
2012-05-24 14:35           ` Anthony Liguori [this message]
2012-05-24 14:52             ` Peter Maydell
2012-05-24 14:08   ` Markus Armbruster
2012-05-24 14:31     ` Andreas Färber
2012-05-24 14:48       ` 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=4FBE472C.7010801@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.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).