Skip to content
Commit 0560b0e9 authored by Shmulik Ladkani's avatar Shmulik Ladkani Committed by Michael S. Tsirkin
Browse files

virtio-pci: Set the QEMU_PCI_CAP_EXPRESS capability early in its DeviceClass realize method



In 1811e64c '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: default avatarShmulik Ladkani <shmulik.ladkani@ravellosystems.com>
Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarMarcel Apfelbaum <marcel@redhat.com>
Tested-by: default avatarMarcel Apfelbaum <marcel@redhat.com>
parent 11380b36
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment