Unpin the guest and free the iommu domain if there are no longer any devices attached. Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx> --- virt/kvm/assigned-dev.c | 3 +++ virt/kvm/iommu.c | 1 + 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c index 01f572c..01e7c37 100644 --- a/virt/kvm/assigned-dev.c +++ b/virt/kvm/assigned-dev.c @@ -765,6 +765,9 @@ static int kvm_vm_ioctl_deassign_device(struct kvm *kvm, kvm_free_assigned_device(kvm, match); + if (list_empty(&kvm->arch.assigned_dev_head)) + kvm_iommu_unmap_guest(kvm); + out: mutex_unlock(&kvm->lock); return r; diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c index fec1723..ee4c236 100644 --- a/virt/kvm/iommu.c +++ b/virt/kvm/iommu.c @@ -342,5 +342,6 @@ int kvm_iommu_unmap_guest(struct kvm *kvm) kvm_iommu_unmap_memslots(kvm); iommu_domain_free(domain); + kvm->arch.iommu_domain = NULL; return 0; } -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html