vfio/container: Introduce vfio_create_container()
This routine allocates the QEMU struct type representing the VFIO container. It is minimal currently and future changes will do more initialization. Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Tested-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
17401879c4
commit
58f5c13260
@ -430,6 +430,16 @@ static bool vfio_set_iommu(VFIOContainer *container, int group_fd,
|
|||||||
return true;
|
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,
|
static int vfio_get_iommu_info(VFIOContainer *container,
|
||||||
struct vfio_iommu_type1_info **info)
|
struct vfio_iommu_type1_info **info)
|
||||||
{
|
{
|
||||||
@ -604,13 +614,14 @@ static bool vfio_connect_container(VFIOGroup *group, AddressSpace *as,
|
|||||||
goto close_fd_exit;
|
goto close_fd_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
container = g_malloc0(sizeof(*container));
|
container = vfio_create_container(fd, group, errp);
|
||||||
container->fd = fd;
|
if (!container) {
|
||||||
bcontainer = &container->bcontainer;
|
goto close_fd_exit;
|
||||||
|
}
|
||||||
if (!vfio_set_iommu(container, group->fd, errp)) {
|
if (!vfio_set_iommu(container, group->fd, errp)) {
|
||||||
goto free_container_exit;
|
goto free_container_exit;
|
||||||
}
|
}
|
||||||
|
bcontainer = &container->bcontainer;
|
||||||
|
|
||||||
if (!vfio_cpr_register_container(bcontainer, errp)) {
|
if (!vfio_cpr_register_container(bcontainer, errp)) {
|
||||||
goto free_container_exit;
|
goto free_container_exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user