virtio-iommu: Use recursive lock to avoid deadlock

When switching address space with mutex lock hold, mapping will be
replayed for assigned device. This will trigger relock deadlock.

Also release the mutex resource in unrealize routine.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Message-Id: <20220613061010.2674054-3-zhenzhong.duan@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Zhenzhong Duan 2022-06-13 14:10:09 +08:00 committed by Michael S. Tsirkin
parent 90519b9053
commit 08f2030a2e
2 changed files with 12 additions and 10 deletions

View file

@ -58,7 +58,7 @@ struct VirtIOIOMMU {
ReservedRegion *reserved_regions;
uint32_t nb_reserved_regions;
GTree *domains;
QemuMutex mutex;
QemuRecMutex mutex;
GTree *endpoints;
bool boot_bypass;
};