summaryrefslogtreecommitdiffstats
path: root/hw/virtio/virtio-pci.h
diff options
context:
space:
mode:
authorShmulik Ladkani2015-12-02 18:49:07 +0100
committerMichael S. Tsirkin2015-12-02 20:51:33 +0100
commit0560b0e97df3da43651158c799c6d889f27529c3 (patch)
tree223c7402f4a51de7d2114999a039b76746f593a1 /hw/virtio/virtio-pci.h
parentvirtio: handle non-virtio-1-capable backend for ccw (diff)
downloadqemu-0560b0e97df3da43651158c799c6d889f27529c3.tar.gz
qemu-0560b0e97df3da43651158c799c6d889f27529c3.tar.xz
qemu-0560b0e97df3da43651158c799c6d889f27529c3.zip
virtio-pci: Set the QEMU_PCI_CAP_EXPRESS capability early in its DeviceClass realize method
In 1811e64 'hw/virtio: Add PCIe capability to virtio devices', the QEMU_PCI_CAP_EXPRESS capability was added to virtio's pci_dev, within 'virtio_pci_realize' - the pci device object realization method. This occurs to late, as 'pci_qdev_realize' (DeviceClass.realize of TYPE_PCI_DEVICE) has already been called, without knowing that the device instance is indeed an "express" instance, thus allocating insufficient pci config space. As a result, device may crash upon attempt to write to the PCIE config space. Fix, by arming the QEMU_PCI_CAP_EXPRESS capability early in virtio-pci's own DeviceClass realize method. This also makes code cleaner, as 'virtio_pci_realize' may now access the 'pci_is_express' predicate when needed. Signed-off-by: Shmulik Ladkani <shmulik.ladkani@ravellosystems.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com> Tested-by: Marcel Apfelbaum <marcel@redhat.com>
Diffstat (limited to 'hw/virtio/virtio-pci.h')
-rw-r--r--hw/virtio/virtio-pci.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
index ffb74bb908..a104ff2072 100644
--- a/hw/virtio/virtio-pci.h
+++ b/hw/virtio/virtio-pci.h
@@ -105,6 +105,7 @@ typedef struct {
typedef struct VirtioPCIClass {
PCIDeviceClass parent_class;
+ DeviceRealize parent_dc_realize;
void (*realize)(VirtIOPCIProxy *vpci_dev, Error **errp);
} VirtioPCIClass;