Received: from eggs.gnu.org ([2001:4830:134:3::10]:48136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCmZO-0002qi-5l for qemu-devel@nongnu.org; Fri, 02 Dec 2016 07:04:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCmZK-00074L-QC for qemu-devel@nongnu.org; Fri, 02 Dec 2016 07:04:01 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45681 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCmZK-00074G-Jj for qemu-devel@nongnu.org; Fri, 02 Dec 2016 07:03:58 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uB2C3Q04118277 for ; Fri, 2 Dec 2016 07:03:57 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0b-001b2d01.pphosted.com with ESMTP id 2738cp8tuf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 02 Dec 2016 07:03:57 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Dec 2016 12:03:55 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id CEE7617D8042 for ; Fri, 2 Dec 2016 12:06:23 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uB2C3qW660424442 for ; Fri, 2 Dec 2016 12:03:52 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uB2C3p26010761 for ; Fri, 2 Dec 2016 05:03:51 -0700 Date: Fri, 2 Dec 2016 13:03:50 +0100 From: Cornelia Huck In-Reply-To: <20161129141819.GH14328@thinpad.lan.raisama.net> References: <1480111556-32586-1-git-send-email-ehabkost@redhat.com> <1480111556-32586-7-git-send-email-ehabkost@redhat.com> <20161129145707.2ec81b5b.cornelia.huck@de.ibm.com> <20161129141819.GH14328@thinpad.lan.raisama.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20161202130350.63d10429.cornelia.huck@de.ibm.com> Subject: Re: [Qemu-devel] [RFC v2 06/20] qdev: Add 'accepted-device-types' property to BusClass List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: qemu-devel@nongnu.org, Markus Armbruster , Marcel Apfelbaum , "Michael S. Tsirkin" On Tue, 29 Nov 2016 12:18:19 -0200 Eduardo Habkost wrote: > On Tue, Nov 29, 2016 at 02:57:07PM +0100, Cornelia Huck wrote: > > On Fri, 25 Nov 2016 20:05:42 -0200 > > Eduardo Habkost wrote: > > > > > Each bus class will now be aware of the specific device types > > > that can be plugged on it. That will be useful for: > > > > > > * Runtime check for which devices types can be plugged to the > > > machine; > > > * Validation of query-machines output by automated tests. > > > > > > By default, a single type name is used on all bus instances (set > > > at BusClass::device_type), but bus instances can override it and > > > return a different type list. > > > > > > Signed-off-by: Eduardo Habkost > > > > I've read (well, more skimmed through) the whole patchset and I think > > we have different cases of "multiple device types for one bus": > > > > - the q35 root bus case later in this patchset, where just a certain > > instance of the bus can accept multiple types > > - the case where every instance of a bus may accept multiple types > > (none currently; but this will be the case for e.g. virtual-css once we > > have other derivates of CCW_DEVICE than virtio-ccw) > > Are all going to be subclasses of TYPE_CCW_DEVICE, and are all > TYPE_CCW_DEVICE subclasses going to be accepted by virtual-css? That's what we plan to do, yes. > In this case, you could just set BusClass::device_type to > TYPE_CCW_DEVICE on virtual-css-bus. Sounds reasonable. > > > > > For the second case, a static initializer for multiple types in the > > class makes sense; > > If necessary, we can change BusClass::device_type to a > BusClass::device_types list. I didn't do that because it didn't > seem necessary (and I would like to encourage buses to encode > compatiblity using a single type/interface name whenever > possible). Most busses will probably allow a single (parent) device type anyway, so that's fine, I guess. > > > > but the first case is a bit hackish. Should there be > > a generic way to pass a list of types to the individual bus instance's > > initializers (that could fall back to a static list in the class)? > > Sound good, but I don't know how that generic mechanism could > look like. Would a: > void bus_add_accepted_device_type(BusState *bus, const char *devtype) > function be enough? Would we need a remove helper as well (i.e. "this bus normally supports types a and b, but this instance accepts only a")? It is probably enough to add it should the need arise some day.