From patchwork Wed May 24 18:05:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlad Yasevich X-Patchwork-Id: 9746727 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 2B742601C2 for ; Wed, 24 May 2017 18:11:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BDF9289CE for ; Wed, 24 May 2017 18:11:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1048D289D0; Wed, 24 May 2017 18:11:03 +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 A1EDA289CD for ; Wed, 24 May 2017 18:11:02 +0000 (UTC) Received: from localhost ([::1]:56209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDakP-0007gw-Pi for patchwork-qemu-devel@patchwork.kernel.org; Wed, 24 May 2017 14:11:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafT-0003qP-6K for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafR-0001L6-V8 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60512) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafR-0001Kr-BV for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58B1012B9A for ; Wed, 24 May 2017 18:05:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 58B1012B9A Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 58B1012B9A Received: from flash.redhat.com (ovpn-116-215.phx2.redhat.com [10.3.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id D82AB77D61; Wed, 24 May 2017 18:05:50 +0000 (UTC) From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:21 -0400 Message-Id: <1495649128-10529-6-git-send-email-vyasevic@redhat.com> In-Reply-To: <1495649128-10529-1-git-send-email-vyasevic@redhat.com> References: <1495649128-10529-1-git-send-email-vyasevic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 24 May 2017 18:05:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 05/12] virtio-net: Allow qemu_announce_self to trigger virtio announcements 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: germano@redhat.com, lvivier@redhat.com, mst@redhat.com, jasowang@redhat.com, Vladislav Yasevich , armbru@redhat.com, kashyap@redhat.com, jdenemar@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Expose the virtio-net self annoucement capability and allow qemu_announce_self() to call it. Signed-off-by: Vladislav Yasevich Reviewed-by: Jason Wang --- hw/net/virtio-net.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 1c65825..4adafbd 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -111,14 +111,38 @@ static bool virtio_net_started(VirtIONet *n, uint8_t status) (n->status & VIRTIO_NET_S_LINK_UP) && vdev->vm_running; } +static void __virtio_net_announce(VirtIONet *net) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(net); + + net->status |= VIRTIO_NET_S_ANNOUNCE; + virtio_notify_config(vdev); +} + static void virtio_net_announce_timer(void *opaque) { VirtIONet *n = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(n); n->announce_timer->round--; - n->status |= VIRTIO_NET_S_ANNOUNCE; - virtio_notify_config(vdev); + __virtio_net_announce(n); +} + +static void virtio_net_announce(NetClientState *nc) +{ + VirtIONet *n = qemu_get_nic_opaque(nc); + VirtIODevice *vdev = VIRTIO_DEVICE(n); + + /* Make sure the virtio migration announcement timer isn't running + * If it is, let it trigger announcement so that we do not cause + * confusion. + */ + if (n->announce_timer->round) + return; + + if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) && + virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { + __virtio_net_announce(n); + } } static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) @@ -1834,6 +1858,7 @@ static NetClientInfo net_virtio_info = { .receive = virtio_net_receive, .link_status_changed = virtio_net_set_link_status, .query_rx_filter = virtio_net_query_rxfilter, + .announce = virtio_net_announce, }; static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) @@ -1941,6 +1966,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) n->status = VIRTIO_NET_S_LINK_UP; n->announce_timer = qemu_announce_timer_new(qemu_get_announce_params(), QEMU_CLOCK_VIRTUAL); + n->announce_timer->round = 0; n->announce_timer->tm = timer_new_ms(QEMU_CLOCK_VIRTUAL, virtio_net_announce_timer, n);