From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9xer-0004Ua-6O for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9xen-0005cT-1M for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:44 -0400 Received: from mail-qg0-x244.google.com ([2607:f8b0:400d:c04::244]:36811) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9xem-0005cO-Sn for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:40 -0400 Received: by mail-qg0-x244.google.com with SMTP id k43so5933019qgk.3 for ; Mon, 06 Jun 2016 09:45:40 -0700 (PDT) Sender: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= From: marcandre.lureau@redhat.com Date: Mon, 6 Jun 2016 18:45:06 +0200 Message-Id: <1465231508-30183-9-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1465231508-30183-1-git-send-email-marcandre.lureau@redhat.com> References: <1465231508-30183-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 08/10] vhost-net: save & restore vring enable state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , Tetsuya Mukawa , jonshin@cisco.com, Ilya Maximets , Yuanhan Liu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau A driver may change the vring enable state at run time but vhost-user backend may not be present (a contrived example is when the backend is disconnected and the device is reconfigured after driver rebinding) Restore the vring state when the vhost-user backend is started, so it can process the ring. Signed-off-by: Marc-André Lureau Tested-by: Yuanhan Liu Reviewed-by: Yuanhan Liu --- hw/net/vhost_net.c | 11 +++++++++++ include/net/net.h | 1 + 2 files changed, 12 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index b28881f..50f4dcd 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -329,6 +329,15 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, if (r < 0) { goto err_start; } + + if (ncs[i].peer->vring_enable) { + /* restore vring enable state */ + r = vhost_set_vring_enable(ncs[i].peer, ncs[i].peer->vring_enable); + + if (r < 0) { + goto err_start; + } + } } return 0; @@ -422,6 +431,8 @@ int vhost_set_vring_enable(NetClientState *nc, int enable) VHostNetState *net = get_vhost_net(nc); const VhostOps *vhost_ops; + nc->vring_enable = enable; + if (!net) { return 0; } diff --git a/include/net/net.h b/include/net/net.h index a69e382..a5c5095 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -99,6 +99,7 @@ struct NetClientState { NetClientDestructor *destructor; unsigned int queue_index; unsigned rxfilter_notify_enabled:1; + int vring_enable; QTAILQ_HEAD(NetFilterHead, NetFilterState) filters; }; -- 2.7.4