Skip to content

Commit

Permalink
iommu/vfio: only set iommu on container once
Browse files Browse the repository at this point in the history
Do not try to set iommu on container if done previously.

Signed-off-by: Klaus Jensen <[email protected]>
  • Loading branch information
birkelund committed Apr 17, 2024
1 parent c16ef72 commit 4f6fed3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/iommu/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ struct vfio_container {
pthread_mutex_t lock;
uint64_t next, next_ephemeral, nephemerals;
struct iommu_iova_range ephemerals;

bool iommu_set;
};

static struct vfio_container vfio_default_container = {
Expand Down Expand Up @@ -245,11 +247,16 @@ static int vfio_iommu_type1_init(struct vfio_container *vfio)
{
uint64_t iova;

if (vfio->iommu_set)
return 0;

if (ioctl(vfio->fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU)) {
log_debug("failed to set vfio iommu type\n");
return -1;
}

vfio->iommu_set = true;

#ifdef VFIO_IOMMU_INFO_CAPS
if (vfio_iommu_type1_get_capabilities(vfio)) {
log_debug("failed to get iommu capabilities\n");
Expand Down

0 comments on commit 4f6fed3

Please sign in to comment.