From patchwork Tue May 10 16:03:58 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: 9059971 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D73FDBF29F for ; Tue, 10 May 2016 16:06:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A475200DB for ; Tue, 10 May 2016 16:06:48 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id D4BCD20149 for ; Tue, 10 May 2016 16:06:46 +0000 (UTC) Received: from localhost ([::1]:47311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0ABJ-00027h-Ra for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 May 2016 12:06:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0A97-0006nU-Sf for qemu-devel@nongnu.org; Tue, 10 May 2016 12:04:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0A93-0007DC-Io for qemu-devel@nongnu.org; Tue, 10 May 2016 12:04:29 -0400 Received: from mail-qk0-x22b.google.com ([2607:f8b0:400d:c09::22b]:33930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0A93-0007D2-EX for qemu-devel@nongnu.org; Tue, 10 May 2016 12:04:25 -0400 Received: by mail-qk0-x22b.google.com with SMTP id r184so9441713qkc.1 for ; Tue, 10 May 2016 09:04:25 -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=DKeH/S0enUDOdKTIUecU32NcFKXQjbaTCzOfk5Gwy6g=; b=GMdiOC5NbNWaiNhJOlo8gMvJoibEBztiNvVSQCQVTW4jI6YEVZgY5PVHcYrGHiD0Yn ZoOG//Gsz1lBC+pou7017ciAAWfUyV0tqwoEsI/ySghWiemvyV4CpATUeFhxI1ED76gJ Vmf5TF+lmsdDdOJFMq+hIPLwIzkPyGurb3+ic38YPHUVswTj1kbZ5ExWnY5Q0Fc+ITxY 2HsSAPfAOL1yv8No9jUBHd2+oO2YC49BAGIZOABuaEnlehvTIWBMaQc2f4kwgp/4t3TL 5MvLfPZQALmYVIz72DtfYemF4mms3lJoSYaTxQudvHJ3DSavNCUWeSi2Frn8dXsmPiBK wwNw== 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=DKeH/S0enUDOdKTIUecU32NcFKXQjbaTCzOfk5Gwy6g=; b=OPj7w6v+MHJLuGqbIAWs4FgFEPcQEEw3hx0a2l06OIbEivEbeOs7KzkW0y/DbLQVM4 R6hkeGJVi8E7qymnW3FoPmytTpUdN/FLwVHosV5eYVMWlh7vzXPzvG3uTGGi06TG5Aux 1NWK7ti4MLND1c5z+SiQDN99s/45UUXrqCKyvzskcYs/Vj1HZbwEADH/0Nmy0cv38/vR hd0eiAAwcdZ3O19vINARUNvbJWUIWixVQKe0X3MBLeEGP6xxnfTz/pxve5ZgFk63dxvX ea4M3cqoNU1e3Z7QCsTqfOh8gwhgC+jWAFIz/lACN/QYFE7ZFf5Y0bNRHB62ekub7dzT bweQ== X-Gm-Message-State: AOPr4FVNr3fmxIFaaCusYjPEF5tmytj4kLpF7/Z0Yxap4aYlp3nOdqSzBgMAZbeQv67RMw== X-Received: by 10.55.111.66 with SMTP id k63mr44733003qkc.2.1462896265004; Tue, 10 May 2016 09:04:25 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id l4sm1184271qkl.45.2016.05.10.09.04.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 May 2016 09:04:24 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Tue, 10 May 2016 18:03:58 +0200 Message-Id: <1462896240-30999-9-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462896240-30999-1-git-send-email-marcandre.lureau@redhat.com> References: <1462896240-30999-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:c09::22b 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-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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 --- 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 f3df18c..722e3f3 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 73e4c46..2c4b23a 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -92,6 +92,7 @@ struct NetClientState { NetClientDestructor *destructor; unsigned int queue_index; unsigned rxfilter_notify_enabled:1; + int vring_enable; QTAILQ_HEAD(NetFilterHead, NetFilterState) filters; };