[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 2/7] hw/virtio: convert vhost-user-base to async shutdown
From: |
Alex Bennée |
Subject: |
[PATCH v7 2/7] hw/virtio: convert vhost-user-base to async shutdown |
Date: |
Tue, 7 Nov 2023 18:02:41 +0000 |
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>
---
hw/virtio/vhost-user-base.c | 16 ++++++++++++----
1 file 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:
--
2.39.2
- [PATCH v7 0/7] virtio: cleanup vhost-user-generic and reduce c&p, Alex Bennée, 2023/11/07
- [PATCH v7 2/7] hw/virtio: convert vhost-user-base to async shutdown,
Alex Bennée <=
- [PATCH v7 1/7] virtio: split into vhost-user-base and vhost-user-device, Alex Bennée, 2023/11/07
- [PATCH v7 3/7] hw/virtio: derive vhost-user-rng from vhost-user-base, Alex Bennée, 2023/11/07
- [PATCH v7 4/7] hw/virtio: derive vhost-user-gpio from vhost-user-base, Alex Bennée, 2023/11/07
- [PATCH v7 7/7] docs/system: add a basic enumeration of vhost-user devices, Alex Bennée, 2023/11/07
- [PATCH v7 6/7] hw/virtio: add vhost-user-snd and virtio-snd-pci devices, Alex Bennée, 2023/11/07
- [PATCH v7 5/7] hw/virtio: derive vhost-user-i2c from vhost-user-base, Alex Bennée, 2023/11/07