diff options
author | Kevin Wolf <kwolf@redhat.com> | 2022-01-25 16:14:35 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2022-02-01 13:49:15 +0100 |
commit | 520d8b40e898158bc9a2b416d1cbdb44d2260bc7 (patch) | |
tree | 64df91f7887219d09ac77454d20623faa9ff8693 /include | |
parent | c0829cb1fd5e0b35abfcf9fc3f04502c1ed5d7b6 (diff) | |
download | qemu-520d8b40e898158bc9a2b416d1cbdb44d2260bc7.zip qemu-520d8b40e898158bc9a2b416d1cbdb44d2260bc7.tar.gz qemu-520d8b40e898158bc9a2b416d1cbdb44d2260bc7.tar.bz2 |
block/export: Fix vhost-user-blk shutdown with requests in flight
The vhost-user-blk export runs requests asynchronously in their own
coroutine. When the vhost connection goes away and we want to stop the
vhost-user server, we need to wait for these coroutines to stop before
we can unmap the shared memory. Otherwise, they would still access the
unmapped memory and crash.
This introduces a refcount to VuServer which is increased when spawning
a new request coroutine and decreased before the coroutine exits. The
memory is only unmapped when the refcount reaches zero.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20220125151435.48792-1-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/vhost-user-server.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/qemu/vhost-user-server.h b/include/qemu/vhost-user-server.h index 121ea1d..cd43193 100644 --- a/include/qemu/vhost-user-server.h +++ b/include/qemu/vhost-user-server.h @@ -42,6 +42,8 @@ typedef struct { const VuDevIface *vu_iface; /* Protected by ctx lock */ + unsigned int refcount; + bool wait_idle; VuDev vu_dev; QIOChannel *ioc; /* The I/O channel with the client */ QIOChannelSocket *sioc; /* The underlying data channel with the client */ @@ -59,6 +61,9 @@ bool vhost_user_server_start(VuServer *server, void vhost_user_server_stop(VuServer *server); +void vhost_user_server_ref(VuServer *server); +void vhost_user_server_unref(VuServer *server); + void vhost_user_server_attach_aio_context(VuServer *server, AioContext *ctx); void vhost_user_server_detach_aio_context(VuServer *server); |