From: Alex Williamson <alex.williamson@redhat.com>
To: kvm@vger.kernel.org
Cc: alex.williamson@redhat.com, avi@redhat.com, jan.kiszka@siemens.com
Subject: [PATCH 2/2] kvm: unpin guest and free iommu domain after deassign last device
Date: Thu, 29 Mar 2012 14:10:43 -0600 [thread overview]
Message-ID: <20120329201043.16338.19390.stgit@bling.home> (raw)
In-Reply-To: <20120329200701.16338.19994.stgit@bling.home>
Unpin the guest and free the iommu domain if there are no longer
any devices attached.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
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 758e3b3..9d6b31a 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -673,6 +673,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;
}
prev parent reply other threads:[~2012-03-29 20:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 20:10 [PATCH 0/2] kvm: iommu cleanup Alex Williamson
2012-03-29 20:10 ` [PATCH 1/2] kvm: unmap pages from the iommu when slots are removed Alex Williamson
2012-03-29 20:10 ` Alex Williamson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120329201043.16338.19390.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox