On 03/26/2015 05:42 PM, Nikunj A Dadhania wrote:
From PCIDevice there is no way to know if the device has a backing
vfio device.
sPAPR guests inherits the "ibm,loc-code" from the pci pass through
device in hypervisor. This helps in identifying the device if there is
any failures using this "ibm,loc-code" for RAS capabilities.
First, you can use object_dynamic_cast(OBJECT(obj), "vfio-pci") to know if
it is a VFIO device.
Second, rather than adding this flag here, I would fix the second patch to
check if PHB is of the TYPE_SPAPR_PCI_VFIO_HOST_BRIDGE type
("spapr-pci-vfio-host-bridge"), using the same QOM mechanism.
CC: Alex Williamson <alex.william...@redhat.com>
CC: Alexander Graf <ag...@suse.de>
Signed-off-by: Nikunj A Dadhania <nik...@linux.vnet.ibm.com>
---
hw/vfio/pci.c | 2 ++
include/hw/pci/pci.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 6b80539..95d666e 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3483,6 +3483,7 @@ static void vfio_instance_finalize(Object *obj)
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pci_dev);
VFIOGroup *group = vdev->vbasedev.group;
+ pci_dev->is_vfio = false;
vfio_unmap_bars(vdev);
g_free(vdev->emulated_config_bits);
g_free(vdev->rom);
@@ -3542,6 +3543,7 @@ static void vfio_instance_init(Object *obj)
PCIDevice *pci_dev = PCI_DEVICE(obj);
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, PCI_DEVICE(obj));
+ pci_dev->is_vfio = true;
device_add_bootindex_property(obj, &vdev->bootindex,
"bootindex", NULL,
&pci_dev->qdev, NULL);
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index b97c295..0ddc830 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -291,6 +291,8 @@ struct PCIDevice {
/* SHPC */
SHPCDevice *shpc;
+ bool is_vfio;
+
/* Location of option rom */
char *romfile;
bool has_rom;
--
Alexey