From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmMBO-0002YI-8v for qemu-devel@nongnu.org; Sun, 26 Apr 2015 09:01:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmMBL-0004Ds-2D for qemu-devel@nongnu.org; Sun, 26 Apr 2015 09:01:14 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:34423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmMBK-0004Dj-T1 for qemu-devel@nongnu.org; Sun, 26 Apr 2015 09:01:10 -0400 Received: by wicmx19 with SMTP id mx19so65124732wic.1 for ; Sun, 26 Apr 2015 06:01:10 -0700 (PDT) From: Luke Gorrie Date: Sun, 26 Apr 2015 15:00:49 +0200 Message-Id: <1430053249-31553-2-git-send-email-luke@snabb.co> In-Reply-To: <1430053249-31553-1-git-send-email-luke@snabb.co> References: <1430053249-31553-1-git-send-email-luke@snabb.co> Subject: [Qemu-devel] [PATCH] vhost-user: Send VHOST_RESET_OWNER on vhost stop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Luke Gorrie , n.nikolaev@virtualopensystems.com, mst@redhat.com Ensure that the vhost-user slave knows when the vrings are valid and when they are invalid, for example during a guest reboot. The vhost-user protocol says this of VHOST_RESET_OWNER: Issued when a new connection is about to be closed. The Master will no longer own this connection (and will usually close it). Send this message to tell the vhost-user slave that the vhost session has ended and that session state (e.g. vrings) is no longer valid. Signed-off-by: Luke Gorrie --- hw/net/vhost_net.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index cf23335..47f8b89 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -263,6 +263,13 @@ static void vhost_net_stop_one(struct vhost_net *net, &file); assert(r >= 0); } + } else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) { + for (file.index = 0; file.index < net->dev.nvqs; ++file.index) { + const VhostOps *vhost_ops = net->dev.vhost_ops; + int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_OWNER, + NULL); + assert(r >= 0); + } } if (net->nc->info->poll) { net->nc->info->poll(net->nc, true); -- 2.1.4