From nobody Fri May 3 16:39:31 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=1560420246; cv=none; d=zoho.com; s=zohoarc; b=B6+ye1qJQypib20M8JgM0q0wQnYKXfUt1qbDdQTcSxNRNR3aEiTp59GnIhAPOVee11IF4LQplGUG4irGxTLsW4RX3WpTwYrCm+9Oy6pIfSSaJ8G0MWN7C2uqCjUPfQFMaYSpL1LteOyRqKyTGaj46KE5q/xTxplPSDE1GT4pVls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560420246; 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=d1oEKIgrtSRHLKYN2pZJFleKVZFJotTzvJdm2uMvyKEurrT1wlCQ6WmwloDeXfrPU7OqtyKMdDtvZ4m1DTRvQ1tprWkWuVsRqxHGOMs2iySojd4A+682fGVLV4aUMvz3i1IdNGVIP8PvvH/uk1omZ/etjbi7CgeTxNZGbZZnb6Q= 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 1560420246113643.627656573751; Thu, 13 Jun 2019 03:04:06 -0700 (PDT) Received: from localhost ([::1]:38152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMaR-0000Nu-2X for importer@patchew.org; Thu, 13 Jun 2019 06:04:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56283) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMWE-0007MB-0o for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbMWC-0005xl-AN for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45258) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbMWC-0005xN-2o for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:40 -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 4F62B30BBEA4 for ; Thu, 13 Jun 2019 09:59:34 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D81B544EE; Thu, 13 Jun 2019 09:59:32 +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, 13 Jun 2019 10:59:20 +0100 Message-Id: <20190613095924.21908-2-dgilbert@redhat.com> In-Reply-To: <20190613095924.21908-1-dgilbert@redhat.com> References: <20190613095924.21908-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.46]); Thu, 13 Jun 2019 09:59:34 +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 v4 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 Fri May 3 16:39:31 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=1560420941; cv=none; d=zoho.com; s=zohoarc; b=fMUY1IQ/rztIYDbTvYYAJO8NS5/yLIfDcNqyzBx+ZF6HfCMjG8muEPCiSIK7jXOO6Zo4Ovf4wa50XtdNu1iOZnTL3rW46wu3HSpwFVWQvz9+4nb8B4DHLU1rh9dWjyO4wqoBhLZiA4sYYin0ZtrJHZ1Q/J+Ac0DG5LwgBqKxWiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560420941; 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=/LutmIEGQiNBhEmb88F5TBMP0LkVDA3lDxmwmEH9ElI=; b=TJugTsaoD6QIFKq9cmpPeD3a98R5448t5lbXuRg9F7MycNKIhQ3fDXHzWxxwX9Zrv8F/AtV0qvQFudsevUssV/Rc8nJdNdW/jlsM3KwUBi4bbhZ80mq6Wx6s//Li+IlGNW+/sUkKdofxth/KJYgfAW+RDbiDt0RNSSjFw/U88ek= 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 1560420941351125.18848546517609; Thu, 13 Jun 2019 03:15:41 -0700 (PDT) Received: from localhost ([::1]:38232 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMld-00085t-37 for importer@patchew.org; Thu, 13 Jun 2019 06:15:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56315) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMWG-0007MW-Is for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbMWF-0005zi-8W for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57520) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbMWE-0005ym-Ic for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:42 -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 CC0BA7EBC1 for ; Thu, 13 Jun 2019 09:59:36 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98C20544EE; Thu, 13 Jun 2019 09:59:34 +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, 13 Jun 2019 10:59:21 +0100 Message-Id: <20190613095924.21908-3-dgilbert@redhat.com> In-Reply-To: <20190613095924.21908-1-dgilbert@redhat.com> References: <20190613095924.21908-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.27]); Thu, 13 Jun 2019 09:59:36 +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 v4 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 ++++-- hmp.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 3dc421cb6a..1b63372713 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/hmp.c b/hmp.c index d4460992b6..52efb4a4fa 100644 --- a/hmp.c +++ b/hmp.c @@ -27,6 +27,7 @@ #include "monitor/monitor.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 Fri May 3 16:39:31 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=1560420695; cv=none; d=zoho.com; s=zohoarc; b=YqCLkn3EwCfvlaTOzUzLqDBZCtGQJ7vQv1VoRrcrqLzYGGVlKWFPvSXROyM3RMWUgJAe9h15oQ7lqqjY6xowhVtSG6H4I0HPdu7Lq9w0tu/aUTwmYv9QhiTUpMBAI4VIWgZL0nj3j2rfHpdhYZgtTY78B0GDTjGA7q/VjvoaEpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560420695; 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=BB7iVU7e+C41+cQEkrv0d4fI2Ll46ihZ5WP+rUhHm7E=; b=dpyn1IaAot4sbmCKRRb5jOoGOzmbRxybuGR1kz3TyY8DziQDgTai6dYR3/vABQ6wyNNlr8GHH2OMVa3/yyk3zH615ZfQJBJzuDW8PnYnn+uVF+HiXh87G0yOWGYENrV2sG/jwPk/ZjhDjINhyAM7Js8uk24BCw74GCC9kGhORm4= 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 1560420695781263.85918663278255; Thu, 13 Jun 2019 03:11:35 -0700 (PDT) Received: from localhost ([::1]:38216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMhi-0005M9-RA for importer@patchew.org; Thu, 13 Jun 2019 06:11:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56309) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMWG-0007MT-Fo for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbMWD-0005yf-Uw for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbMWD-0005xz-At for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:41 -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 975A7316291E for ; Thu, 13 Jun 2019 09:59:40 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2112454474; Thu, 13 Jun 2019 09:59:36 +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, 13 Jun 2019 10:59:22 +0100 Message-Id: <20190613095924.21908-4-dgilbert@redhat.com> In-Reply-To: <20190613095924.21908-1-dgilbert@redhat.com> References: <20190613095924.21908-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.41]); Thu, 13 Jun 2019 09:59:40 +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 v4 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 | 46 +++++++++++++++++++++++++++++++++++------- net/trace-events | 3 ++- qapi/net.json | 9 +++++++-- 5 files changed, 56 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..4d4e2c22a1 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,18 @@ 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) { + free_timer =3D timer =3D=3D + g_datalist_get_data(&named_timers, timer->params.id); + 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 +75,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 +139,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 +163,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 +174,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 Fri May 3 16:39:31 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=1560420509; cv=none; d=zoho.com; s=zohoarc; b=i2if+sgrc4dnWtRh3QYX465a8JvUGiOCQL2c2wv4ShMS2lThi+OZa79m0suTFrxNEsA4zprgJACjbiQa6F+r12hZfaGPh/tJU9j8wDfa8WQIDHP7W4VIvTIb85qxelBocJ2fZIogWOvW3jWelVQMT+ffIBdnEApV2OISZ9Hkouw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560420509; 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=23wwr8zN6cZfOQ2O1aTgtw1pywasN44JJOA2KKFx4jE=; b=TRpsZ5bR2hD+zX9N9Ado75YOFGjy1OC3rn7FsWvaeDr/ZYLrBJn57D9hms3OCveIClkhU6Gf4o77Rle5aCgrWzL/CW3Qd4epw3wyanS2X9ev0oainGVdT9sQ3b9CJOHx64cwnKUkiPd99H9sU9y6ho5Ns1JoCTuEVnKrr6ZNtuA= 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 15604205094621015.2506708921044; Thu, 13 Jun 2019 03:08:29 -0700 (PDT) Received: from localhost ([::1]:38192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMei-0003gJ-HQ for importer@patchew.org; Thu, 13 Jun 2019 06:08:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56312) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMWG-0007MV-GH for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbMWF-0005zn-91 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36416) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbMWE-0005z3-R4 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:43 -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 149056EB93 for ; Thu, 13 Jun 2019 09:59:42 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF5D552FDE; Thu, 13 Jun 2019 09:59:40 +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, 13 Jun 2019 10:59:23 +0100 Message-Id: <20190613095924.21908-5-dgilbert@redhat.com> In-Reply-To: <20190613095924.21908-1-dgilbert@redhat.com> References: <20190613095924.21908-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.25]); Thu, 13 Jun 2019 09:59:42 +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 v4 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 ++++--- hmp.c | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 1b63372713..7ba8543cc3 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/hmp.c b/hmp.c index 52efb4a4fa..fd498ca0a8 100644 --- a/hmp.c +++ b/hmp.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 Fri May 3 16:39:31 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=1560421169; cv=none; d=zoho.com; s=zohoarc; b=Ls+IPnVzf4eH8u3/0CO2jnzWIq8miv3JBbezoGQ7tusLjU71vKOBZjxCfUTV4EMqhrTgoPVCGjcY23BcGKDO0A+39qv7P3IOBotRVZ7zR6U4IN2h6JAfOPrT2hTwXIY+e7sLEcG1h79W6cirRNmMwz0WotdgyQc7R8AWSn4pQvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560421169; 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=Lqg7grB9tx05Wr4iKiulL5VuwO6F7f+msxd3WcXKrbA=; b=OxTImQ6q4JxZwycxVy4vU8jpmXCG8WWHfU9mEOCamoaPjs9DZGQIBXEbhcHhWnNj7+FNbRpSx9x1FBdBRUzKFgFqBNICY9vZ80RfHGyOHp1gci1fWalEAZiKvnY8Odp23HTGGj0P6KERzEYufyGNCxoxkug4kTfkgfU8oNwTAqg= 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 1560421169968433.3713321290584; Thu, 13 Jun 2019 03:19:29 -0700 (PDT) Received: from localhost ([::1]:38260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMpN-0001zE-04 for importer@patchew.org; Thu, 13 Jun 2019 06:19:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56343) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbMWT-0007OJ-RM for qemu-devel@nongnu.org; Thu, 13 Jun 2019 06:00:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbMWO-000644-53 for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbMWG-000601-FD for qemu-devel@nongnu.org; Thu, 13 Jun 2019 05:59:45 -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 89BDC309B15A for ; Thu, 13 Jun 2019 09:59:43 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DE41544EE; Thu, 13 Jun 2019 09:59:42 +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, 13 Jun 2019 10:59:24 +0100 Message-Id: <20190613095924.21908-6-dgilbert@redhat.com> In-Reply-To: <20190613095924.21908-1-dgilbert@redhat.com> References: <20190613095924.21908-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.49]); Thu, 13 Jun 2019 09:59:43 +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 v4 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..3b49b431dc 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, * 2 for wiggle */ + deadline =3D start + 1000 * (100 * 30 * 2); + last_rxt =3D start; + + do { + 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); + } + } while (true); } =20 static void virtio_net_test_cleanup(void *sockets) --=20 2.21.0