From 7185c8577653533ee89e7d070d77473096f0ff74 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 24 Sep 2020 16:15:45 +0100 Subject: util/vhost-user-server: rework vu_client_trip() coroutine lifecycle The vu_client_trip() coroutine is leaked during AioContext switching. It is also unsafe to destroy the vu_dev in panic_cb() since its callers still access it in some cases. Rework the lifecycle to solve these safety issues. Signed-off-by: Stefan Hajnoczi Message-id: 20200924151549.913737-10-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- block/export/vhost-user-blk-server.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'block/export') diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user-blk-server.c index c8fa4ec..4d35232 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -313,18 +313,13 @@ static const VuDevIface vu_block_iface = { static void blk_aio_attached(AioContext *ctx, void *opaque) { VuBlockDev *vub_dev = opaque; - aio_context_acquire(ctx); - vhost_user_server_set_aio_context(&vub_dev->vu_server, ctx); - aio_context_release(ctx); + vhost_user_server_attach_aio_context(&vub_dev->vu_server, ctx); } static void blk_aio_detach(void *opaque) { VuBlockDev *vub_dev = opaque; - AioContext *ctx = vub_dev->vu_server.ctx; - aio_context_acquire(ctx); - vhost_user_server_set_aio_context(&vub_dev->vu_server, NULL); - aio_context_release(ctx); + vhost_user_server_detach_aio_context(&vub_dev->vu_server); } static void -- cgit v1.1