Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com> --- 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