From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsRYu-0005cX-9V for qemu-devel@nongnu.org; Thu, 05 Jun 2014 02:54:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsRYg-0005Ny-Eh for qemu-devel@nongnu.org; Thu, 05 Jun 2014 02:54:08 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:50536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsRYf-0005MY-LA for qemu-devel@nongnu.org; Thu, 05 Jun 2014 02:53:54 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Jun 2014 16:53:49 +1000 From: Gavin Shan Date: Thu, 5 Jun 2014 16:53:40 +1000 Message-Id: <1401951221-32613-4-git-send-email-gwshan@linux.vnet.ibm.com> In-Reply-To: <1401951221-32613-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1401951221-32613-1-git-send-email-gwshan@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v8 3/4] VFIO: Introduce helper vfio_pci_container_ioctl() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org Cc: aik@ozlabs.ru, qemu-devel@nongnu.org, agraf@suse.de, alex.williamson@redhat.com, qiudayu@linux.vnet.ibm.com, Gavin Shan The patch introduces helper function vfio_pci_container_ioctl() to pass ioctl commands to the specified VFIO container that is identified by IOMMU group id. On sPAPR platform, each container only has one IOMMU group. Signed-off-by: Gavin Shan --- hw/misc/vfio.c | 31 +++++++++++++++++++++++++++++++ include/hw/misc/vfio.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 0796abf..999d97d 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -4310,3 +4310,34 @@ put_group_exit: return n; } + +int vfio_pci_container_ioctl(int iommu_group_id, int req, int opt) +{ + VFIOGroup *group; + int ret, fd = 0; + + /* Search container's fd */ + QLIST_FOREACH(group, &group_list, next) { + if (group->groupid == iommu_group_id) { + fd = group->container ? group->container->fd : 0; + break; + } + } + + if (fd <= 0) { + return -ENOENT; + } + + switch (req) { + case VFIO_EEH_PE_OP: { + struct vfio_eeh_pe_op op = { .argsz = sizeof(op), .op = opt }; + + ret = ioctl(fd, req, &op); + break; + } + default: + ret = -EINVAL; + } + + return ret; +} diff --git a/include/hw/misc/vfio.h b/include/hw/misc/vfio.h index 53ec665..dc92fae 100644 --- a/include/hw/misc/vfio.h +++ b/include/hw/misc/vfio.h @@ -30,4 +30,6 @@ static inline long vfio_kvm_notify(Notifier *n, unsigned request, void *data) return p.ret; } +extern int vfio_pci_container_ioctl(int iommu_group_id, int req, int opt); + #endif -- 1.8.3.2