On Tue, May 27, 2014 at 08:16:47AM -0600, Alex Williamson wrote: >On Tue, 2014-05-27 at 18:51 +1000, Gavin Shan wrote: >> The patch adds function vfio_get_container_fd_by_group_id() to retrieve >> the container's fd of the specified VFIO group. The fd will be used >> by subsequent patches. >> >> Signed-off-by: Gavin Shan <gws...@linux.vnet.ibm.com> >> --- >> hw/misc/vfio.c | 17 +++++++++++++++++ >> include/hw/misc/vfio.h | 1 + >> 2 files changed, 18 insertions(+) >> >> diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c >> index 0796abf..424d467 100644 >> --- a/hw/misc/vfio.c >> +++ b/hw/misc/vfio.c >> @@ -4310,3 +4310,20 @@ put_group_exit: >> >> return n; >> } >> + >> +int vfio_get_container_fd_by_group_id(int32_t groupid) >> +{ >> + VFIOGroup *group; >> + >> + QLIST_FOREACH(group, &group_list, next) { >> + if (group->groupid == groupid) { >> + if (group->container) { >> + return group->container->fd; >> + } else { >> + return -ENOENT; >> + } >> + } >> + } >> + >> + return -ENOENT; >> +} >> diff --git a/include/hw/misc/vfio.h b/include/hw/misc/vfio.h >> index 53ec665..a5afebd 100644 >> --- a/include/hw/misc/vfio.h >> +++ b/include/hw/misc/vfio.h >> @@ -30,4 +30,5 @@ static inline long vfio_kvm_notify(Notifier *n, unsigned >> request, void *data) >> return p.ret; >> } >> >> +extern int vfio_get_container_fd_by_group_id(int32_t groupid); >> #endif > >NAK, get implies a reference, there is none here. >
Well, how about to have vfio_find_container_fd_by_group_id() or just vfio_container_fd_by_group_id() ? Thanks, Gavin