From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
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 <dgilbert@redhat.com>
---
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);
-/* Delete the underlying timer */
+/* Delete the underlying timer and other data */
void qemu_announce_timer_del(AnnounceTimer *timer);
/*
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 = NULL;
}
+ qapi_free_strList(timer->params.ifaces);
+ timer->params.ifaces = NULL;
}
/*
@@ -96,24 +98,47 @@ static int announce_self_create(uint8_t *buf,
static void qemu_announce_self_iter(NICState *nic, void *opaque)
{
+ AnnounceTimer *timer = opaque;
uint8_t buf[60];
int len;
+ bool skip;
+
+ if (timer->params.has_ifaces) {
+ strList *entry = timer->params.ifaces;
+ /* Skip unless we find our name in the requested list */
+ skip = true;
+
+ while (entry) {
+ if (!strcmp(entry->value, nic->ncs->name)) {
+ /* Found us */
+ skip = false;
+ break;
+ }
+ entry = entry->next;
+ }
+ } else {
+ skip = false;
+ }
+
+ trace_qemu_announce_self_iter(nic->ncs->name,
+ qemu_ether_ntoa(&nic->conf->macaddr), skip);
- trace_qemu_announce_self_iter(qemu_ether_ntoa(&nic->conf->macaddr));
- len = announce_self_create(buf, nic->conf->macaddr.a);
+ if (!skip) {
+ len = announce_self_create(buf, nic->conf->macaddr.a);
- qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
+ qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
- /* 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 well */
+ if (nic->ncs->info->announce) {
+ nic->ncs->info->announce(nic->ncs);
+ }
}
}
static void qemu_announce_self_once(void *opaque)
{
AnnounceTimer *timer = (AnnounceTimer *)opaque;
- qemu_foreach_nic(qemu_announce_self_iter, NULL);
+ qemu_foreach_nic(qemu_announce_self_iter, timer);
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.
# 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"
# 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'] } }
##
# @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
--
2.21.0
On 5/23/19 9:58 AM, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> 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 <dgilbert@redhat.com>
> ---
> +++ b/qapi/net.json
> @@ -706,7 +706,8 @@
> 'data': { 'initial': 'int',
> 'max': 'int',
> 'rounds': 'int',
> - 'step': 'int' } }
> + 'step': 'int',
> + '*ifaces': ['str'] } }
Missing documentation for the addition, including a '(since 4.1)' tag.
>
> ##
> # @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
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
* Eric Blake (eblake@redhat.com) wrote:
> On 5/23/19 9:58 AM, Dr. David Alan Gilbert (git) wrote:
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > 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 <dgilbert@redhat.com>
> > ---
>
> > +++ b/qapi/net.json
> > @@ -706,7 +706,8 @@
> > 'data': { 'initial': 'int',
> > 'max': 'int',
> > 'rounds': 'int',
> > - 'step': 'int' } }
> > + 'step': 'int',
> > + '*ifaces': ['str'] } }
>
> Missing documentation for the addition, including a '(since 4.1)' tag.
Oops, thanks, added:
# @ifaces: An optional list of interface names, which restrict the
# announcment to the listed interfaces. (Since 4.1)
#
Dave
> >
> > ##
> > # @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
> >
>
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc. +1-919-301-3226
> Virtualization: qemu.org | libvirt.org
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> writes:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> 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 <dgilbert@redhat.com>
[...]
> 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'] } }
QMP traditionally eschews abbreviations like "iface".
>
> ##
> # @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
* Markus Armbruster (armbru@redhat.com) wrote:
> "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> writes:
>
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > 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 <dgilbert@redhat.com>
> [...]
> > 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'] } }
>
> QMP traditionally eschews abbreviations like "iface".
OK, renamed 'interfaces'
Dave
> >
> > ##
> > # @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
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
© 2016 - 2026 Red Hat, Inc.