From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXZ8b-0007wQ-Ek for qemu-devel@nongnu.org; Thu, 24 May 2012 10:35:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXZ8S-0003lC-LG for qemu-devel@nongnu.org; Thu, 24 May 2012 10:35:36 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:44095) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXZ8S-0003l2-G9 for qemu-devel@nongnu.org; Thu, 24 May 2012 10:35:28 -0400 Received: by obbwd20 with SMTP id wd20so15616739obb.4 for ; Thu, 24 May 2012 07:35:27 -0700 (PDT) Message-ID: <4FBE472C.7010801@codemonkey.ws> Date: Thu, 24 May 2012 09:35:24 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1337859784-24097-1-git-send-email-armbru@redhat.com> <4FBE2A59.3060701@suse.de> <4FBE324C.70407@codemonkey.ws> <4FBE4168.4000204@codemonkey.ws> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 0/2] QMP command qom-new List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , Markus Armbruster On 05/24/2012 09:23 AM, Peter Maydell wrote: > On 24 May 2012 15:10, Anthony Liguori 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