From nobody Thu May 16 23:30:13 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561059149; cv=none; d=zoho.com; s=zohoarc; b=Hj+/2hEOZyV3R3In3C8Zu2mxtCWg4neGMbSr9Yt2Z5BMnKwiKAuXgadpkakLNBm8LjWxnwl+bpswGWWpbAEKt18BgmPBrly4ITzB3wrtlSU9ppKavL1df/EwpeyxN4XPXSsD90TPiKo5VjXMPovjXGaAp3bjQFV8b5U+jfWq+lA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561059149; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=SdCReZ/mZ9XHojS/Td45fgjuxnXmanB0FxmE2mLdtXI=; b=fRLbF+Gyddq8fslLhLuQjwwCPzYxPbNxGx7okqcLAebEt7gJ3rItldbhiIuJVFM/ZZq2nj0RP6sjyMsFh0/xU9MEehC46uXHb1B6gzOQbhO/FVjaF0HImeA73pNQb4VFtBa8FUwuI1WvhqkjCW/LW0k65TQAPKJb7tiCbn0g2no= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561059149762519.6391374758787; Thu, 20 Jun 2019 12:32:29 -0700 (PDT) Received: from localhost ([::1]:52428 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he2nJ-0003Vg-OU for importer@patchew.org; Thu, 20 Jun 2019 15:32:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49682) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he26Y-0003c0-FO for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he26U-0000dT-TO for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55282) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1he26U-0008LQ-L5 for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7A77308FB9D for ; Thu, 20 Jun 2019 18:47:13 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-203.ams2.redhat.com [10.36.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id 775CA5D772; Thu, 20 Jun 2019 18:47:12 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, jasowang@redhat.com, eblake@redhat.com, armbru@redhat.com, laine@redhat.com Date: Thu, 20 Jun 2019 19:47:02 +0100 Message-Id: <20190620184706.19988-2-dgilbert@redhat.com> In-Reply-To: <20190620184706.19988-1-dgilbert@redhat.com> References: <20190620184706.19988-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 20 Jun 2019 18:47:13 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v5 1/5] net/announce: Allow optional list of interfaces X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Allow the caller to restrict the set of interfaces that announces are sent on. The default is still to send on all interfaces. e.g. { "execute": "announce-self", "arguments": { "initial": 50, "max": 550, "= rounds": 5, "step": 50, "interfaces": ["vn2", "vn1"] } } This doesn't affect the behaviour of migraiton announcments. Note: There's still only one timer for the qmp command, so that performing an 'announce-self' on one list of interfaces followed by another 'announce-self' on another list will stop the announces on the existing set. Signed-off-by: Dr. David Alan Gilbert --- include/net/announce.h | 2 +- net/announce.c | 39 ++++++++++++++++++++++++++++++++------- net/trace-events | 2 +- qapi/net.json | 11 ++++++++--- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/include/net/announce.h b/include/net/announce.h index 04a035f679..773470428b 100644 --- a/include/net/announce.h +++ b/include/net/announce.h @@ -22,7 +22,7 @@ struct AnnounceTimer { /* Returns: update the timer to the next time point */ int64_t qemu_announce_timer_step(AnnounceTimer *timer); =20 -/* Delete the underlying timer */ +/* Delete the underlying timer and other data */ void qemu_announce_timer_del(AnnounceTimer *timer); =20 /* diff --git a/net/announce.c b/net/announce.c index 91e9a6e267..1ce42b571d 100644 --- a/net/announce.c +++ b/net/announce.c @@ -38,6 +38,8 @@ void qemu_announce_timer_del(AnnounceTimer *timer) timer_free(timer->tm); timer->tm =3D NULL; } + qapi_free_strList(timer->params.interfaces); + timer->params.interfaces =3D NULL; } =20 /* @@ -96,24 +98,47 @@ static int announce_self_create(uint8_t *buf, =20 static void qemu_announce_self_iter(NICState *nic, void *opaque) { + AnnounceTimer *timer =3D opaque; uint8_t buf[60]; int len; + bool skip; + + if (timer->params.has_interfaces) { + strList *entry =3D timer->params.interfaces; + /* Skip unless we find our name in the requested list */ + skip =3D true; + + while (entry) { + if (!strcmp(entry->value, nic->ncs->name)) { + /* Found us */ + skip =3D false; + break; + } + entry =3D entry->next; + } + } else { + skip =3D false; + } + + trace_qemu_announce_self_iter(nic->ncs->name, + qemu_ether_ntoa(&nic->conf->macaddr), sk= ip); =20 - trace_qemu_announce_self_iter(qemu_ether_ntoa(&nic->conf->macaddr)); - len =3D announce_self_create(buf, nic->conf->macaddr.a); + if (!skip) { + len =3D announce_self_create(buf, nic->conf->macaddr.a); =20 - qemu_send_packet_raw(qemu_get_queue(nic), buf, len); + qemu_send_packet_raw(qemu_get_queue(nic), buf, len); =20 - /* if the NIC provides it's own announcement support, use it as well */ - if (nic->ncs->info->announce) { - nic->ncs->info->announce(nic->ncs); + /* if the NIC provides it's own announcement support, use it as we= ll */ + if (nic->ncs->info->announce) { + nic->ncs->info->announce(nic->ncs); + } } } static void qemu_announce_self_once(void *opaque) { AnnounceTimer *timer =3D (AnnounceTimer *)opaque; =20 - qemu_foreach_nic(qemu_announce_self_iter, NULL); + qemu_foreach_nic(qemu_announce_self_iter, timer); =20 if (--timer->round) { qemu_announce_timer_step(timer); diff --git a/net/trace-events b/net/trace-events index a7937f3f3a..875ef2a0f3 100644 --- a/net/trace-events +++ b/net/trace-events @@ -1,7 +1,7 @@ # See docs/devel/tracing.txt for syntax documentation. =20 # announce.c -qemu_announce_self_iter(const char *mac) "%s" +qemu_announce_self_iter(const char *name, const char *mac, int skip) "%s:%= s skip: %d" =20 # vhost-user.c vhost_user_event(const char *chr, int event) "chr: %s got event: %d" diff --git a/qapi/net.json b/qapi/net.json index 5f7bff1637..6f2cd4f530 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -699,6 +699,9 @@ # # @step: Delay increase (in ms) after each self-announcement attempt # +# @interfaces: An optional list of interface names, which restricts the +# announcement to the listed interfaces. (Since 4.1) +# # Since: 4.0 ## =20 @@ -706,7 +709,8 @@ 'data': { 'initial': 'int', 'max': 'int', 'rounds': 'int', - 'step': 'int' } } + 'step': 'int', + '*interfaces': ['str'] } } =20 ## # @announce-self: @@ -718,9 +722,10 @@ # # Example: # -# -> { "execute": "announce-self" +# -> { "execute": "announce-self", # "arguments": { -# "initial": 50, "max": 550, "rounds": 10, "step": 50 } } +# "initial": 50, "max": 550, "rounds": 10, "step": 50, +# "interfaces": ["vn2", "vn3"] } } # <- { "return": {} } # # Since: 4.0 --=20 2.21.0 From nobody Thu May 16 23:30:13 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561058994; cv=none; d=zoho.com; s=zohoarc; b=HuX0thMq5ReJubE+x3udDop5S2UtKlSFW3mqZLbZoqbK1c7EBGeI0rphMPYE3rnC1JAyARasYt0jrlC7HRSxPkhxnoXPVbMx0X6Eqeb3UG8WiNrNri+1MxZV96z/G4wT3dVSqlNPRQr9FaZ7/M6aRecufk3NimYNgpvBogQihU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561058994; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QMZiGcN1d6V3rjw5fT+x58sV00vT68lyPgINL4RDLsU=; b=DwCkfzyuJa0M37/em18f67Rux2qQKylo5qpilSWCAYWYP/PXVHtB/GkIXq8RQwhfFNmNCim+8ZcaHZlVVC786NvjCDgtD86I3Ukf9VyF7s90AX4hhW55LJyA2qGYaG1ZpQHqsAWnSvGXFvOGiIibffi3Ygit2rN6za6xMpWKQBE= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561058994256698.5400244895928; Thu, 20 Jun 2019 12:29:54 -0700 (PDT) Received: from localhost ([::1]:52420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he2kl-0002JU-Bp for importer@patchew.org; Thu, 20 Jun 2019 15:29:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49540) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he264-0003Ut-Fs for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:47:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he261-0000EL-98 for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:47:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33320) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1he25x-0008IG-0q for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:47:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27CD230024C9 for ; Thu, 20 Jun 2019 18:47:15 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-203.ams2.redhat.com [10.36.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0A1F5D71C; Thu, 20 Jun 2019 18:47:13 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, jasowang@redhat.com, eblake@redhat.com, armbru@redhat.com, laine@redhat.com Date: Thu, 20 Jun 2019 19:47:03 +0100 Message-Id: <20190620184706.19988-3-dgilbert@redhat.com> In-Reply-To: <20190620184706.19988-1-dgilbert@redhat.com> References: <20190620184706.19988-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 20 Jun 2019 18:47:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v5 2/5] net/announce: Add HMP optional interface list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Add the optional interface list to the HMP command. i.e. All interfaces announce_self Just the named interfaces: announce_self vn1,vn2 Signed-off-by: Dr. David Alan Gilbert --- hmp-commands.hx | 6 ++++-- monitor/hmp-cmds.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 810b7b9283..c2a2df9708 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -955,8 +955,8 @@ ETEXI =20 { .name =3D "announce_self", - .args_type =3D "", - .params =3D "", + .args_type =3D "interfaces:s?", + .params =3D "[interfaces]", .help =3D "Trigger GARP/RARP announcements", .cmd =3D hmp_announce_self, }, @@ -967,6 +967,8 @@ STEXI Trigger a round of GARP/RARP broadcasts; this is useful for explicitly upd= ating the network infrastructure after a reconfiguration or some forms of migration. The timings of the round are set by the migration announce parameters. +An optional comma separated @var{interfaces} list restricts the announce t= o the +named set of interfaces. ETEXI =20 { diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index a7ae586723..a3d34b12fe 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -27,6 +27,7 @@ #include "monitor/monitor-internal.h" #include "monitor/qdev.h" #include "qapi/error.h" +#include "qapi/clone-visitor.h" #include "qapi/opts-visitor.h" #include "qapi/qapi-builtin-visit.h" #include "qapi/qapi-commands-block.h" @@ -38,6 +39,7 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-visit-net.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/string-input-visitor.h" @@ -67,6 +69,32 @@ static void hmp_handle_error(Monitor *mon, Error **errp) } } =20 +/* + * Produce a strList from a comma separated list. + * A NULL or empty input string return NULL. + */ +static strList *strList_from_comma_list(const char *in) +{ + strList *res =3D NULL; + strList **hook =3D &res; + + while (in && in[0]) { + char *comma =3D strchr(in, ','); + *hook =3D g_new0(strList, 1); + + if (comma) { + (*hook)->value =3D g_strndup(in, comma - in); + in =3D comma + 1; /* skip the , */ + } else { + (*hook)->value =3D g_strdup(in); + in =3D NULL; + } + hook =3D &(*hook)->next; + } + + return res; +} + void hmp_info_name(Monitor *mon, const QDict *qdict) { NameInfo *info; @@ -1640,7 +1668,15 @@ void hmp_info_snapshots(Monitor *mon, const QDict *q= dict) =20 void hmp_announce_self(Monitor *mon, const QDict *qdict) { - qmp_announce_self(migrate_announce_params(), NULL); + const char *interfaces_str =3D qdict_get_try_str(qdict, "interfaces"); + AnnounceParameters *params =3D QAPI_CLONE(AnnounceParameters, + migrate_announce_params()); + + qapi_free_strList(params->interfaces); + params->interfaces =3D strList_from_comma_list(interfaces_str); + params->has_interfaces =3D params->interfaces !=3D NULL; + qmp_announce_self(params, NULL); + qapi_free_AnnounceParameters(params); } =20 void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) --=20 2.21.0 From nobody Thu May 16 23:30:13 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561057858; cv=none; d=zoho.com; s=zohoarc; b=HisY0LQlMsSkrJaiopMboqgTi4uWJCkBa6fEvT4PSkZCiqWNYZIpLGYvbAo7T0rIF0inMoCt6/e7H1pEhRME7gnZZu3oPsg0VZtwN0lpdwlYjM3Kuwyv8KewdOUaY/ujW+qrOUEWVGdnmHNpJBgAnkCs9btzaCAFCmwsScUOabI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561057858; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3b89N1GpBGB4HgR12jN9chgi3tn8hpnFg1et0haFY+0=; b=hS5rHXrXCsRMuO3udd5bcnDOcM0AwYaoOwH6hqoTDzVvfrWgqDDCnbwuixAT6hxk8z1vpZShh9IA6x+3ThKDSEWKvvo2l0dCSNsGLSytqeFGsA9J50PmsWvuufZmlTCELNFviFj7yoQksaiKdrtjImOovDQZzRaoIoCr/HuYtsg= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561057858614903.6221467542817; Thu, 20 Jun 2019 12:10:58 -0700 (PDT) Received: from localhost ([::1]:52288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he2SX-00019u-Jh for importer@patchew.org; Thu, 20 Jun 2019 15:10:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49687) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he26Y-0003c8-Gy for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he26W-0000jV-FZ for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1he26U-0008Jr-NJ for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D8305945D for ; Thu, 20 Jun 2019 18:47:16 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-203.ams2.redhat.com [10.36.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70FD05D71C; Thu, 20 Jun 2019 18:47:15 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, jasowang@redhat.com, eblake@redhat.com, armbru@redhat.com, laine@redhat.com Date: Thu, 20 Jun 2019 19:47:04 +0100 Message-Id: <20190620184706.19988-4-dgilbert@redhat.com> In-Reply-To: <20190620184706.19988-1-dgilbert@redhat.com> References: <20190620184706.19988-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 20 Jun 2019 18:47:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v5 3/5] net/announce: Add optional ID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Previously there was a single instance of the timer used by monitor triggered announces, that's OK, but when combined with the previous change that lets you have announces for subsets of interfaces it's a bit restrictive if you want to do different things to different interfaces. Add an 'id' field to the announce, and maintain a list of the timers based on id. This allows you to for example: a) Start an announce going on interface eth0 for a long time b) Start an announce going on interface eth1 for a long time c) Kill the announce on eth0 while leaving eth1 going. Signed-off-by: Dr. David Alan Gilbert --- hw/net/virtio-net.c | 4 ++-- include/net/announce.h | 8 +++++-- net/announce.c | 52 ++++++++++++++++++++++++++++++++++++------ net/trace-events | 3 ++- qapi/net.json | 9 ++++++-- 5 files changed, 62 insertions(+), 14 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index c3f5fccfd1..b9e1cd71cf 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2360,7 +2360,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) timer_mod(n->announce_timer.tm, qemu_clock_get_ms(n->announce_timer.type)); } else { - qemu_announce_timer_del(&n->announce_timer); + qemu_announce_timer_del(&n->announce_timer, false); } } =20 @@ -2784,7 +2784,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev, Error **errp) virtio_net_del_queue(n, i); } =20 - qemu_announce_timer_del(&n->announce_timer); + qemu_announce_timer_del(&n->announce_timer, false); g_free(n->vqs); qemu_del_nic(n->nic); virtio_net_rsc_cleanup(n); diff --git a/include/net/announce.h b/include/net/announce.h index 773470428b..3d90c83c23 100644 --- a/include/net/announce.h +++ b/include/net/announce.h @@ -22,8 +22,12 @@ struct AnnounceTimer { /* Returns: update the timer to the next time point */ int64_t qemu_announce_timer_step(AnnounceTimer *timer); =20 -/* Delete the underlying timer and other data */ -void qemu_announce_timer_del(AnnounceTimer *timer); +/* + * Delete the underlying timer and other data + * If 'free_named' true and the timer is a named timer, then remove + * it from the list of named timers and free the AnnounceTimer itself. + */ +void qemu_announce_timer_del(AnnounceTimer *timer, bool free_named); =20 /* * Under BQL/main thread diff --git a/net/announce.c b/net/announce.c index 1ce42b571d..db90d3bd4b 100644 --- a/net/announce.c +++ b/net/announce.c @@ -15,6 +15,8 @@ #include "qapi/qapi-commands-net.h" #include "trace.h" =20 +static GData *named_timers; + int64_t qemu_announce_timer_step(AnnounceTimer *timer) { int64_t step; @@ -31,8 +33,13 @@ int64_t qemu_announce_timer_step(AnnounceTimer *timer) return step; } =20 -void qemu_announce_timer_del(AnnounceTimer *timer) +/* + * If 'free_named' is true, then remove the timer from the list + * and free the timer itself. + */ +void qemu_announce_timer_del(AnnounceTimer *timer, bool free_named) { + bool free_timer =3D false; if (timer->tm) { timer_del(timer->tm); timer_free(timer->tm); @@ -40,6 +47,24 @@ void qemu_announce_timer_del(AnnounceTimer *timer) } qapi_free_strList(timer->params.interfaces); timer->params.interfaces =3D NULL; + if (free_named && timer->params.has_id) { + AnnounceTimer *list_timer; + /* + * Sanity check: There should only be one timer on the list with + * the id. + */ + list_timer =3D g_datalist_get_data(&named_timers, timer->params.id= ); + assert(timer =3D=3D list_timer); + free_timer =3D true; + g_datalist_remove_data(&named_timers, timer->params.id); + } + trace_qemu_announce_timer_del(free_named, free_timer, timer->params.id= ); + g_free(timer->params.id); + timer->params.id =3D NULL; + + if (free_timer) { + g_free(timer); + } } =20 /* @@ -56,7 +81,7 @@ void qemu_announce_timer_reset(AnnounceTimer *timer, * We're under the BQL, so the current timer can't * be firing, so we should be able to delete it. */ - qemu_announce_timer_del(timer); + qemu_announce_timer_del(timer, false); =20 QAPI_CLONE_MEMBERS(AnnounceParameters, &timer->params, params); timer->round =3D params->rounds; @@ -120,7 +145,8 @@ static void qemu_announce_self_iter(NICState *nic, void= *opaque) skip =3D false; } =20 - trace_qemu_announce_self_iter(nic->ncs->name, + trace_qemu_announce_self_iter(timer->params.has_id ? timer->params.id = : "_", + nic->ncs->name, qemu_ether_ntoa(&nic->conf->macaddr), sk= ip); =20 if (!skip) { @@ -143,7 +169,7 @@ static void qemu_announce_self_once(void *opaque) if (--timer->round) { qemu_announce_timer_step(timer); } else { - qemu_announce_timer_del(timer); + qemu_announce_timer_del(timer, true); } } =20 @@ -154,12 +180,24 @@ void qemu_announce_self(AnnounceTimer *timer, Announc= eParameters *params) if (params->rounds) { qemu_announce_self_once(timer); } else { - qemu_announce_timer_del(timer); + qemu_announce_timer_del(timer, true); } } =20 void qmp_announce_self(AnnounceParameters *params, Error **errp) { - static AnnounceTimer announce_timer; - qemu_announce_self(&announce_timer, params); + AnnounceTimer *named_timer; + if (!params->has_id) { + params->id =3D g_strdup(""); + params->has_id =3D true; + } + + named_timer =3D g_datalist_get_data(&named_timers, params->id); + + if (!named_timer) { + named_timer =3D g_new0(AnnounceTimer, 1); + g_datalist_set_data(&named_timers, params->id, named_timer); + } + + qemu_announce_self(named_timer, params); } diff --git a/net/trace-events b/net/trace-events index 875ef2a0f3..ac57056497 100644 --- a/net/trace-events +++ b/net/trace-events @@ -1,7 +1,8 @@ # See docs/devel/tracing.txt for syntax documentation. =20 # announce.c -qemu_announce_self_iter(const char *name, const char *mac, int skip) "%s:%= s skip: %d" +qemu_announce_self_iter(const char *id, const char *name, const char *mac,= int skip) "%s:%s:%s skip: %d" +qemu_announce_timer_del(bool free_named, bool free_timer, char *id) "free = named: %d free timer: %d id: %s" =20 # vhost-user.c vhost_user_event(const char *chr, int event) "chr: %s got event: %d" diff --git a/qapi/net.json b/qapi/net.json index 6f2cd4f530..728990f4fb 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -702,6 +702,10 @@ # @interfaces: An optional list of interface names, which restricts the # announcement to the listed interfaces. (Since 4.1) # +# @id: A name to be used to identify an instance of announce-timers +# and to allow it to modified later. Not for use as +# part of the migration parameters. (Since 4.1) +# # Since: 4.0 ## =20 @@ -710,7 +714,8 @@ 'max': 'int', 'rounds': 'int', 'step': 'int', - '*interfaces': ['str'] } } + '*interfaces': ['str'], + '*id' : 'str' } } =20 ## # @announce-self: @@ -725,7 +730,7 @@ # -> { "execute": "announce-self", # "arguments": { # "initial": 50, "max": 550, "rounds": 10, "step": 50, -# "interfaces": ["vn2", "vn3"] } } +# "interfaces": ["vn2", "vn3"], "id": "bob" } } # <- { "return": {} } # # Since: 4.0 --=20 2.21.0 From nobody Thu May 16 23:30:13 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561059584; cv=none; d=zoho.com; s=zohoarc; b=W7eHj4RERoY9bxI6tjgPBhCXYJjMJOHLBS5XQh/BwuA0qxXaKmQUwFQz984kjgeL9Xrb2IZFMpxx2Lny/rNhcIl9CllFshXdv/rGBHB3ydHeUgxQpPD6QxUHbHEFpKxyLEO7yI0DgQyQKrs1HGNeUPGvBFyx/K0XmXaPlc2umDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561059584; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3pJw3oQp07z+5W9/DItosWk6D0NqcDB2T8UlhZHkceM=; b=SibPlifXxv744bpgcXm3qPQemOc0LN0GWontMN/87TzGmPl/snyE+vJmXQkLrPn1rp0pBAEiB3oVxT9VZhJirHbK6MJgiV2S/T84nBb1Eeq2jmaVCL3nwywoyxN7UwlQs1GzTipiPBeitCBdkb+Ry+536l9Z9dGbHxBNKng3Vwc= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15610595842931016.5970477347958; Thu, 20 Jun 2019 12:39:44 -0700 (PDT) Received: from localhost ([::1]:52480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he2uJ-0007uU-Lt for importer@patchew.org; Thu, 20 Jun 2019 15:39:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49925) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he26x-0003qq-Mz for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he26v-0001QY-3F for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45372) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1he26t-0008Js-3G for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1F97060CC for ; Thu, 20 Jun 2019 18:47:18 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-203.ams2.redhat.com [10.36.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5E645D71C; Thu, 20 Jun 2019 18:47:16 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, jasowang@redhat.com, eblake@redhat.com, armbru@redhat.com, laine@redhat.com Date: Thu, 20 Jun 2019 19:47:05 +0100 Message-Id: <20190620184706.19988-5-dgilbert@redhat.com> In-Reply-To: <20190620184706.19988-1-dgilbert@redhat.com> References: <20190620184706.19988-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 20 Jun 2019 18:47:18 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v5 4/5] net/announce: Add HMP optional ID X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Add the optional ID to the HMP command. e.g. # start an announce for a long time on eth1 migrate_set_parameter announce-rounds 1000 announce_self "eth1" e1 # start an announce on eth2 announce_self "eth2" e2 # Change e1 to be announcing on eth1 and eth3 announce_self "eth1,eth3" e1 # Cancel e1 migrate_set_parameter announce-rounds 0 announce_self "" e1 Signed-off-by: Dr. David Alan Gilbert --- hmp-commands.hx | 7 ++++--- monitor/hmp-cmds.c | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index c2a2df9708..61d0be29d8 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -955,8 +955,8 @@ ETEXI =20 { .name =3D "announce_self", - .args_type =3D "interfaces:s?", - .params =3D "[interfaces]", + .args_type =3D "interfaces:s?,id:s?", + .params =3D "[interfaces] [id]", .help =3D "Trigger GARP/RARP announcements", .cmd =3D hmp_announce_self, }, @@ -968,7 +968,8 @@ Trigger a round of GARP/RARP broadcasts; this is useful= for explicitly updating network infrastructure after a reconfiguration or some forms of migration. The timings of the round are set by the migration announce parameters. An optional comma separated @var{interfaces} list restricts the announce t= o the -named set of interfaces. +named set of interfaces. An optional @var{id} can be used to start a separ= ate announce +timer and to change the parameters of it later. ETEXI =20 { diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index a3d34b12fe..96715c7103 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1669,12 +1669,15 @@ void hmp_info_snapshots(Monitor *mon, const QDict *= qdict) void hmp_announce_self(Monitor *mon, const QDict *qdict) { const char *interfaces_str =3D qdict_get_try_str(qdict, "interfaces"); + const char *id =3D qdict_get_try_str(qdict, "id"); AnnounceParameters *params =3D QAPI_CLONE(AnnounceParameters, migrate_announce_params()); =20 qapi_free_strList(params->interfaces); params->interfaces =3D strList_from_comma_list(interfaces_str); params->has_interfaces =3D params->interfaces !=3D NULL; + params->id =3D g_strdup(id); + params->has_id =3D !!params->id; qmp_announce_self(params, NULL); qapi_free_AnnounceParameters(params); } --=20 2.21.0 From nobody Thu May 16 23:30:13 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1561059018; cv=none; d=zoho.com; s=zohoarc; b=lfh5VQNfiTpYM4QmsJZ+08Nr70YdAw9J2PXcte0CvEu/9vadO1+bgiriG5ddOGQdzabjfzILtTVXqoE5+QeivXIiIDIb+mKcSwPtjpLKH/BkgvGayDT7njExAQOc62BCxEFhILsKMr72LTJ/9DcWdvxKh3s3wqV5/ztlUSRe58s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561059018; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Modc8rPgXxcmobvILCQCMBJJnr6Wx4Zp+TffoGn2T/4=; b=MdQR1xl9wV/F0it/0d51nPNnRyMdkBmy/9VsNJmsPGhJsMqx/Q5+IUgqqTI3iKCz1GJsakbXLTaChMI3bam0zGL03YTy82jreLU1eJ3FCvebyCAT7EF1kpfUFZDeGquvauEWHCPdaYWP0yCfAlXC/9Jt5I386BzDXuJ31ZSEqpM= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561059018382837.1941504827106; Thu, 20 Jun 2019 12:30:18 -0700 (PDT) Received: from localhost ([::1]:52422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he2lA-0002Tq-58 for importer@patchew.org; Thu, 20 Jun 2019 15:30:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49926) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he26x-0003qr-NA for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he26v-0001TO-Ge for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57626) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1he26v-0008Kd-8X for qemu-devel@nongnu.org; Thu, 20 Jun 2019 14:48:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95978C18B2C8 for ; Thu, 20 Jun 2019 18:47:19 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-203.ams2.redhat.com [10.36.117.203]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66CCC5B683; Thu, 20 Jun 2019 18:47:18 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, jasowang@redhat.com, eblake@redhat.com, armbru@redhat.com, laine@redhat.com Date: Thu, 20 Jun 2019 19:47:06 +0100 Message-Id: <20190620184706.19988-6-dgilbert@redhat.com> In-Reply-To: <20190620184706.19988-1-dgilbert@redhat.com> References: <20190620184706.19988-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 20 Jun 2019 18:47:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v5 5/5] net/announce: Expand test for stopping self announce X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Expand self-announce test to check we can stop an announce timer. We set it up to send 300 packets, but after we receive the first one we tell it to stop. We error if: a) We receive more than 30 of the packets b) We're still receiving packets after a lot longer than the 30 seconds should have arrived Signed-off-by: Dr. David Alan Gilbert --- tests/virtio-net-test.c | 57 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index 663cf7ea7e..7aa9622f30 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -184,21 +184,72 @@ static void announce_self(void *obj, void *data, QGue= stAllocator *t_alloc) QDict *rsp; int ret; uint16_t *proto =3D (uint16_t *)&buffer[12]; + size_t total_received =3D 0; + uint64_t start, now, last_rxt, deadline; =20 + /* Send a set of packets over a few second period */ rsp =3D qmp("{ 'execute' : 'announce-self', " " 'arguments': {" - " 'initial': 50, 'max': 550," - " 'rounds': 10, 'step': 50 } }"); + " 'initial': 20, 'max': 100," + " 'rounds': 300, 'step': 10, 'id': 'bob' } }"); assert(!qdict_haskey(rsp, "error")); qobject_unref(rsp); =20 - /* Catch the packet and make sure it's a RARP */ + /* Catch the first packet and make sure it's a RARP */ ret =3D qemu_recv(sv[0], &len, sizeof(len), 0); g_assert_cmpint(ret, =3D=3D, sizeof(len)); len =3D ntohl(len); =20 ret =3D qemu_recv(sv[0], buffer, len, 0); g_assert_cmpint(*proto, =3D=3D, htons(ETH_P_RARP)); + + /* + * Stop the announcment by settings rounds to 0 on the + * existing timer. + */ + rsp =3D qmp("{ 'execute' : 'announce-self', " + " 'arguments': {" + " 'initial': 20, 'max': 100," + " 'rounds': 0, 'step': 10, 'id': 'bob' } }"); + assert(!qdict_haskey(rsp, "error")); + qobject_unref(rsp); + + /* Now make sure the packets stop */ + + /* Times are in us */ + start =3D g_get_monotonic_time(); + /* 30 packets, max gap 100ms, * 4 for wiggle */ + deadline =3D start + 1000 * (100 * 30 * 4); + last_rxt =3D start; + + while (true) { + int saved_err; + ret =3D qemu_recv(sv[0], buffer, 60, MSG_DONTWAIT); + saved_err =3D errno; + now =3D g_get_monotonic_time(); + g_assert_cmpint(now, <, deadline); + + if (ret >=3D 0) { + if (ret) { + last_rxt =3D now; + } + total_received +=3D ret; + + /* Check it's not spewing loads */ + g_assert_cmpint(total_received, <, 60 * 30 * 2); + } else { + g_assert_cmpint(saved_err, =3D=3D, EAGAIN); + + /* 400ms, i.e. 4 worst case gaps */ + if ((now - last_rxt) > (1000 * 100 * 4)) { + /* Nothings arrived for a while - must have stopped */ + break; + }; + + /* 100ms */ + g_usleep(1000 * 100); + } + }; } =20 static void virtio_net_test_cleanup(void *sockets) --=20 2.21.0