diff options
author | John Levon <john.levon@nutanix.com> | 2021-04-06 15:55:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 15:55:02 +0100 |
commit | c42ac841ad1d0094d6f6173e4f8bb4f231f8962b (patch) | |
tree | 050ed4bbd37d65dc8e71ede1ce310a6efd285d8f /lib/libvfio-user.c | |
parent | 0b722b79212dfd4a5fb6f7b9137c27f27bd46105 (diff) | |
download | libvfio-user-c42ac841ad1d0094d6f6173e4f8bb4f231f8962b.zip libvfio-user-c42ac841ad1d0094d6f6173e4f8bb4f231f8962b.tar.gz libvfio-user-c42ac841ad1d0094d6f6173e4f8bb4f231f8962b.tar.bz2 |
call reset callback on losing client connection (#419)
Give API users an opportunity to clean up when a client disconnects from the
vfio-user socket.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/libvfio-user.c')
-rw-r--r-- | lib/libvfio-user.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index d9e58e0..b5c7739 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -567,7 +567,7 @@ handle_device_reset(vfu_ctx_t *vfu_ctx) { vfu_log(vfu_ctx, LOG_DEBUG, "Device reset called by client"); if (vfu_ctx->reset != NULL) { - return vfu_ctx->reset(vfu_ctx); + return vfu_ctx->reset(vfu_ctx, VFU_RESET_DEVICE); } return 0; } @@ -1112,6 +1112,10 @@ 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_regions(vfu_ctx->dma); } @@ -1413,10 +1417,8 @@ out: int vfu_setup_device_reset_cb(vfu_ctx_t *vfu_ctx, vfu_reset_cb_t *reset) { - assert(vfu_ctx != NULL); vfu_ctx->reset = reset; - return 0; } |