aboutsummaryrefslogtreecommitdiff
path: root/lib/libvfio-user.c
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-02-04 09:58:55 +0000
committerGitHub <noreply@github.com>2021-02-04 09:58:55 +0000
commit8f464f0f52ac4c10b1c10376d26eddc644492966 (patch)
tree1264657242e5f5bb6f8ed552a4289a2d6c5d05b9 /lib/libvfio-user.c
parent3eca929802ed6efb57d9ee37a3d6728e3b8521c8 (diff)
downloadlibvfio-user-8f464f0f52ac4c10b1c10376d26eddc644492966.zip
libvfio-user-8f464f0f52ac4c10b1c10376d26eddc644492966.tar.gz
libvfio-user-8f464f0f52ac4c10b1c10376d26eddc644492966.tar.bz2
close listening socket in vfu_destroy_ctx() (#299)
We were forgetting to close vfu_ctx->fd, add a tran callback for this. While we're there, clean up the tran callbacks somewhat. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'lib/libvfio-user.c')
-rw-r--r--lib/libvfio-user.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 83fb9a5..fce7923 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -1088,6 +1088,11 @@ vfu_destroy_ctx(vfu_ctx_t *vfu_ctx)
if (vfu_ctx->trans->detach != NULL) {
vfu_ctx->trans->detach(vfu_ctx);
}
+
+ if (vfu_ctx->trans->fini != NULL) {
+ vfu_ctx->trans->fini(vfu_ctx);
+ }
+
if (vfu_ctx->dma != NULL) {
dma_controller_destroy(vfu_ctx->dma);
}
@@ -1123,6 +1128,8 @@ vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt,
vfu_ctx_t *vfu_ctx = NULL;
int err = 0;
+ //FIXME: Validate arguments.
+
if (trans != VFU_TRANS_SOCK) {
errno = ENOTSUP;
return NULL;
@@ -1138,11 +1145,11 @@ vfu_create_ctx(vfu_trans_t trans, const char *path, int flags, void *pvt,
errno = ENOMEM;
return NULL;
}
+
+ vfu_ctx->fd = -1;
+ vfu_ctx->conn_fd = -1;
vfu_ctx->dev_type = dev_type;
vfu_ctx->trans = &sock_transport_ops;
-
- //FIXME: Validate arguments.
- // Set other context data.
vfu_ctx->pvt = pvt;
vfu_ctx->flags = flags;
vfu_ctx->log_level = LOG_ERR;