Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LbelW-00015r-8i for qemu-devel@nongnu.org; Mon, 23 Feb 2009 12:38:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LbelU-00013O-U3 for qemu-devel@nongnu.org; Mon, 23 Feb 2009 12:38:49 -0500 Received: from [199.232.76.173] (port=51174 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LbelU-00013A-Na for qemu-devel@nongnu.org; Mon, 23 Feb 2009 12:38:48 -0500 Received: from mx2.redhat.com ([66.187.237.31]:44274) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LbelT-0004Nr-VK for qemu-devel@nongnu.org; Mon, 23 Feb 2009 12:38:48 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n1NHckUK014266 for ; Mon, 23 Feb 2009 12:38:47 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n1NHckqe010507 for ; Mon, 23 Feb 2009 12:38:47 -0500 Received: from pike.pond.sub.org (vpn-10-44.str.redhat.com [10.32.10.44]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n1NHckA7027404 for ; Mon, 23 Feb 2009 12:38:46 -0500 Subject: Re: [Qemu-devel] Machine description as data prototype, take 3 References: <87iqnh6kyv.fsf@pike.pond.sub.org> <871vtuafdr.fsf@pike.pond.sub.org> <499D7168.2050008@codemonkey.ws> From: Markus Armbruster Date: Mon, 23 Feb 2009 18:38:44 +0100 In-Reply-To: <499D7168.2050008@codemonkey.ws> (Anthony Liguori's message of "Thu\, 19 Feb 2009 08\:49\:12 -0600") Message-ID: <87y6vxhx3v.fsf@pike.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Anthony Liguori writes: >> diff --git a/hw/dt.c b/hw/dt.c >> + >> > > Please remove the ^Ls. They don't render properly in my mail client. Many source files contain ^L already. But I'll drop mine if you insist. >> +/* Host Configuration */ >> + >> +typedef struct dt_host { >> + /* connection NICs <-> VLAN */ >> + tree *nic[MAX_NICS]; >> + VLANState *nic_vlan[MAX_NICS]; >> + /* connection drives <-> controller */ >> + tree *drive_ctrl[MAX_DRIVES]; >> + BlockDriverState *drive_state[MAX_DRIVES]; >> +} dt_host; >> >> > > typedef struct DeviceTreeHost > { > } DeviceTreeHost. If you insist on CamelCase, IFindThatUglyAndHardToRead, but I can do that. Just typedef names? As to the placement of braces, a quick grep shows the vast majority of such typedefs to have the brace on the same line as the typedef. > I'm not sure this structure is going to scale well as we introduce > more types of host devices. You don't necessarily need to address the > host configuration file part of this at this stage. Agreed. struct dt_host was just the simplest way I could find to separate machine from host configuration, and still keep host configuration together in one place. I rather like to have it in one place right now, because it makes it easier for me to find out what host configuration actually is. > For instance, I think it would be perfectly fine to require to start > with that the command line configuration matches the describe machine > file. For instance, if you see: > > -net tap -net nic,model=rtl8139 > > Then you should search for an rtl8139 and configure the node to be on > vlan=0. If an rtl8139 doesn't exist, throw an error. Conversely, when an optional tree node isn't enabled (e.g. with -net nic for NICs), silently cut it from the tree. > The long term goal, would be to have a mechanism to modify the tree in > a generic way and the -net nic code would end up looking like: > > node = find_next_device("type=nic,model=rtl8139"); > if (!node) { > node = find_bus("type=pcibus"); > if (!node) > bail out > node = add_node_to_bus(node, > "type=nic,model=rtl8139,remaining_description_of_rtl8139"); > if (!node) > bail out > } > > attach_nic_to_vlan(vlan, node); Makes sense to me. The driver should declare on what kind(s) of bus this device can go. >> +static dt_driver * >> +dt_driver_by_name(const char *name) >> > > While I'm not wildly opposed to this style (it's nice for grepping), > most of the rest of the code doesn't do this (it keeps it on the same > line). Done. > Regards, > > Anthony Liguori Thanks! -- Consistently separating words by spaces became a general custom about the tenth century A.D., and lasted until about 1957, when FORTRAN abandoned the practice. -- Sun FORTRAN Reference Manual