diff options
| author | Alex Bennée <alex.bennee@linaro.org> | 2022-11-30 11:24:38 +0000 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2022-12-01 02:30:13 -0500 |
| commit | 71e076a07dc195129fe25d90d4b276be3b2f12d8 (patch) | |
| tree | ede68f35ad6fd8c5a9e785c01dbca02a76a92a98 /include/hw/virtio/vhost-user.h | |
| parent | 060f4a944072ecf37cece0f16a0609babfb679b8 (diff) | |
| download | focaccia-qemu-71e076a07dc195129fe25d90d4b276be3b2f12d8.tar.gz focaccia-qemu-71e076a07dc195129fe25d90d4b276be3b2f12d8.zip | |
hw/virtio: generalise CHR_EVENT_CLOSED handling
..and use for both virtio-user-blk and virtio-user-gpio. This avoids the circular close by deferring shutdown due to disconnection until a later point. virtio-user-blk already had this mechanism in place so generalise it as a vhost-user helper function and use for both blk and gpio devices. While we are at it we also fix up vhost-user-gpio to re-establish the event handler after close down so we can reconnect later. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com> Message-Id: <20221130112439.2527228-5-alex.bennee@linaro.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to '')
| -rw-r--r-- | include/hw/virtio/vhost-user.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index c6e693cd3f..191216a74f 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -68,4 +68,22 @@ bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp); */ void vhost_user_cleanup(VhostUserState *user); +/** + * vhost_user_async_close() - cleanup vhost-user post connection drop + * @d: DeviceState for the associated device (passed to callback) + * @chardev: the CharBackend associated with the connection + * @vhost: the common vhost device + * @cb: the user callback function to complete the clean-up + * + * This function is used to handle the shutdown of a vhost-user + * connection to a backend. We handle this centrally to make sure we + * do all the steps and handle potential races due to VM shutdowns. + * Once the connection is disabled we call a backhalf to ensure + */ +typedef void (*vu_async_close_fn)(DeviceState *cb); + +void vhost_user_async_close(DeviceState *d, + CharBackend *chardev, struct vhost_dev *vhost, + vu_async_close_fn cb); + #endif |