@@ -35,6 +35,8 @@
#include "pci.h"
#include "trace.h"
+#include "hw/vfio/vfio-pci.h"
+
#define MSIX_CAP_LENGTH 12
static void vfio_disable_interrupts(VFIOPCIDevice *vdev);
@@ -2312,6 +2314,18 @@ static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev)
vdev->req_enabled = false;
}
+VFIOGroup *vfio_pci_device_group(PCIDevice *pdev)
+{
+ VFIOPCIDevice *vdev;
+
+ if (!object_dynamic_cast(OBJECT(pdev), "vfio-pci")) {
+ return NULL;
+ }
+
+ vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
+ return vdev->vbasedev.group;
+}
+
static int vfio_initfn(PCIDevice *pdev)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
new file mode 100644
@@ -0,0 +1,11 @@
+#ifndef VFIO_PCI_H
+#define VFIO_PCI_H
+
+#include "qemu/typedefs.h"
+
+/* We expose the concept of a VFIOGroup, though not its internals */
+typedef struct VFIOGroup VFIOGroup;
+
+extern VFIOGroup *vfio_pci_device_group(PCIDevice *pdev);
+
+#endif /* VFIO_PCI_H */