aboutsummaryrefslogtreecommitdiff
path: root/lib/libvfio-user.c
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-05-10 12:59:01 +0100
committerGitHub <noreply@github.com>2021-05-10 12:59:01 +0100
commitb95c886ed23b4cc4c539030bf383b55aae8859a3 (patch)
treed032be6eff881d8ff69ea94a29b459546876d97a /lib/libvfio-user.c
parent12ee57e1101e7059361d41011211bc4e8aef20fc (diff)
downloadlibvfio-user-b95c886ed23b4cc4c539030bf383b55aae8859a3.zip
libvfio-user-b95c886ed23b4cc4c539030bf383b55aae8859a3.tar.gz
libvfio-user-b95c886ed23b4cc4c539030bf383b55aae8859a3.tar.bz2
fix dma unregister callback during region removal (#464)
There are two issues with the unregister callback: - we were requiring the callback to be set when removing a region, but it's only required if a consumer wants to map regions - when we removed all regions (for example, on a reset), we weren't triggering the callback Signed-off-by: John Levon <john.levon@nutanix.com> swapnil code review add assert Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'lib/libvfio-user.c')
-rw-r--r--lib/libvfio-user.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 92c1724..88135f2 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -1086,12 +1086,13 @@ vfu_reset_ctx(vfu_ctx_t *vfu_ctx, const char *reason)
{
vfu_log(vfu_ctx, LOG_INFO, "%s: %s", __func__, reason);
- if (vfu_ctx->reset != NULL) {
- vfu_ctx->reset(vfu_ctx, VFU_RESET_LOST_CONN);
+ if (vfu_ctx->dma != NULL) {
+ dma_controller_remove_all_regions(vfu_ctx->dma, vfu_ctx->dma_unregister,
+ vfu_ctx);
}
- if (vfu_ctx->dma != NULL) {
- dma_controller_remove_regions(vfu_ctx->dma);
+ if (vfu_ctx->reset != NULL) {
+ vfu_ctx->reset(vfu_ctx, VFU_RESET_LOST_CONN);
}
if (vfu_ctx->irqs != NULL) {