Received: from eggs.gnu.org ([2001:4830:134:3::10]:50724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAOdp-0006h5-Jl for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAOdo-0000Pd-P9 for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cAOdo-0000OS-Jf for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:44 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBC2C8124F for ; Fri, 25 Nov 2016 22:06:43 +0000 (UTC) From: Eduardo Habkost Date: Fri, 25 Nov 2016 20:05:53 -0200 Message-Id: <1480111556-32586-18-git-send-email-ehabkost@redhat.com> In-Reply-To: <1480111556-32586-1-git-send-email-ehabkost@redhat.com> References: <1480111556-32586-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [RFC v2 17/20] pci: Set device_type on bus classes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Markus Armbruster , Marcel Apfelbaum , "Michael S. Tsirkin" The default device_type for for TYPE_PCI_BUS will be INTERFACE_LEGACY_PCI_DEVICE. The device_type for TYPE_PCIE_BUS will be INTERFACE_PCIE_DEVICE. Note that specific bus instances may still override accepted_device_types. See the comments added to the code. Signed-off-by: Eduardo Habkost --- Changes series v1 -> v2: * (new patch added to series) --- hw/pci/pci.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 2fc543c..19dc63a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -152,7 +152,10 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) k->realize = pci_bus_realize; k->unrealize = pci_bus_unrealize; k->reset = pcibus_reset; - k->device_type = TYPE_PCI_DEVICE; + /* note that TYPE_PCIE_BUS is a TYPE_PCI_BUS subclass, + * but overrides BusClass::device_type to INTERFACE_PCIE_DEVICE + */ + k->device_type = INTERFACE_LEGACY_PCI_DEVICE; pbc->is_root = pcibus_is_root; pbc->bus_num = pcibus_num; @@ -177,8 +180,19 @@ static const TypeInfo legacy_pci_interface_info = { .parent = TYPE_INTERFACE, }; +static void pcie_bus_class_init(ObjectClass *oc, void *opaque) +{ + BusClass *bc = BUS_CLASS(oc); + /* Note that this is the default value for accepted_device_types, + * but specific PCIe bus instances may override it. + * (e.g. q35 root bus accepts both legacy and PCIe devices). + */ + bc->device_type = INTERFACE_PCIE_DEVICE; +} + static const TypeInfo pcie_bus_info = { .name = TYPE_PCIE_BUS, + .class_init = pcie_bus_class_init, .parent = TYPE_PCI_BUS, }; -- 2.7.4