From nobody Fri May 3 14:36:22 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=1558623809; cv=none; d=zoho.com; s=zohoarc; b=gM5qe64dokxZIGkd3JaNo2BDomD8gX88l/I0cw30UIbDbAUzruyzjUK4rOufawpkB9GAZfBBMAgc+98ZVRsuCVUbyl+e7VPxKC8/A83ctj132+msg/FZ8tmJFFeDR4SrJe3QvoPqFvMfJkg8XVnbQvBIPFSFCUoy4AjDCzrSePw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558623809; 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=0ke5iMC6Xsr/y9WLrv8Iuty7dasJR3wiStTDX4YXVCY=; b=j0Nw6WbL0WLdHa1A0UIKxesP56uwk7AjALSimmwmfIjatt3/x0cbRDJJSefyTI+VZD9QD1tSDGl78Ua/0yt7O9PtjMKvJ4fhKfcJdKL7ZJ7gozr19OgH6rWQ81QQUcHoq6rh74Y76h+0SvGNJAmNQR6SNCYShIZdqwhH328yoDk= 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 1558623809789554.8284839900646; Thu, 23 May 2019 08:03:29 -0700 (PDT) Received: from localhost ([127.0.0.1]:38351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTpFX-0002dL-2R for importer@patchew.org; Thu, 23 May 2019 11:03:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTpBS-0006o7-0I for qemu-devel@nongnu.org; Thu, 23 May 2019 10:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTpBQ-00032W-OK for qemu-devel@nongnu.org; Thu, 23 May 2019 10:59:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37770) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTpBQ-0002ti-GD for qemu-devel@nongnu.org; Thu, 23 May 2019 10:59:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C295CC329C for ; Thu, 23 May 2019 14:58:49 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-235.ams2.redhat.com [10.36.117.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C9EA620C5; Thu, 23 May 2019 14:58:46 +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, 23 May 2019 15:58:39 +0100 Message-Id: <20190523145840.11774-2-dgilbert@redhat.com> In-Reply-To: <20190523145840.11774-1-dgilbert@redhat.com> References: <20190523145840.11774-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 23 May 2019 14:58:49 +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 1/2] net/announce: Allow optional list of interfaces 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: , 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, "ifaces": ["vn2","vn1"] } } 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 | 8 +++++--- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/include/net/announce.h b/include/net/announce.h index 892d302b65..3ebffe517e 100644 --- a/include/net/announce.h +++ b/include/net/announce.h @@ -23,7 +23,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..2a85a72280 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.ifaces); + timer->params.ifaces =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_ifaces) { + strList *entry =3D timer->params.ifaces; + /* 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..871cfa7405 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -706,7 +706,8 @@ 'data': { 'initial': 'int', 'max': 'int', 'rounds': 'int', - 'step': 'int' } } + 'step': 'int', + '*ifaces': ['str'] } } =20 ## # @announce-self: @@ -718,9 +719,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, +# "ifaces": ["vn2","vn3"] } } # <- { "return": {} } # # Since: 4.0 --=20 2.21.0 From nobody Fri May 3 14:36:22 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=1558624025; cv=none; d=zoho.com; s=zohoarc; b=JYsSNuqDce7vkEwbgHgpTLcAJ8Zr+jEb0sSp9bZEUyTbqzGMbPUBj3W6mWz4uR5PN1j4uMe7PHBgEthjreNlHbdEQlDPZzRiQViTYnxCon6V44ltpCMhxzmdBcOKrTUmi1U45TD/1BAlRl6PcB2QCh4EoFpOSBZ13ahVSi/mIGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558624025; 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=Hbj5rr+/UAeCceeSF5abw/2x82o5vCYMJ8KB0A7KmxU=; b=JTQ8Oo2oXnN9YJY99EExv/aVELhEBhvkGCbfra4OyikQ1XbK4lrbT9NUNxVFxRSm2wbZavQ+X264BT9Uhn41nXT3JuCBfi8MKmL4RYTrZhe4W3AVwkRav74929NFyS6nabhjvj3IQmTocSeYIcZWhNRrzK4FFbhNxIsNIvUZQiQ= 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 1558624025624235.74002816346558; Thu, 23 May 2019 08:07:05 -0700 (PDT) Received: from localhost ([127.0.0.1]:38454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTpJ5-0004sD-9z for importer@patchew.org; Thu, 23 May 2019 11:06:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTpBR-0006o0-Qc for qemu-devel@nongnu.org; Thu, 23 May 2019 10:59:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTpBQ-00032R-O4 for qemu-devel@nongnu.org; Thu, 23 May 2019 10:59:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55405) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTpBQ-0002vu-GE for qemu-devel@nongnu.org; Thu, 23 May 2019 10:59:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4812A3179B7F for ; Thu, 23 May 2019 14:58:53 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-117-235.ams2.redhat.com [10.36.117.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id 145A3620BF; Thu, 23 May 2019 14:58:49 +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, 23 May 2019 15:58:40 +0100 Message-Id: <20190523145840.11774-3-dgilbert@redhat.com> In-Reply-To: <20190523145840.11774-1-dgilbert@redhat.com> References: <20190523145840.11774-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 23 May 2019 14:58:53 +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 2/2] net/announce: Add HMP optional interface list 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: , 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..a8cbcb7681 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 "ifaces:s?", + .params =3D "[ifaces]", .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{ifaces} list restricts the announce to th= e named +set of interfaces. ETEXI =20 { diff --git a/hmp.c b/hmp.c index a9665da6ec..f9b1c1d01d 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 *ifaces_str =3D qdict_get_try_str(qdict, "ifaces"); + AnnounceParameters *params =3D QAPI_CLONE(AnnounceParameters, + migrate_announce_params()); + + qapi_free_strList(params->ifaces); + params->ifaces =3D strList_from_comma_list(ifaces_str); + params->has_ifaces =3D params->ifaces !=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