qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v7 2/3] VFIO: Helper function to retrieve container


From: Gavin Shan
Subject: [Qemu-devel] [PATCH v7 2/3] VFIO: Helper function to retrieve container fd
Date: Tue, 27 May 2014 18:51:09 +1000

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 <address@hidden>
---
 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
-- 
1.8.3.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]