[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC 0/2] QMP command qom-new

From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH RFC 0/2] QMP command qom-new
Date: Thu, 24 May 2012 09:35:24 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1

On 05/24/2012 09:23 AM, Peter Maydell wrote:
On 24 May 2012 15:10, Anthony Liguori<address@hidden>  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..


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.


Anthony Liguori

-- PMM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]