From nobody Wed Apr 16 11:38:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551770427387254.3946885345755; Mon, 4 Mar 2019 23:20:27 -0800 (PST) Received: from localhost ([127.0.0.1]:38694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h14NE-0000Em-C8 for importer@patchew.org; Tue, 05 Mar 2019 02:20:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h14G7-00032t-Ck for qemu-devel@nongnu.org; Tue, 05 Mar 2019 02:13:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h14G6-0000lX-KN for qemu-devel@nongnu.org; Tue, 05 Mar 2019 02:13:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35842) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h14G5-0000kd-3T for qemu-devel@nongnu.org; Tue, 05 Mar 2019 02:13:02 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 43EDC3082AF4; Tue, 5 Mar 2019 07:13:00 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-234.pek2.redhat.com [10.72.12.234]) by smtp.corp.redhat.com (Postfix) with ESMTP id 837E918009; Tue, 5 Mar 2019 07:12:55 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Tue, 5 Mar 2019 15:12:17 +0800 Message-Id: <1551769940-22739-11-git-send-email-jasowang@redhat.com> In-Reply-To: <1551769940-22739-1-git-send-email-jasowang@redhat.com> References: <1551769940-22739-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 05 Mar 2019 07:13:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL V2 10/13] 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: Vladislav Yasevich , Jason Wang , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Expose the virtio-net self announcement capability and allow qemu_announce_self() to call it. These announces are caused by something external (i.e. the announce-self command); they won't trigger if the migration counter is triggering announces at the same time. Signed-off-by: Vladislav Yasevich Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Michael S. Tsirkin Signed-off-by: Jason Wang --- hw/net/trace-events | 1 + hw/net/virtio-net.c | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/hw/net/trace-events b/hw/net/trace-events index b237d90..3a86004 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -361,6 +361,7 @@ sunhme_rx_desc(uint32_t addr, int offset, uint32_t stat= us, int len, int cr, int sunhme_rx_xsum_calc(uint16_t xsum) "calculated incoming xsum as 0x%x" =20 # hw/net/virtio-net.c +virtio_net_announce_notify(void) "" virtio_net_announce_timer(int round) "%d" virtio_net_handle_announce(int round) "%d" virtio_net_post_load_device(void) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 38b8974..7e2c2a6 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -150,15 +150,42 @@ static bool virtio_net_started(VirtIONet *n, uint8_t = status) (n->status & VIRTIO_NET_S_LINK_UP) && vdev->vm_running; } =20 +static void virtio_net_announce_notify(VirtIONet *net) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(net); + trace_virtio_net_announce_notify(); + + net->status |=3D VIRTIO_NET_S_ANNOUNCE; + virtio_notify_config(vdev); +} + static void virtio_net_announce_timer(void *opaque) { VirtIONet *n =3D opaque; - VirtIODevice *vdev =3D VIRTIO_DEVICE(n); trace_virtio_net_announce_timer(n->announce_timer.round); =20 n->announce_timer.round--; - n->status |=3D VIRTIO_NET_S_ANNOUNCE; - virtio_notify_config(vdev); + virtio_net_announce_notify(n); +} + +static void virtio_net_announce(NetClientState *nc) +{ + VirtIONet *n =3D qemu_get_nic_opaque(nc); + VirtIODevice *vdev =3D 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_notify(n); + } } =20 static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) @@ -2556,6 +2583,7 @@ static NetClientInfo net_virtio_info =3D { .receive =3D virtio_net_receive, .link_status_changed =3D virtio_net_set_link_status, .query_rx_filter =3D virtio_net_query_rxfilter, + .announce =3D virtio_net_announce, }; =20 static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) @@ -2692,6 +2720,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) qemu_announce_timer_reset(&n->announce_timer, migrate_announce_params(= ), QEMU_CLOCK_VIRTUAL, virtio_net_announce_timer, n); + n->announce_timer.round =3D 0; =20 if (n->netclient_type) { /* --=20 2.5.0