aboutsummaryrefslogtreecommitdiff
path: root/hw/pci/pci.c
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2017-09-27 16:56:35 -0300
committerMichael S. Tsirkin <mst@redhat.com>2017-10-15 05:54:43 +0300
commit2fefa16cec5a719f5cbc26c0672dd2099cd2ed9b (patch)
tree7ada954d9c586fa014c488d034b3dedc607c476c /hw/pci/pci.c
parent6d7023763ec8cc7999468769a0c6bf1335dc3bf4 (diff)
pci: Validate interfaces on base_class_init
Make sure we don't forget to add the Conventional PCI or PCI Express interface names on PCI device classes in the future. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Revieed-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/pci/pci.c')
-rw-r--r--hw/pci/pci.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 1b08e18205..5ed3c8dca4 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2547,6 +2547,17 @@ static void pci_device_class_init(ObjectClass *klass, void *data)
pc->realize = pci_default_realize;
}
+static void pci_device_class_base_init(ObjectClass *klass, void *data)
+{
+ if (!object_class_is_abstract(klass)) {
+ ObjectClass *conventional =
+ object_class_dynamic_cast(klass, INTERFACE_CONVENTIONAL_PCI_DEVICE);
+ ObjectClass *pcie =
+ object_class_dynamic_cast(klass, INTERFACE_PCIE_DEVICE);
+ assert(conventional || pcie);
+ }
+}
+
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev)
{
PCIBus *bus = PCI_BUS(dev->bus);
@@ -2671,6 +2682,7 @@ static const TypeInfo pci_device_type_info = {
.abstract = true,
.class_size = sizeof(PCIDeviceClass),
.class_init = pci_device_class_init,
+ .class_base_init = pci_device_class_base_init,
};
static void pci_register_types(void)