From patchwork Mon Jun 6 16:45:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 9158801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0BCBB60759 for ; Mon, 6 Jun 2016 16:54:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F181626E5D for ; Mon, 6 Jun 2016 16:54:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E65C42834A; Mon, 6 Jun 2016 16:54:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B81026E5D for ; Mon, 6 Jun 2016 16:54:35 +0000 (UTC) Received: from localhost ([::1]:43845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9xnP-0003uQ-5p for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 12:54:35 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HZHEZwVj25SKCcaGHnAZDPC4M79tY4LKVn85ck6iHJc=; b=V46zysN+d9u08mj/bTOqFIevi88NrsznhFn1VHFtcBwuvYolNVFYzo9XjdsiFayOfd Qkw7mrBaAt3oRC8bV95XV2xlpN9yq4QsfUPbkGjb9mMhuq2Vel46Iea+DGMFjiPWUgfk f07W/NsFrALC4SJVAVeczw5zKIBt88oVyzMajQ1WYqxfvu/dLNTMX/v2g4nR2e9f9hDc eUKRJMtPh1eocA+vbTB/LS4Y3qVzWVXzpilNVgN5Zbbbf23Cw9wKmSHW98J/MRo1eSKH CGfQBjRJphwh+F1nCtKqudLUhlegX6lw3+H7IKhNAPTV8UWwod8epK8JvXSFE9K1RWE5 ezvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=HZHEZwVj25SKCcaGHnAZDPC4M79tY4LKVn85ck6iHJc=; b=gYPcKjQQIDMGoPalEvdakhs+Nambk4T8RkrSErKZDRxaRNlofMAADOUTtcyuzal3cy OXtHZa9w+r7u1C787ZzEIu0F1K8/C7/Y8OKrAgR5V824vNMl8/biNc2ejb1oBcXlI3Jp 8pMLkBfX/DTwAeSo4ikrZ5d8CA53r6l18qjplj6+bWPBAfRpfPLJJ1V1CRrR2I3hnPLT 7cBv/v6TNuHsCn0vyFO3C0IVbyPZfzOgvfJMjAw5rzpLvaOMJgkpTiZZ89olHZ8BvYDD 36pFJh/z+Sxi/8Z6dmcJ2Zb8dlBTjCtfT8gZ2ej1Ea4Wll+hIDb4Uvdj5zHWWiwCsdLY J8Lw== X-Gm-Message-State: ALyK8tJVrUeQR3DFWP12DxyA4MOIuM9pkQnMtCN2aIEPRTzXAqqT7vwl8NJbrJz/2UM24Q== X-Received: by 10.141.23.6 with SMTP id z6mr8716065qhd.52.1465231540533; Mon, 06 Jun 2016 09:45:40 -0700 (PDT) Received: from localhost (APoitiers-110-1-1-130.w193-248.abo.wanadoo.fr. [193.248.103.130]) by smtp.gmail.com with ESMTPSA id h132sm2057909qhh.32.2016.06.06.09.45.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2016 09:45:39 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2016 18:45:06 +0200 Message-Id: <1465231508-30183-9-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.7.4 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::244 Subject: [Qemu-devel] [PATCH 08/10] vhost-net: save & restore vring enable state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yuanhan Liu , "Michael S . Tsirkin" , Ilya Maximets , jonshin@cisco.com, Tetsuya Mukawa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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; };