From: Marc-André Lureau <marcandre.lur...@redhat.com> In a previous series "Add feature to start QEMU without vhost-user backend", Tetsuya Mukawa proposed to allow the vhost-user backend to disconnect and reconnect. However, Michael Tsirkin pointed out that you can't do that without extra care, because the guest and hypervisor don't know the slave ring manipulation state, there might be pending replies for example that could be lost, and suggested to reset the guest queues, but this requires kernel changes, and it may have to clear the ring and lose queued packets.
The following series starts from the idea that the slave can request a "managed" shutdown instead and later recover (I guess the use case for this is to allow for example to update static dispatching/filter rules etc) In order to do it, the slave must be in a good state, that is it should flush all pending buffers so that resume after VHOST_SET_VRING_BASE is enough to resume where it lefts. The guest is made aware of virtio-net disconnection thanks to VIRTIO_NET_S_LINK_UP status, so communication can be stopped. Unfortunately, vhost-user protocol isn't bidirectional, so a new optional communication channel is added for the slave to make request to the master, such as a the new shutdown request. I have done some testing with modified vapp and linux 4.2, it seems to work just fine. But more intensive testing and review are required, as I am not sure this approach can be made solid enough. Before going further, I would welcome any comment or testing suggestions! The series is based on top of pending vhost-user migration series, but for easier testing you may just use the following git repo: https://github.com/elmarco/qemu vhost-user-reconnect branch Marc-André Lureau (12): vhost-user: remove useless is_server field qemu-char: avoid potential double-free qemu-char: remove all msgfds on disconnect qemu-char: make tcp_chr_disconnect() reentrant-safe vhost-net: keep VIRTIO_NET_F_STATUS for vhost-user virtio-net: enable tx notification if up and vhost started vhost: add vhost_dev stop callback vhost-user: add vhost_user to hold the chr qemu-char: add qemu_chr_free() vhost-user: add slave-fd support vhost-user: add shutdown support test: start vhost-user reconnect test Tetsuya Mukawa (2): vhost-user: Add ability to know vhost-user backend disconnection qemu-char: Add qemu_chr_disconnect to close a fd accepted by listen fd docs/specs/vhost-user.txt | 38 +++++++++++ hw/net/vhost_net.c | 14 +++- hw/net/virtio-net.c | 4 ++ hw/virtio/vhost-user.c | 120 +++++++++++++++++++++++++++++++-- include/hw/virtio/vhost.h | 4 ++ include/sysemu/char.h | 17 ++++- net/vhost-user.c | 20 +++++- qemu-char.c | 23 ++++++- tests/Makefile | 2 +- tests/vhost-user-test.c | 168 ++++++++++++++++++++++++++++++++++++++++++---- 10 files changed, 384 insertions(+), 26 deletions(-) -- 2.4.3