From patchwork Fri Feb 16 17:29:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 10225217 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 C2E5A602CB for ; Fri, 16 Feb 2018 17:34:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B34CE29622 for ; Fri, 16 Feb 2018 17:34:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6FA129627; Fri, 16 Feb 2018 17:34:19 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 502D329625 for ; Fri, 16 Feb 2018 17:34:19 +0000 (UTC) Received: from localhost ([::1]:43089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emjtq-0006SD-H5 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Feb 2018 12:34:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emjp8-0002RV-3P for qemu-devel@nongnu.org; Fri, 16 Feb 2018 12:29:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emjp5-0007he-6L for qemu-devel@nongnu.org; Fri, 16 Feb 2018 12:29:26 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43602 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1emjp5-0007h5-27 for qemu-devel@nongnu.org; Fri, 16 Feb 2018 12:29:23 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9791D402291E for ; Fri, 16 Feb 2018 17:29:22 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BB8B2024CA1; Fri, 16 Feb 2018 17:29:21 +0000 (UTC) From: Maxime Coquelin To: stefanha@redhat.com, mst@redhat.com, mlureau@redhat.com, qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 18:29:08 +0100 Message-Id: <20180216172910.8549-4-maxime.coquelin@redhat.com> In-Reply-To: <20180216172910.8549-1-maxime.coquelin@redhat.com> References: <20180216172910.8549-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 16 Feb 2018 17:29:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 16 Feb 2018 17:29:22 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 3/5] vhost_net: send virtio device status update to the backend 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: Maxime Coquelin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds ans uses a new function to send virtio device status updates to the backend. Suggested-by: Stefan Hajnoczi Signed-off-by: Maxime Coquelin --- hw/net/vhost_net.c | 10 ++++++++++ hw/net/virtio-net.c | 7 ++++++- include/net/vhost_net.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index e037db63a3..75e2165163 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -450,6 +450,11 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu) return vhost_ops->vhost_net_set_mtu(&net->dev, mtu); } +int vhost_net_set_virtio_status(struct vhost_net *net, uint8_t status) +{ + return vhost_dev_set_virtio_status(&net->dev, status); +} + #else uint64_t vhost_net_get_max_queues(VHostNetState *net) { @@ -521,4 +526,9 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu) { return 0; } + +int vhost_net_set_virtio_status(struct vhost_net *net, uint8_t status) +{ + return 0; +} #endif diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 38674b08aa..06c431ea28 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -136,7 +136,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) if ((virtio_net_started(n, status) && !nc->peer->link_down) == !!n->vhost_started) { - return; + goto out; } if (!n->vhost_started) { int r, i; @@ -175,11 +175,16 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) error_report("unable to start vhost net: %d: " "falling back on userspace virtio", -r); n->vhost_started = 0; + + return; } } else { vhost_net_stop(vdev, n->nic->ncs, queues); n->vhost_started = 0; } + +out: + vhost_net_set_virtio_status(get_vhost_net(nc->peer), status); } static int virtio_net_set_vnet_endian_one(VirtIODevice *vdev, diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index afc1499eb9..bf083e2d2e 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -37,4 +37,6 @@ uint64_t vhost_net_get_acked_features(VHostNetState *net); int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu); +int vhost_net_set_virtio_status(struct vhost_net *net, uint8_t status); + #endif