[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH RFC 2/4] VFIO: Introduce vfio_get_group_id()
From: |
Gavin Shan |
Subject: |
[Qemu-ppc] [PATCH RFC 2/4] VFIO: Introduce vfio_get_group_id() |
Date: |
Fri, 18 Sep 2015 16:30:14 +1000 |
This introduces vfio_get_group_id() to retrieve the group ID from
the specified PCI device. The function will be used by subsequent
patches to support applying EEH operation on the specified IOMMU
group.
Signed-off-by: Gavin Shan <address@hidden>
---
hw/vfio/pci.c | 12 ++++++++++++
include/hw/vfio/vfio.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 73d34b9..27d7842 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3507,6 +3507,18 @@ static void vfio_setup_resetfn(VFIOPCIDevice *vdev)
}
}
+int vfio_get_group_id(PCIDevice *pdev)
+{
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
+
+ if (!pdev || !object_dynamic_cast(OBJECT(pdev), "vfio-pci") ||
+ !vdev->vbasedev.group) {
+ return -1;
+ }
+
+ return vdev->vbasedev.group->groupid;
+}
+
static int vfio_initfn(PCIDevice *pdev)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
diff --git a/include/hw/vfio/vfio.h b/include/hw/vfio/vfio.h
index 0b26cd8..6289b96 100644
--- a/include/hw/vfio/vfio.h
+++ b/include/hw/vfio/vfio.h
@@ -5,5 +5,6 @@
extern int vfio_container_ioctl(AddressSpace *as, int32_t groupid,
int req, void *param);
+extern int vfio_get_group_id(PCIDevice *pdev);
#endif
--
2.1.0