hw/i386/amd_iommu: Factor amdvi_pci_realize out of amdvi_sysbus_realize
commit5ec7755eb7c503fc66fe44083ee5113bd5b87bd9
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 13 Mar 2023 15:30:31 +0000 (13 16:30 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 21 Apr 2023 08:25:52 +0000 (21 04:25 -0400)
treed5c13dc715966180272b4bcb84ebf3642cab3444
parent7f5a459dc8132bd15c28a0d2af1f0cf844ee19f4
hw/i386/amd_iommu: Factor amdvi_pci_realize out of amdvi_sysbus_realize

Aside the Frankenstein model of a SysBusDevice realizing a PCIDevice,
QOM parents shouldn't access children internals. In this particular
case, amdvi_sysbus_realize() is just open-coding TYPE_AMD_IOMMU_PCI's
DeviceRealize() handler. Factor it out.

Declare QOM-cast macros with OBJECT_DECLARE_SIMPLE_TYPE() so we can
cast the AMDVIPCIState in amdvi_pci_realize().

Note this commit removes the single use in the repository of
pci_add_capability() and msi_init() on a *realized* QDev instance.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230313153031.86107-7-philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/i386/amd_iommu.c
hw/i386/amd_iommu.h