From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4lza-0004Pr-HU for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:13:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4lzZ-0004ft-Fo for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:13:10 -0400 Received: from [59.151.112.132] (port=55292 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4lzY-0004Q8-Ep for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:13:09 -0400 From: Chen Fan Date: Tue, 16 Jun 2015 16:10:54 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RFC v10 10/19] vfio: improve vfio_get_group to support adding as is NULL. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: izumi.taku@jp.fujitsu.com, alex.williamson@redhat.com Signed-off-by: Chen Fan --- hw/vfio/common.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index df3171d..15f19a2 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -808,11 +808,18 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as) VFIOGroup *group; char path[32]; struct vfio_group_status status = { .argsz = sizeof(status) }; + int ret; QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == groupid) { /* Found it. Now is it already in the right context? */ - if (group->container->space->as == as) { + if (as && !group->container->space->as) { + ret = vfio_register_container_listener(group->container, as); + if (ret) { + return NULL; + } + } + if (!as || group->container->space->as == as) { group->ref++; return group; } else { -- 1.9.3