From patchwork Fri Nov 25 22:05:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 699408 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tQW6W2F0nz9vF7 for ; Sat, 26 Nov 2016 09:32:35 +1100 (AEDT) Received: from localhost ([::1]:48207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAP2m-0000Kd-L3 for incoming@patchwork.ozlabs.org; Fri, 25 Nov 2016 17:32:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cAOdu-0006mP-5m for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cAOds-0000U9-SG for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54956) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cAOds-0000TZ-MC for qemu-devel@nongnu.org; Fri, 25 Nov 2016 17:06:48 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 E047980F94 for ; Fri, 25 Nov 2016 22:06:47 +0000 (UTC) Received: from localhost (ovpn-116-207.phx2.redhat.com [10.3.116.207]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAPM6kRd016382; Fri, 25 Nov 2016 17:06:47 -0500 From: Eduardo Habkost To: qemu-devel@nongnu.org, Markus Armbruster , Marcel Apfelbaum , "Michael S. Tsirkin" Date: Fri, 25 Nov 2016 20:05:55 -0200 Message-Id: <1480111556-32586-20-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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 25 Nov 2016 22:06:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 19/20] pci: validate interfaces on base_class_init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Make sure we don't forget to add the legacy-PCI or PCIe interface names on any PCI device class. Signed-off-by: Eduardo Habkost --- Changes series v1 -> v2: * (new patch added to series) --- hw/pci/pci.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 19dc63a..2eac71a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2521,6 +2521,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 *legacy = + object_class_dynamic_cast(klass, INTERFACE_LEGACY_PCI_DEVICE); + ObjectClass *pcie = + object_class_dynamic_cast(klass, INTERFACE_PCIE_DEVICE); + assert(legacy || pcie); + } +} + AddressSpace *pci_device_iommu_address_space(PCIDevice *dev) { PCIBus *bus = PCI_BUS(dev->bus); @@ -2645,6 +2656,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)