Skip to contentSkip to conversation

network announce; interface selection & IDs

PATCH Superseded Dr. David Alan Gilbert (git) 2 participants 9 messages Jun 10, 2019 – Jun 12, 2019 Networking

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover network announce; interface selection & IDs

From: "Dr. David Alan Gilbert" <[email protected]>

Laine asked for some extra features on the network announce support;

The first allows the announce timer to announce on a subset of the interfaces.

The second allows there to be multiple timers, each with their own parameters (including the interface list).

v3
Support for multiple timers.

Dr. David Alan Gilbert (4):
net/announce: Allow optional list of interfaces
net/announce: Add HMP optional interface list
net/announce: Add optional ID
net/announce: Add HMP optional ID

 hmp-commands.hx         |  7 +++-
 hmp.c                   | 41 +++++++++++++++++++-
 hw/net/virtio-net.c     |  4 +-
 include/net/announce.h  |  8 +++-
 net/announce.c          | 83 ++++++++++++++++++++++++++++++++++-------
 net/trace-events        |  3 +-
 qapi/net.json           | 16 ++++++--
 tests/virtio-net-test.c |  2 +-
 8 files changed, 139 insertions(+), 25 deletions(-)
Signature · 1 line
2.21.0
#1 lore raw

PATCH v3 1/4 net/announce: Allow optional list of interfaces

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---
 include/net/announce.h |  2 +-
 net/announce.c         | 39 ++++++++++++++++++++++++++++++++-------
 net/trace-events       |  2 +-
 qapi/net.json          | 11 ++++++++---
 4 files changed, 42 insertions(+), 12 deletions(-)
include/net/announce.h +1 -1
index 892d302b65..3ebffe517e 100644
@@ -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);
 
 /*
net/announce.c +32 -7
index 91e9a6e267..1ce42b571d 100644
@@ -38,6 +38,8 @@ void qemu_announce_timer_del(AnnounceTimer *timer)
         timer_free(timer->tm);
         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)
 {
+    AnnounceTimer *timer = opaque;
     uint8_t buf[60];
     int len;
+    bool skip;
+
+    if (timer->params.has_interfaces) {
+        strList *entry = timer->params.interfaces;
+        /* 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);
net/trace-events +1 -1
index a7937f3f3a..875ef2a0f3 100644
@@ -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"
qapi/net.json +8 -3
index 5f7bff1637..ee9bf2c5f5 100644
@@ -699,6 +699,9 @@
 #
 # @step: Delay increase (in ms) after each self-announcement attempt
 #
+# @interfaces: An optional list of interface names, which restrict the
+#        announcment to the listed interfaces. (Since 4.1)
+#
 # Since: 4.0
 ##
 
@@ -706,7 +709,8 @@
   'data': { 'initial': 'int',
             'max': 'int',
             'rounds': 'int',
-            'step': 'int' } }
+            'step': 'int',
+            '*interfaces': ['str'] } }
 
 ##
 # @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
Signature · 1 line
2.21.0
#2 lore raw

Re: [Qemu-devel] [PATCH v3 1/4] net/announce: Allow optional list of interfaces

Quoted 21 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---

+++ b/qapi/net.json

qapi/net.json line 702

Quoted 4 lines
qapi/net.json +1 -0
@@ -699,6 +699,9 @@
 #
 # @step: Delay increase (in ms) after each self-announcement attempt
 #
+# @interfaces: An optional list of interface names, which restrict the

restricts

qapi/net.json line 703

Quoted 1 line
qapi/net.json +1 -0
+#        announcment to the listed interfaces. (Since 4.1)

announcement

Quoted 15 lines
qapi/net.json +3 -1
+#
 # Since: 4.0
 ##
 
@@ -706,7 +709,8 @@
   'data': { 'initial': 'int',
             'max': 'int',
             'rounds': 'int',
-            'step': 'int' } }
+            'step': 'int',
+            '*interfaces': ['str'] } }
 
 ##
 # @announce-self:

qapi/net.json line 725

Quoted 5 lines
qapi/net.json +1 -1
@@ -718,9 +722,10 @@
 #
 # Example:
 #
-# -> { "execute": "announce-self"
+# -> { "execute": "announce-self",

Embarrassing that we didn't notice that one earlier.

qapi/net.json line 728

Quoted 4 lines
qapi/net.json +2 -1
 #      "arguments": {
-#          "initial": 50, "max": 550, "rounds": 10, "step": 50 } }
+#          "initial": 50, "max": 550, "rounds": 10, "step": 50,
+#          "interfaces": ["vn2","vn3"] } }

Worth a space after the comma? Not required, but I think it looks nicer.

As I only focused on doc issues, I'll leave the full review to others.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#3 lore raw

Re: [Qemu-devel] [PATCH v3 1/4] net/announce: Allow optional list of interfaces

Quoted 20 lines · * Eric Blake ([email protected]) wrote:
Quoted 18 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---

Quoted 8 lines

qapi/net.json line 702

Quoted 6 lines

+++ b/qapi/net.json

qapi/net.json +1 -0
@@ -699,6 +699,9 @@
 #
 # @step: Delay increase (in ms) after each self-announcement attempt
 #
+# @interfaces: An optional list of interface names, which restrict the

restricts

Done

Quoted 3 lines

qapi/net.json line 703

Quoted 1 line
qapi/net.json +1 -0
+#        announcment to the listed interfaces. (Since 4.1)

announcement

Done

Quoted 12 lines
Quoted 12 lines
qapi/net.json +3 -1
+#
 # Since: 4.0
 ##
 
@@ -706,7 +709,8 @@
   'data': { 'initial': 'int',
             'max': 'int',
             'rounds': 'int',
-            'step': 'int' } }
+            'step': 'int',
+            '*interfaces': ['str'] } }
 
Quoted 10 lines

qapi/net.json line 725

Quoted 8 lines
qapi/net.json +1 -1
 ##
 # @announce-self:
@@ -718,9 +722,10 @@
 #
 # Example:
 #
-# -> { "execute": "announce-self"
+# -> { "execute": "announce-self",

Embarrassing that we didn't notice that one earlier.

The way to avoid it I guess would be to parse the example code.

Quoted 6 lines

qapi/net.json line 728

Quoted 4 lines
qapi/net.json +2 -1
 #      "arguments": {
-#          "initial": 50, "max": 550, "rounds": 10, "step": 50 } }
+#          "initial": 50, "max": 550, "rounds": 10, "step": 50,
+#          "interfaces": ["vn2","vn3"] } }

Worth a space after the comma? Not required, but I think it looks nicer.

Added

Quoted 1 line

As I only focused on doc issues, I'll leave the full review to others.

Thanks,

Dave

Quoted 5 lines
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#4 lore raw

PATCH v3 2/4 net/announce: Add HMP optional interface list

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Add the optional interface list to the HMP command.

i.e.

All interfaces
announce_self

Just the named interfaces:
announce_self vn1,vn2

---
 hmp-commands.hx |  6 ++++--
 hmp.c           | 38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 3 deletions(-)
hmp-commands.hx +4 -2
index 3dc421cb6a..1b63372713 100644
@@ -955,8 +955,8 @@ ETEXI
 
     {
         .name       = "announce_self",
-        .args_type  = "",
-        .params     = "",
+        .args_type  = "interfaces:s?",
+        .params     = "[interfaces]",
         .help       = "Trigger GARP/RARP announcements",
         .cmd        = hmp_announce_self,
     },
@@ -967,6 +967,8 @@ STEXI
 Trigger a round of GARP/RARP broadcasts; this is useful for explicitly updating 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 to the
+named set of interfaces.
 ETEXI
 
     {
hmp.c +37 -1
index d4460992b6..52efb4a4fa 100644
@@ -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)
     }
 }
 
+/*
+ * 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 = NULL;
+    strList **hook = &res;
+
+    while (in && in[0]) {
+        char *comma = strchr(in, ',');
+        *hook = g_new0(strList, 1);
+
+        if (comma) {
+            (*hook)->value = g_strndup(in, comma - in);
+            in = comma + 1; /* skip the , */
+        } else {
+            (*hook)->value = g_strdup(in);
+            in = NULL;
+        }
+        hook = &(*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 *qdict)
 
 void hmp_announce_self(Monitor *mon, const QDict *qdict)
 {
-    qmp_announce_self(migrate_announce_params(), NULL);
+    const char *interfaces_str = qdict_get_try_str(qdict, "interfaces");
+    AnnounceParameters *params = QAPI_CLONE(AnnounceParameters,
+                                            migrate_announce_params());
+
+    qapi_free_strList(params->interfaces);
+    params->interfaces = strList_from_comma_list(interfaces_str);
+    params->has_interfaces = params->interfaces != NULL;
+    qmp_announce_self(params, NULL);
+    qapi_free_AnnounceParameters(params);
 }
 
 void hmp_migrate_cancel(Monitor *mon, const QDict *qdict)
Signature · 1 line
2.21.0
#5 lore raw

PATCH v3 3/4 net/announce: Add optional ID

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---
 hw/net/virtio-net.c     |  4 ++--
 include/net/announce.h  |  8 +++++--
 net/announce.c          | 46 ++++++++++++++++++++++++++++++++++-------
 net/trace-events        |  3 ++-
 qapi/net.json           |  9 ++++++--
 tests/virtio-net-test.c |  2 +-
 6 files changed, 57 insertions(+), 15 deletions(-)
hw/net/virtio-net.c +2 -2
index ffe0872fff..120248bbf6 100644
@@ -2359,7 +2359,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);
         }
     }
 
@@ -2783,7 +2783,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
         virtio_net_del_queue(n, i);
     }
 
-    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);
include/net/announce.h +6 -2
index 3ebffe517e..9cf7a4f835 100644
@@ -23,8 +23,12 @@ struct AnnounceTimer {
 /* Returns: update the timer to the next time point */
 int64_t qemu_announce_timer_step(AnnounceTimer *timer);
 
-/* Delete the underlying timer and other data */
-void qemu_announce_timer_del(AnnounceTimer *timer);
+/*
+ * Delete the underlying timer and other datas
+ * 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);
 
 /*
  * Under BQL/main thread
net/announce.c +39 -7

92 lines not on this page · raw message

net/trace-events +2 -1
index 875ef2a0f3..ac57056497 100644
@@ -1,7 +1,8 @@
 # See docs/devel/tracing.txt for syntax documentation.
 
 # 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"
 
 # vhost-user.c
 vhost_user_event(const char *chr, int event) "chr: %s got event: %d"
qapi/net.json +7 -2
index ee9bf2c5f5..9da9b5bbc5 100644
@@ -702,6 +702,10 @@
 # @interfaces: An optional list of interface names, which restrict the
 #        announcment 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 paramters. (Since 4.1)
+#
 # Since: 4.0
 ##
 
@@ -710,7 +714,8 @@
             'max': 'int',
             'rounds': 'int',
             'step': 'int',
-            '*interfaces': ['str'] } }
+            '*interfaces': ['str'],
+            '*id' : 'str' } }
 
 ##
 # @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
tests/virtio-net-test.c +1 -1
index 163126cf07..7184e2bff4 100644
@@ -186,7 +186,7 @@ static void announce_self(void *obj, void *data, QGuestAllocator *t_alloc)
     rsp = qmp("{ 'execute' : 'announce-self', "
                   " 'arguments': {"
                       " 'initial': 50, 'max': 550,"
-                      " 'rounds': 10, 'step': 50 } }");
+                      " 'rounds': 10, 'step': 50, 'id': 'bob' } }");
     assert(!qdict_haskey(rsp, "error"));
     qobject_unref(rsp);
 
Signature · 1 line
2.21.0
#6 lore raw

Re: [Qemu-devel] [PATCH v3 3/4] net/announce: Add optional ID

Quoted 21 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---

+++ b/include/net/announce.h

include/net/announce.h struct AnnounceTimer { · line 27

Quoted 7 lines
include/net/announce.h +2 -2
@@ -23,8 +23,12 @@ struct AnnounceTimer {
 /* Returns: update the timer to the next time point */
 int64_t qemu_announce_timer_step(AnnounceTimer *timer);
 
-/* Delete the underlying timer and other data */
-void qemu_announce_timer_del(AnnounceTimer *timer);
+/*
+ * Delete the underlying timer and other datas

'data' is already plural, 'datas' is not a word.

Quoted 8 lines
include/net/announce.h +5 -0
+ * 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);
 
 
+++ b/qapi/net.json

include/net/announce.h line 707

Quoted 6 lines
include/net/announce.h +3 -0
@@ -702,6 +702,10 @@
 # @interfaces: An optional list of interface names, which restrict the
 #        announcment 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 paramters. (Since 4.1)

parameters

Quoted 15 lines
qapi/net.json +3 -1
+#
 # Since: 4.0
 ##
 
@@ -710,7 +714,8 @@
             'max': 'int',
             'rounds': 'int',
             'step': 'int',
-            '*interfaces': ['str'] } }
+            '*interfaces': ['str'],
+            '*id' : 'str' } }
 
 ##
 # @announce-self:

qapi/net.json line 735

Quoted 7 lines
qapi/net.json +1 -1
@@ -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": {} }
 #

Worth an example of deleting a timer by id?

tests/virtio-net-test.c static void announce_self(void *obj, void *data, QGuestAllocator *t_alloc) · line 189

Quoted 11 lines
(quoted diff) +0 -0
 # Since: 4.0
tests/virtio-net-test.c +1 -1
index 163126cf07..7184e2bff4 100644
@@ -186,7 +186,7 @@ static void announce_self(void *obj, void *data, QGuestAllocator *t_alloc)
     rsp = qmp("{ 'execute' : 'announce-self', "
                   " 'arguments': {"
                       " 'initial': 50, 'max': 550,"
-                      " 'rounds': 10, 'step': 50 } }");
+                      " 'rounds': 10, 'step': 50, 'id': 'bob' } }");

And here, is it worth testing that you can delete by id, rather than just create with an id?

Quoted 4 lines
tests/virtio-net-test.c +0 -0
     assert(!qdict_haskey(rsp, "error"));
     qobject_unref(rsp);
 
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#7 lore raw

Re: [Qemu-devel] [PATCH v3 3/4] net/announce: Add optional ID

Quoted 25 lines · * Eric Blake ([email protected]) wrote:
Quoted 24 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---

+++ b/include/net/announce.h

include/net/announce.h +0 -0
@@ -23,8 +23,12 @@ struct AnnounceTimer {
 /* Returns: update the timer to the next time point */
 int64_t qemu_announce_timer_step(AnnounceTimer *timer);
 
Quoted 6 lines

include/net/announce.h struct AnnounceTimer { · line 27

Quoted 4 lines
include/net/announce.h +2 -2
-/* Delete the underlying timer and other data */
-void qemu_announce_timer_del(AnnounceTimer *timer);
+/*
+ * Delete the underlying timer and other datas

'data' is already plural, 'datas' is not a word.

oops yes, fixed.

Quoted 6 lines
Quoted 5 lines
include/net/announce.h +4 -0
+ * 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);
 
Quoted 10 lines

qapi/net.json line 707

Quoted 8 lines
qapi/net.json +4 -0
+++ b/qapi/net.json
@@ -702,6 +702,10 @@
 # @interfaces: An optional list of interface names, which restrict the
 #        announcment 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 paramters. (Since 4.1)

parameters

Fixed.

Quoted 12 lines
Quoted 12 lines
qapi/net.json +3 -1
+#
 # Since: 4.0
 ##
 
@@ -710,7 +714,8 @@
             'max': 'int',
             'rounds': 'int',
             'step': 'int',
-            '*interfaces': ['str'] } }
+            '*interfaces': ['str'],
+            '*id' : 'str' } }
 
Quoted 13 lines

qapi/net.json line 735

Quoted 10 lines
qapi/net.json +1 -1
 ##
 # @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": {} }
 #

Worth an example of deleting a timer by id?

The syntax is actually the same - the only thing you need to do to cancel is set 'rounds' to 0 for the named id.

Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -0
 # Since: 4.0
tests/virtio-net-test.c +0 -0
index 163126cf07..7184e2bff4 100644
@@ -186,7 +186,7 @@ static void announce_self(void *obj, void *data, QGuestAllocator *t_alloc)
Quoted 8 lines

tests/virtio-net-test.c static void announce_self(void *obj, void *data, QGuestAllocator *t_alloc) · line 189

Quoted 5 lines
tests/virtio-net-test.c +1 -1
     rsp = qmp("{ 'execute' : 'announce-self', "
                   " 'arguments': {"
                       " 'initial': 50, 'max': 550,"
-                      " 'rounds': 10, 'step': 50 } }");
+                      " 'rounds': 10, 'step': 50, 'id': 'bob' } }");

And here, is it worth testing that you can delete by id, rather than just create with an id?

OK, I'll have a look at how painful that is.

Dave

Quoted 10 lines
Quoted 4 lines
tests/virtio-net-test.c +0 -0
     assert(!qdict_haskey(rsp, "error"));
     qobject_unref(rsp);
 
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#8 lore raw

PATCH v3 4/4 net/announce: Add HMP optional ID

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

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

---
 hmp-commands.hx | 7 ++++---
 hmp.c           | 3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)
hmp-commands.hx +4 -3
index 1b63372713..7ba8543cc3 100644
@@ -955,8 +955,8 @@ ETEXI
 
     {
         .name       = "announce_self",
-        .args_type  = "interfaces:s?",
-        .params     = "[interfaces]",
+        .args_type  = "interfaces:s?,id:s?",
+        .params     = "[interfaces] [id]",
         .help       = "Trigger GARP/RARP announcements",
         .cmd        = 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 to the
-named set of interfaces.
+named set of interfaces. An optional @var{id} can be used to start a separate announce
+timer and to change the parameters of it later.
 ETEXI
 
     {
hmp.c +3 -0
index 52efb4a4fa..fd498ca0a8 100644
@@ -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 = qdict_get_try_str(qdict, "interfaces");
+    const char *id = qdict_get_try_str(qdict, "id");
     AnnounceParameters *params = QAPI_CLONE(AnnounceParameters,
                                             migrate_announce_params());
 
     qapi_free_strList(params->interfaces);
     params->interfaces = strList_from_comma_list(interfaces_str);
     params->has_interfaces = params->interfaces != NULL;
+    params->id = g_strdup(id);
+    params->has_id = !!params->id;
     qmp_announce_self(params, NULL);
     qapi_free_AnnounceParameters(params);
 }
Signature · 1 line
2.21.0