diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2024-01-04 21:09:36 +0000 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2024-02-14 06:01:42 -0500 |
commit | 64a312a2737e3aab97f103b76f8e76a97770e670 (patch) | |
tree | 67eefa9774a82bb6d06bd18e088c5b20e2a06016 /hw/virtio | |
parent | 6275989647efb708f126eb4f880e593792301ed4 (diff) |
hw/virtio: convert vhost-user-base to async shutdown
We are about to convert at least one stubs which was using the async
teardown so lets use it for all the cases.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240104210945.1223134-3-alex.bennee@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r-- | hw/virtio/vhost-user-base.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 620fa5cb4a..78cfa9a5bb 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -201,6 +201,8 @@ static int vub_connect(DeviceState *dev) return 0; } +static void vub_event(void *opaque, QEMUChrEvent event); + static void vub_disconnect(DeviceState *dev) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -211,9 +213,13 @@ static void vub_disconnect(DeviceState *dev) } vub->connected = false; - if (vhost_dev_is_started(&vub->vhost_dev)) { - vub_stop(vdev); - } + vub_stop(vdev); + vhost_dev_cleanup(&vub->vhost_dev); + + /* Re-instate the event handler for new connections */ + qemu_chr_fe_set_handlers(&vub->chardev, + NULL, NULL, vub_event, + NULL, dev, NULL, true); } static void vub_event(void *opaque, QEMUChrEvent event) @@ -230,7 +236,9 @@ static void vub_event(void *opaque, QEMUChrEvent event) } break; case CHR_EVENT_CLOSED: - vub_disconnect(dev); + /* defer close until later to avoid circular close */ + vhost_user_async_close(dev, &vub->chardev, &vub->vhost_dev, + vub_disconnect, vub_event); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: |