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 <stefanha@redhat.com>
Message-id: 20200924151549.913737-10-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2020-09-24 16:15:45 +01:00
parent edaf6205a3
commit 7185c85776
3 changed files with 157 additions and 130 deletions

View file

@ -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