From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alx49-000598-I6 for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alx44-0001gC-IU for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:16:37 -0400 Received: from mail-qg0-x22f.google.com ([2607:f8b0:400d:c04::22f]:35101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alx44-0001fG-C9 for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:16:32 -0400 Received: by mail-qg0-x22f.google.com with SMTP id y89so93613223qge.2 for ; Fri, 01 Apr 2016 04:16:32 -0700 (PDT) Sender: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= From: marcandre.lureau@redhat.com Date: Fri, 1 Apr 2016 13:16:10 +0200 Message-Id: <1459509388-6185-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 00/18] RFCv2: vhost-user: shutdown and reconnection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Yuanhan Liu , "Michael S. Tsirkin" , Ilya Maximets , jonshin@cisco.com, Tetsuya Mukawa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau Hi This is a follow-up on previous RFC allowing the slave to request a "managed" shutdown and reconnect later. A new optional communication socket is added for the slave to make request to the master (since vhost-user protocol isn't bidirectional) The initial connection must be made before the guest is started for the feature negotiation to complete. In "server" mode, qemu waits before starting the VM. However, in "client" mode with "reconnect", you have to specify "wait". This will wait for the initial connection before starting the VM (in contrast with the "nowait"+backend features proposed by Tetsuya [1]). In order to do a clean shutdown, the slave should flush all pending buffers so that after VHOST_SET_VRING_BASE, it is enough to resume. The guest is made aware of virtio-net disconnection thanks to VIRTIO_NET_S_LINK_UP status, which is reflected by a link-down on the nic. RFCv2: - rebased, added a few preliminary patches - fix a few mistakes in shutdown message recv/send - enforce "wait" when using "reconnect" - save & restore features & check backend compatibility - save & restore the ring state - add shutdown support to vhost-user-bridge Testing: - the vhost-user-test has a simple reconnect test. - vhost-user-bridge can be used to run test interactively: 1) Run a slirp/vlan in a background process: $ qemu -net none -net socket,vlan=0,udp=localhost:4444,localaddr=localhost:5555 -net user,vlan=0 2) Start vubr (it'll use the slirp/vlan process above by default): $ tests/vhost-user-bridge 3) Start qemu with vhost-user / virtio-net: $ qemu ... -chardev socket,id=char0,path=/tmp/vubr.sock,reconnect=1,wait -netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce -device virtio-net-pci,netdev=mynet1 4) Play in the guest, interrupt (ctlr-c) vubr, check nic link status, restart vubr, etc.. [1] 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. He also introduced a new option to specify backend features on qemu command line to be able to boot the VM without waiting for the backend. I consider this a seperate enhancement. Marc-André Lureau (16): tests: append i386 tests char: lower reconnect error to trace event char: use a trace for when the char is waiting char: add wait support for reconnect vhost-user: check reconnect comes with wait vhost: add vhost_dev stop callback vhost-user: add vhost_user to hold the chr vhost-user: add slave-fd support vhost-user: add shutdown support vhost-user: disconnect on start failure vhost-net: do not crash if backend is not present vhost-net: save & restore vhost-user acked features vhost-net: save & restore vring enable state test: vubr check vring enable state test: start vhost-user reconnect test test: add shutdown support vubr 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 | 53 ++++++++++++- hw/virtio/vhost-user.c | 104 +++++++++++++++++++++++++- include/hw/virtio/vhost.h | 4 + include/net/net.h | 1 + include/net/vhost-user.h | 1 + include/net/vhost_net.h | 3 + include/sysemu/char.h | 7 ++ net/vhost-user.c | 44 ++++++++++- qemu-char.c | 46 +++++++++--- tests/Makefile | 4 +- tests/vhost-user-bridge.c | 112 ++++++++++++++++++++++++++-- tests/vhost-user-test.c | 184 ++++++++++++++++++++++++++++++++++++++++++---- trace-events | 4 + 14 files changed, 564 insertions(+), 41 deletions(-) -- 2.5.5