From 0b722b79212dfd4a5fb6f7b9137c27f27bd46105 Mon Sep 17 00:00:00 2001 From: John Levon Date: Tue, 6 Apr 2021 15:37:09 +0100 Subject: vfu_reset_ctx(): tear down DMA and IRQs (#418) When we lose the client connection, the IRQ and DMA region state is no longer valid; clean them up. Signed-off-by: John Levon Reviewed-by: Thanos Makatos --- lib/libvfio-user.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/libvfio-user.c') diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index c041694..d9e58e0 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -1112,6 +1112,14 @@ vfu_reset_ctx(vfu_ctx_t *vfu_ctx, const char *reason) { vfu_log(vfu_ctx, LOG_INFO, "%s: %s", __func__, reason); + if (vfu_ctx->dma != NULL) { + dma_controller_remove_regions(vfu_ctx->dma); + } + + if (vfu_ctx->irqs != NULL) { + irqs_reset(vfu_ctx); + } + if (vfu_ctx->tran->detach != NULL) { vfu_ctx->tran->detach(vfu_ctx); } -- cgit v1.1