[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 09/17] vfio/container: Introduce vfio_create_container()
From: |
Eric Auger |
Subject: |
Re: [PATCH v2 09/17] vfio/container: Introduce vfio_create_container() |
Date: |
Mon, 17 Jun 2024 16:29:56 +0200 |
User-agent: |
Mozilla Thunderbird |
On 6/17/24 08:34, Cédric Le Goater wrote:
> This routine allocates the QEMU struct type representing the VFIO
> container. It is minimal currently and future changes will do more
> initialization.
>
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> hw/vfio/container.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index
> bb6abe60ee29d5b69b494523c9002f53e1b2a3c8..a8691942791006f44f7a3c34b32c67ca51766182
> 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -430,6 +430,16 @@ static bool vfio_set_iommu(VFIOContainer *container, int
> group_fd,
> return true;
> }
>
> +static VFIOContainer *vfio_create_container(int fd, VFIOGroup *group,
> + Error **errp)
> +{
> + VFIOContainer *container;
> +
> + container = g_malloc0(sizeof(*container));
> + container->fd = fd;
> + return container;
> +}
> +
> static int vfio_get_iommu_info(VFIOContainer *container,
> struct vfio_iommu_type1_info **info)
> {
> @@ -604,13 +614,14 @@ static bool vfio_connect_container(VFIOGroup *group,
> AddressSpace *as,
> goto close_fd_exit;
> }
>
> - container = g_malloc0(sizeof(*container));
> - container->fd = fd;
> - bcontainer = &container->bcontainer;
> -
> + container = vfio_create_container(fd, group, errp);
> + if (!container) {
> + goto close_fd_exit;
> + }
> if (!vfio_set_iommu(container, group->fd, errp)) {
> goto free_container_exit;
> }
> + bcontainer = &container->bcontainer;
>
> if (!vfio_cpr_register_container(bcontainer, errp)) {
> goto free_container_exit;
- Re: [PATCH v2 06/17] vfio/container: Simplify vfio_container_init(), (continued)
- [PATCH v2 08/17] vfio/container: Introduce vfio_get_iommu_class_name(), Cédric Le Goater, 2024/06/17
- [PATCH v2 14/17] vfio/container: Remove VFIOContainerBase::ops, Cédric Le Goater, 2024/06/17
- [PATCH v2 12/17] vfio/container: Switch to QOM, Cédric Le Goater, 2024/06/17
- [PATCH v2 11/17] vfio/container: Change VFIOContainerBase to use QOM, Cédric Le Goater, 2024/06/17
- [PATCH v2 09/17] vfio/container: Introduce vfio_create_container(), Cédric Le Goater, 2024/06/17
- Re: [PATCH v2 09/17] vfio/container: Introduce vfio_create_container(),
Eric Auger <=
- [PATCH v2 10/17] vfio/container: Discover IOMMU type before creating the container, Cédric Le Goater, 2024/06/17
- [PATCH v2 15/17] vfio/container: Remove vfio_container_init(), Cédric Le Goater, 2024/06/17
- [PATCH v2 17/17] vfio/container: Move vfio_container_destroy() to an instance_finalize() handler, Cédric Le Goater, 2024/06/17
- [PATCH v2 13/17] vfio/container: Introduce an instance_init() handler, Cédric Le Goater, 2024/06/17
- [PATCH v2 16/17] vfio/container: Introduce vfio_iommu_legacy_instance_init(), Cédric Le Goater, 2024/06/17