From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPEyR-0007sv-Vv for qemu-devel@nongnu.org; Tue, 01 May 2012 11:26:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPEyP-0007dj-9x for qemu-devel@nongnu.org; Tue, 01 May 2012 11:26:43 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:44117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPEyP-0007dH-3h for qemu-devel@nongnu.org; Tue, 01 May 2012 11:26:41 -0400 Received: by pbbro12 with SMTP id ro12so5051733pbb.4 for ; Tue, 01 May 2012 08:26:39 -0700 (PDT) Message-ID: <4FA000A3.80801@codemonkey.ws> Date: Tue, 01 May 2012 10:26:27 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <4F9D797E.500@ilande.co.uk> <4F9D97F3.8080608@codemonkey.ws> <4F9E5028.7010306@redhat.com> <4F9E82C7.10706@ilande.co.uk> <4F9E9268.70408@redhat.com> <4F9E9569.5000700@redhat.com> <4F9FD997.9000403@redhat.com> <4F9FDA38.6030108@redhat.com> <4F9FDB80.4020604@redhat.com> <4F9FDEBC.2030806@redhat.com> <4F9FEA24.3070603@codemonkey.ws> <4F9FEDFE.3030403@codemonkey.ws> <4F9FFCA6.5070706@codemonkey.ws> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Memory API: handling unassigned physical memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Mark Cave-Ayland , Avi Kivity , qemu-devel@nongnu.org On 05/01/2012 10:20 AM, Peter Maydell wrote: > On 1 May 2012 16:09, Anthony Liguori wrote: >> On 05/01/2012 09:20 AM, Peter Maydell wrote: >>> This is a bit verbose. Something more like >>> pin_connect(s, "int_out[0]", self, "int_set[2]"); >> >> This is incorrect, it would have to be: >> >> Error *err = NULL; >> >> if (pin_connect(s, "in_out[0]", self, "int_set[2]",&err)) { >> error_propagate(errp, err); >> return; >> >> } >> >>> would be a bit less longwinded. Or even >>> connect(TYPE_PIN, s, "int_out[0]", self, "int_set[2]"); >> >> >> Not checking for failure is not an option. > > The assumption is that failure to connect is a fatal error, > and we can happily just assert()/hw_error()/etc. So that means that we have a bug from someone miss-typing, instead of your hotplug attempt failing with an error, your entire guest is destroyed. That doesn't sound very nice to me. Device initialization should never exit() (unless you really hit a fatal error like OOM). >>> (No, this doesn't do compile time type checking. I don't >>> think that's a problem particularly, or at least not enough >>> of one to justify not doing it this way. The object model we >>> have is dynamic and does things at runtime...) >> >> Correctness is more important to me than brevity. >> >> And really, we should focus on killing things like i8259_init(). > > Functions like i8259_init() exist precisely because > QOM/qdev don't provide brevity and people trying to > use these devices do in fact value brevity. No, they exist because we aren't modeling correctly. i8259_init() is doing a few different things at once. Once you split things between init and realize, you no longer have long chunks of redundant code. > That's why > I want the standard native "connect this thing to this > other thing" function to be short and simple. With my previous proposal, it's just: s->irq_in = &b->int_out[0]; This is why I like exposing public members in structures. It's brief and safe. Regards, Anthony Liguori > > -- PMM