From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mkbzq-0007N5-6Z for qemu-devel@nongnu.org; Mon, 07 Sep 2009 07:02:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mkbzk-0007Jc-Vf for qemu-devel@nongnu.org; Mon, 07 Sep 2009 07:02:53 -0400 Received: from [199.232.76.173] (port=54430 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mkbzk-0007JU-Op for qemu-devel@nongnu.org; Mon, 07 Sep 2009 07:02:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50285) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mkbzj-0007TI-HE for qemu-devel@nongnu.org; Mon, 07 Sep 2009 07:02:47 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n87B2kQO032351 for ; Mon, 7 Sep 2009 07:02:46 -0400 Message-ID: <4AA4E852.1090500@redhat.com> Date: Mon, 07 Sep 2009 13:02:42 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] Defaults for qdev properties inherited from bus References: <873a73d7gh.fsf@pike.pond.sub.org> <4AA0CC83.3060705@redhat.com> <87zl9a623k.fsf@pike.pond.sub.org> In-Reply-To: <87zl9a623k.fsf@pike.pond.sub.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org >> The second group has instance-dependent defaults (see ${device}_io >> arrays in pc.c and elsewhere), i.e. first ne2k_isa at 0x300, second at >> 0x320, etc. Property defaults can cover instance #1 only. > > The instance-dependent defaults are occasionally convenient, but I'm not > sure the functionality worth replicating for -device. For -serial (and maybe -parallel) you probably want to have that because there are standard i/o port for serial lines 1 -> 4. More than one serial line isn't that uncommon too, and even in a pci machine these are isa devices. For sb16, ne2k_isa, ... we can probably simply go with default values (so -device $name just works for a single card) and expect the user to override iobase in case he wants to plug multiple cards into his isapc. >> We can move the io properties from the bus to the devices which >> actually need it. Then this would probably become something like >> this: >> >> if (ne2k_isa->iobase == -1) >> ne2c_isa->iobase = default_base[instance]; > > Not sure I get what you mean. If your proposal has the above code in > the init() callback, then it's not much of an improvement. Only needed for devices which want to have different default values per instance (i.e. serial, see above). Otherwise property defaults (or no iobase property at all) will do just fine. > The cleanest way to implement defaults is to get the job done in > qdev_create(). No second-guessing in init() whether the default has > been overridden by the user. Sure. Might be overkill for just one or two use cases though. cheers, Gerd