From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsiWZ-0007hS-BS for qemu-devel@nongnu.org; Thu, 05 Jun 2014 21:01:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsiWP-0006Yt-Qk for qemu-devel@nongnu.org; Thu, 05 Jun 2014 21:00:51 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:43257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsiWP-0006Yj-2f for qemu-devel@nongnu.org; Thu, 05 Jun 2014 21:00:41 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 6 Jun 2014 11:00:35 +1000 Date: Fri, 6 Jun 2014 11:00:33 +1000 From: Gavin Shan Message-ID: <20140606010033.GA18402@shangw> References: <1401951221-32613-1-git-send-email-gwshan@linux.vnet.ibm.com> <1401951221-32613-4-git-send-email-gwshan@linux.vnet.ibm.com> <53905E69.3010903@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <53905E69.3010903@suse.de> Subject: Re: [Qemu-devel] [PATCH v8 3/4] VFIO: Introduce helper vfio_pci_container_ioctl() Reply-To: Gavin Shan List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: aik@ozlabs.ru, Gavin Shan , qemu-devel@nongnu.org, alex.williamson@redhat.com, qemu-ppc@nongnu.org, qiudayu@linux.vnet.ibm.com On Thu, Jun 05, 2014 at 02:11:21PM +0200, Alexander Graf wrote: > >On 05.06.14 08:53, Gavin Shan wrote: >>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) { > >fd 0 is a valid file descriptor. > Yep, I'll fix :) Thanks, Gavin > >Alex >