From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcpCe-0002Fe-6S for qemu-devel@nongnu.org; Fri, 18 Sep 2015 02:31:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcpCa-0001mW-UZ for qemu-devel@nongnu.org; Fri, 18 Sep 2015 02:31:24 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:50200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcpCa-0001kE-CA for qemu-devel@nongnu.org; Fri, 18 Sep 2015 02:31:20 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 18 Sep 2015 16:31:17 +1000 From: Gavin Shan Date: Fri, 18 Sep 2015 16:30:14 +1000 Message-Id: <1442557816-23067-3-git-send-email-gwshan@linux.vnet.ibm.com> In-Reply-To: <1442557816-23067-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1442557816-23067-1-git-send-email-gwshan@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH RFC 2/4] VFIO: Introduce vfio_get_group_id() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, qemu-ppc@nongnu.org, Gavin Shan , david@gibson.dropbear.id.au 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 --- 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