net/announce: Allow optional list of interfaces
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 <dgilbert@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
4623027d86
commit
ef2fdbfb4d
|
@ -22,7 +22,7 @@ struct AnnounceTimer {
|
||||||
/* Returns: update the timer to the next time point */
|
/* Returns: update the timer to the next time point */
|
||||||
int64_t qemu_announce_timer_step(AnnounceTimer *timer);
|
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);
|
void qemu_announce_timer_del(AnnounceTimer *timer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -38,6 +38,8 @@ void qemu_announce_timer_del(AnnounceTimer *timer)
|
||||||
timer_free(timer->tm);
|
timer_free(timer->tm);
|
||||||
timer->tm = NULL;
|
timer->tm = NULL;
|
||||||
}
|
}
|
||||||
|
qapi_free_strList(timer->params.interfaces);
|
||||||
|
timer->params.interfaces = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -96,24 +98,47 @@ static int announce_self_create(uint8_t *buf,
|
||||||
|
|
||||||
static void qemu_announce_self_iter(NICState *nic, void *opaque)
|
static void qemu_announce_self_iter(NICState *nic, void *opaque)
|
||||||
{
|
{
|
||||||
|
AnnounceTimer *timer = opaque;
|
||||||
uint8_t buf[60];
|
uint8_t buf[60];
|
||||||
int len;
|
int len;
|
||||||
|
bool skip;
|
||||||
|
|
||||||
trace_qemu_announce_self_iter(qemu_ether_ntoa(&nic->conf->macaddr));
|
if (timer->params.has_interfaces) {
|
||||||
len = announce_self_create(buf, nic->conf->macaddr.a);
|
strList *entry = timer->params.interfaces;
|
||||||
|
/* Skip unless we find our name in the requested list */
|
||||||
|
skip = true;
|
||||||
|
|
||||||
qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
|
while (entry) {
|
||||||
|
if (!strcmp(entry->value, nic->ncs->name)) {
|
||||||
|
/* Found us */
|
||||||
|
skip = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
entry = entry->next;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
skip = false;
|
||||||
|
}
|
||||||
|
|
||||||
/* if the NIC provides it's own announcement support, use it as well */
|
trace_qemu_announce_self_iter(nic->ncs->name,
|
||||||
if (nic->ncs->info->announce) {
|
qemu_ether_ntoa(&nic->conf->macaddr), skip);
|
||||||
nic->ncs->info->announce(nic->ncs);
|
|
||||||
|
if (!skip) {
|
||||||
|
len = announce_self_create(buf, nic->conf->macaddr.a);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void qemu_announce_self_once(void *opaque)
|
static void qemu_announce_self_once(void *opaque)
|
||||||
{
|
{
|
||||||
AnnounceTimer *timer = (AnnounceTimer *)opaque;
|
AnnounceTimer *timer = (AnnounceTimer *)opaque;
|
||||||
|
|
||||||
qemu_foreach_nic(qemu_announce_self_iter, NULL);
|
qemu_foreach_nic(qemu_announce_self_iter, timer);
|
||||||
|
|
||||||
if (--timer->round) {
|
if (--timer->round) {
|
||||||
qemu_announce_timer_step(timer);
|
qemu_announce_timer_step(timer);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# See docs/devel/tracing.txt for syntax documentation.
|
# See docs/devel/tracing.txt for syntax documentation.
|
||||||
|
|
||||||
# announce.c
|
# 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.c
|
||||||
vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
|
vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
|
||||||
|
|
|
@ -699,6 +699,9 @@
|
||||||
#
|
#
|
||||||
# @step: Delay increase (in ms) after each self-announcement attempt
|
# @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
|
# Since: 4.0
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@ -706,7 +709,8 @@
|
||||||
'data': { 'initial': 'int',
|
'data': { 'initial': 'int',
|
||||||
'max': 'int',
|
'max': 'int',
|
||||||
'rounds': 'int',
|
'rounds': 'int',
|
||||||
'step': 'int' } }
|
'step': 'int',
|
||||||
|
'*interfaces': ['str'] } }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @announce-self:
|
# @announce-self:
|
||||||
|
@ -718,9 +722,10 @@
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
#
|
#
|
||||||
# -> { "execute": "announce-self"
|
# -> { "execute": "announce-self",
|
||||||
# "arguments": {
|
# "arguments": {
|
||||||
# "initial": 50, "max": 550, "rounds": 10, "step": 50 } }
|
# "initial": 50, "max": 550, "rounds": 10, "step": 50,
|
||||||
|
# "interfaces": ["vn2", "vn3"] } }
|
||||||
# <- { "return": {} }
|
# <- { "return": {} }
|
||||||
#
|
#
|
||||||
# Since: 4.0
|
# Since: 4.0
|
||||||
|
|
Loading…
Reference in New Issue