Received: from eggs.gnu.org ([140.186.70.92]:57971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdliM-00066d-7v for qemu-devel@nongnu.org; Mon, 04 Jul 2011 12:09:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QdliK-00071R-Ep for qemu-devel@nongnu.org; Mon, 04 Jul 2011 12:09:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdliK-00071N-3Z for qemu-devel@nongnu.org; Mon, 04 Jul 2011 12:09:36 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p64G9ZUI007572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 4 Jul 2011 12:09:35 -0400 From: Markus Armbruster References: <1309519646-3206-1-git-send-email-kraxel@redhat.com> Date: Mon, 04 Jul 2011 18:09:32 +0200 In-Reply-To: <1309519646-3206-1-git-send-email-kraxel@redhat.com> (Gerd Hoffmann's message of "Fri, 1 Jul 2011 13:27:24 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] PCI: how handle multifunction / compound devices best? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Gerd Hoffmann writes: > Hi folks, > > I'm still looking for a sane way to handle multifunction pci devices, > specifically a EHCI USB controller with UHCI companion controllers. > > Here comes a small (incomplete[1]) two patch series to make the issue > more clear. The first patch adds a function which creates all devices > with the properties set as needed. The second patch adds a '-usb2' > switch to windup this in a user-friendly way. > > Adding a -usb2 switch sucks though. I'd prefer to have some way to > create such devices via -device, but without asking the user to create > all functions individually on the command line, i.e. have something > along the lines of ... > > qemu -device ich9-usb,slot=08 > > ... instead of ... > > qemu \ > -device ich9-usb-ehci1,addr=08.7,multifunction=on,id=ehci \ > -device ich9-usb-uhci1,addr=08.0,multifunction=on,masterbus=ehci.0,firstport=0 \ > -device ich9-usb-uhci2,addr=08.1,multifunction=on,masterbus=ehci.0,firstport=2 \ > -device ich9-usb-uhci3,addr=08.2,multifunction=on,masterbus=ehci.0,firstport=4 > > Suggestions? This special case of composition is simple enough that some kind of macro expansion could work. A device defines a name, properties and a bunch of methods. A device macro could define a name, properties (the macro parameters), and an expansion. Expansions could be as simple as a list of -device where the property values can also be macro parameter names. -device MACRO,... could then be replaced by MACRO's expansion with the property values substituted. Use to make -device ich9-usb,... expand into its functions. Just an idea; I'm not claiming this is the way to go. Device macros destroy the 1:1 relationship between -device and device tree nodes. Or rather what's left of it: we already have a device that expands into multiple devices, namely usb-storage. But it's an ad hoc hack, which has caused us some grief.