qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC v9 09/18] vfio: add ref for group to support own a


From: Alex Williamson
Subject: Re: [Qemu-devel] [RFC v9 09/18] vfio: add ref for group to support own affected groups
Date: Tue, 09 Jun 2015 15:23:08 -0600

On Tue, 2015-06-09 at 11:37 +0800, Chen Fan wrote:
> Signed-off-by: Chen Fan <address@hidden>
> ---
>  hw/vfio/common.c              | 12 ++++++++++++
>  include/hw/vfio/vfio-common.h |  1 +
>  2 files changed, 13 insertions(+)
> 
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 4230f83..eff1930 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -832,6 +832,7 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as)
>          goto close_fd_exit;
>      }
>  
> +    group->ref = 0;
>      group->groupid = groupid;
>      QLIST_INIT(&group->device_list);
>  
> @@ -865,6 +866,15 @@ void vfio_put_group(VFIOGroup *group)
>          return;
>      }
>  
> +    if (group->ref) {
> +        if (QLIST_EMPTY(&group->device_list)) {
> +            if (group->container) {
> +                vfio_disconnect_container(group);
> +            }
> +        }
> +        return;
> +    }

Once we disconnect the container, our file descriptor for the group
isn't sufficient for a bus reset.

> +
>      vfio_kvm_device_del_group(group);
>      if (group->container) {
>          vfio_disconnect_container(group);
> @@ -901,6 +911,7 @@ int vfio_get_device(VFIOGroup *group, const char *name,
>          return ret;
>      }
>  
> +    group->ref++;
>      vbasedev->fd = fd;
>      vbasedev->group = group;
>      QLIST_INSERT_HEAD(&group->device_list, vbasedev, next);
> @@ -921,6 +932,7 @@ void vfio_put_base_device(VFIODevice *vbasedev)
>      if (!vbasedev->group) {
>          return;
>      }
> +    vbasedev->group->ref--;
>      QLIST_REMOVE(vbasedev, next);
>      vbasedev->group = NULL;
>      trace_vfio_put_base_device(vbasedev->fd);
> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
> index 0d1fb80..3eb042e 100644
> --- a/include/hw/vfio/vfio-common.h
> +++ b/include/hw/vfio/vfio-common.h
> @@ -117,6 +117,7 @@ struct VFIODeviceOps {
>  typedef struct VFIOGroup {
>      int fd;
>      int groupid;
> +    int ref;
>      VFIOContainer *container;
>      QLIST_HEAD(, VFIODevice) device_list;
>      QLIST_ENTRY(VFIOGroup) next;






reply via email to

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